@@ -1796,6 +1796,56 @@ func TestClusterPatch(t *testing.T) {
17961796 g .Expect (result .Generation ).To (Equal (int32 (2 )))
17971797 })
17981798
1799+ t .Run ("spec unchanged with different key order keeps generation" , func (t * testing.T ) {
1800+ t .Parallel ()
1801+ g := NewWithT (t )
1802+ clusterDao := newMockClusterDao ()
1803+ nodePoolDao := newMockNodePoolDao ()
1804+ adapterStatusDao := newMockAdapterStatusDao ()
1805+ adapterConfig := testAdapterConfig ()
1806+ adapterConfig .Required .Cluster = []string {}
1807+ service := NewClusterService (clusterDao , nodePoolDao , newMockNodePoolService (), adapterStatusDao , adapterConfig )
1808+ ctx := context .Background ()
1809+
1810+ clusterDao .clusters ["c1" ] = & api.Cluster {
1811+ Meta : api.Meta {ID : "c1" },
1812+ Spec : []byte (`{"z":"last","a":"first","m":"middle"}` ),
1813+ Labels : []byte (`{}` ),
1814+ Generation : 5 ,
1815+ }
1816+
1817+ sameSpec := map [string ]interface {}{"z" : "last" , "a" : "first" , "m" : "middle" }
1818+ result , svcErr := service .Patch (ctx , "c1" , & api.ClusterPatchRequest {Spec : & sameSpec })
1819+
1820+ g .Expect (svcErr ).To (BeNil ())
1821+ g .Expect (result .Generation ).To (Equal (int32 (5 )))
1822+ })
1823+
1824+ t .Run ("labels unchanged with different key order keeps generation" , func (t * testing.T ) {
1825+ t .Parallel ()
1826+ g := NewWithT (t )
1827+ clusterDao := newMockClusterDao ()
1828+ nodePoolDao := newMockNodePoolDao ()
1829+ adapterStatusDao := newMockAdapterStatusDao ()
1830+ adapterConfig := testAdapterConfig ()
1831+ adapterConfig .Required .Cluster = []string {}
1832+ service := NewClusterService (clusterDao , nodePoolDao , newMockNodePoolService (), adapterStatusDao , adapterConfig )
1833+ ctx := context .Background ()
1834+
1835+ clusterDao .clusters ["c1" ] = & api.Cluster {
1836+ Meta : api.Meta {ID : "c1" },
1837+ Spec : []byte (`{}` ),
1838+ Labels : []byte (`{"z":"zulu","a":"alpha"}` ),
1839+ Generation : 4 ,
1840+ }
1841+
1842+ sameLabels := map [string ]string {"z" : "zulu" , "a" : "alpha" }
1843+ result , svcErr := service .Patch (ctx , "c1" , & api.ClusterPatchRequest {Labels : & sameLabels })
1844+
1845+ g .Expect (svcErr ).To (BeNil ())
1846+ g .Expect (result .Generation ).To (Equal (int32 (4 )))
1847+ })
1848+
17991849 t .Run ("not found returns 404" , func (t * testing.T ) {
18001850 t .Parallel ()
18011851 g := NewWithT (t )
0 commit comments