@@ -1810,6 +1810,39 @@ var _ = Describe("Fake client", func() {
18101810 Expect (cmp .Diff (objOriginal , actual )).To (BeEmpty ())
18111811 })
18121812
1813+ It ("should Unmarshal the unstructured object with int64 to preserve ints" , func () {
1814+ obj := & unstructured.Unstructured {}
1815+ obj .SetAPIVersion ("foo/v1" )
1816+ obj .SetKind ("Foo" )
1817+ obj .SetName ("a-foo" )
1818+
1819+ // must be set to int64 or function will error
1820+ err := unstructured .SetNestedMap (obj .Object , map [string ]any {"value" : int64 (999 )}, "spec" )
1821+ Expect (err ).NotTo (HaveOccurred ())
1822+
1823+ cl := NewClientBuilder ().WithStatusSubresource (obj ).WithObjects (obj ).Build ()
1824+ Expect (cl .Update (context .Background (), obj )).To (Succeed ())
1825+ Expect (cl .Get (context .Background (), client .ObjectKeyFromObject (obj ), obj )).To (Succeed ())
1826+
1827+ Expect (obj .Object ["spec" ]).To (BeEquivalentTo (map [string ]any {"value" : int64 (999 )}))
1828+ })
1829+
1830+ It ("should Unmarshal the unstructured object with float64 to preserve ints" , func () {
1831+ obj := & unstructured.Unstructured {}
1832+ obj .SetAPIVersion ("foo/v1" )
1833+ obj .SetKind ("Foo" )
1834+ obj .SetName ("a-foo" )
1835+
1836+ err := unstructured .SetNestedMap (obj .Object , map [string ]any {"value" : 99.9 }, "spec" )
1837+ Expect (err ).NotTo (HaveOccurred ())
1838+
1839+ cl := NewClientBuilder ().WithStatusSubresource (obj ).WithObjects (obj ).Build ()
1840+ Expect (cl .Update (context .Background (), obj )).To (Succeed ())
1841+ Expect (cl .Get (context .Background (), client .ObjectKeyFromObject (obj ), obj )).To (Succeed ())
1842+
1843+ Expect (obj .Object ["spec" ]).To (BeEquivalentTo (map [string ]any {"value" : float64 (99.9 )}))
1844+ })
1845+
18131846 It ("should not change the status of unstructured objects that are configured to have a status subresource on update" , func () {
18141847 obj := & unstructured.Unstructured {}
18151848 obj .SetAPIVersion ("foo/v1" )
0 commit comments