@@ -1810,6 +1810,38 @@ 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+ err := unstructured .SetNestedMap (obj .Object , map [string ]any {"value" : json .Number ("999" )}, "spec" )
1820+ Expect (err ).NotTo (HaveOccurred ())
1821+
1822+ cl := NewClientBuilder ().WithStatusSubresource (obj ).WithObjects (obj ).Build ()
1823+ Expect (cl .Update (context .Background (), obj )).To (Succeed ())
1824+ Expect (cl .Get (context .Background (), client .ObjectKeyFromObject (obj ), obj )).To (Succeed ())
1825+
1826+ Expect (obj .Object ["spec" ]).To (BeEquivalentTo (map [string ]any {"value" : int64 (999 )}))
1827+ })
1828+
1829+ It ("should Unmarshal the unstructured object with float64 to preserve ints" , func () {
1830+ obj := & unstructured.Unstructured {}
1831+ obj .SetAPIVersion ("foo/v1" )
1832+ obj .SetKind ("Foo" )
1833+ obj .SetName ("a-foo" )
1834+
1835+ err := unstructured .SetNestedMap (obj .Object , map [string ]any {"value" : 99.9 }, "spec" )
1836+ Expect (err ).NotTo (HaveOccurred ())
1837+
1838+ cl := NewClientBuilder ().WithStatusSubresource (obj ).WithObjects (obj ).Build ()
1839+ Expect (cl .Update (context .Background (), obj )).To (Succeed ())
1840+ Expect (cl .Get (context .Background (), client .ObjectKeyFromObject (obj ), obj )).To (Succeed ())
1841+
1842+ Expect (obj .Object ["spec" ]).To (BeEquivalentTo (map [string ]any {"value" : float64 (99.9 )}))
1843+ })
1844+
18131845 It ("should not change the status of unstructured objects that are configured to have a status subresource on update" , func () {
18141846 obj := & unstructured.Unstructured {}
18151847 obj .SetAPIVersion ("foo/v1" )
0 commit comments