@@ -8074,3 +8074,146 @@ func Test_Sync_Avoid_Overwrite_On_Select_Tag_Mismatch_With_ID(t *testing.T) {
8074
8074
})
8075
8075
}
8076
8076
}
8077
+
8078
+ // test scope:
8079
+ //
8080
+ // - >=2.8.0 <3.0.0
8081
+ func Test_Sync_Plugins_Nested_Foreign_Keys (t * testing.T ) {
8082
+ runWhen (t , "kong" , ">=2.8.0 <3.0.0" )
8083
+ setup (t )
8084
+
8085
+ ctx := context .Background ()
8086
+
8087
+ tests := []struct {
8088
+ name string
8089
+ stateFile string
8090
+ }{
8091
+ {
8092
+ name : "plugins with consumer reference - via name" ,
8093
+ stateFile : "testdata/sync/041-plugins-nested-foreign-keys/1_1/kong-consumers-via-names.yaml" ,
8094
+ },
8095
+ {
8096
+ name : "plugins with consumer reference - via id" ,
8097
+ stateFile : "testdata/sync/041-plugins-nested-foreign-keys/1_1/kong-consumers-via-ids.yaml" ,
8098
+ },
8099
+ {
8100
+ name : "plugins with route reference - via name" ,
8101
+ stateFile : "testdata/sync/041-plugins-nested-foreign-keys/1_1/kong-routes-via-names.yaml" ,
8102
+ },
8103
+ {
8104
+ name : "plugins with route reference - via id" ,
8105
+ stateFile : "testdata/sync/041-plugins-nested-foreign-keys/1_1/kong-routes-via-ids.yaml" ,
8106
+ },
8107
+ {
8108
+ name : "plugins with service reference - via name" ,
8109
+ stateFile : "testdata/sync/041-plugins-nested-foreign-keys/1_1/kong-services-via-ids.yaml" ,
8110
+ },
8111
+ {
8112
+ name : "plugins with service reference - via id" ,
8113
+ stateFile : "testdata/sync/041-plugins-nested-foreign-keys/1_1/kong-services-via-ids.yaml" ,
8114
+ },
8115
+ }
8116
+
8117
+ for _ , tc := range tests {
8118
+ t .Run (tc .name , func (t * testing.T ) {
8119
+ reset (t )
8120
+ err := sync (ctx , tc .stateFile )
8121
+ require .NoError (t , err )
8122
+
8123
+ // re-sync with no error
8124
+ err = sync (ctx , tc .stateFile )
8125
+ require .NoError (t , err )
8126
+ })
8127
+ }
8128
+ }
8129
+
8130
+ // test scope:
8131
+ //
8132
+ // - >=3.0.0
8133
+ // - konnect
8134
+ func Test_Sync_Plugins_Nested_Foreign_Keys_3x (t * testing.T ) {
8135
+ runWhenKongOrKonnect (t , ">=3.0.0" )
8136
+ setup (t )
8137
+
8138
+ ctx := context .Background ()
8139
+
8140
+ tests := []struct {
8141
+ name string
8142
+ stateFile string
8143
+ }{
8144
+ {
8145
+ name : "plugins with consumer reference - via name" ,
8146
+ stateFile : "testdata/sync/041-plugins-nested-foreign-keys/kong3x-consumers-via-names.yaml" ,
8147
+ },
8148
+ {
8149
+ name : "plugins with consumer reference - via id" ,
8150
+ stateFile : "testdata/sync/041-plugins-nested-foreign-keys/kong3x-consumers-via-ids.yaml" ,
8151
+ },
8152
+ {
8153
+ name : "plugins with route reference - via name" ,
8154
+ stateFile : "testdata/sync/041-plugins-nested-foreign-keys/kong3x-routes-via-names.yaml" ,
8155
+ },
8156
+ {
8157
+ name : "plugins with route reference - via id" ,
8158
+ stateFile : "testdata/sync/041-plugins-nested-foreign-keys/kong3x-routes-via-ids.yaml" ,
8159
+ },
8160
+ {
8161
+ name : "plugins with service reference - via name" ,
8162
+ stateFile : "testdata/sync/041-plugins-nested-foreign-keys/kong3x-services-via-ids.yaml" ,
8163
+ },
8164
+ {
8165
+ name : "plugins with service reference - via id" ,
8166
+ stateFile : "testdata/sync/041-plugins-nested-foreign-keys/kong3x-services-via-ids.yaml" ,
8167
+ },
8168
+ }
8169
+
8170
+ for _ , tc := range tests {
8171
+ t .Run (tc .name , func (t * testing.T ) {
8172
+ reset (t )
8173
+ err := sync (ctx , tc .stateFile )
8174
+ require .NoError (t , err )
8175
+
8176
+ // re-sync with no error
8177
+ err = sync (ctx , tc .stateFile )
8178
+ require .NoError (t , err )
8179
+ })
8180
+ }
8181
+ }
8182
+
8183
+ // test scope:
8184
+ //
8185
+ // - >=3.0.0+enterprise
8186
+ // - konnect
8187
+ func Test_Sync_Plugins_Nested_Foreign_Keys_EE_3x (t * testing.T ) {
8188
+ // prior versions don't support a consumer_group foreign key with a value
8189
+ runWhenEnterpriseOrKonnect (t , ">=3.6.0" )
8190
+ setup (t )
8191
+
8192
+ ctx := context .Background ()
8193
+
8194
+ tests := []struct {
8195
+ name string
8196
+ stateFile string
8197
+ }{
8198
+ {
8199
+ name : "plugins with consumer-group reference - via name" ,
8200
+ stateFile : "testdata/sync/041-plugins-nested-foreign-keys/kong3x-consumer-groups-via-names.yaml" ,
8201
+ },
8202
+ {
8203
+ name : "plugins with consumer-group reference - via id" ,
8204
+ stateFile : "testdata/sync/041-plugins-nested-foreign-keys/kong3x-consumer-groups-via-ids.yaml" ,
8205
+ },
8206
+ }
8207
+
8208
+ for _ , tc := range tests {
8209
+ t .Run (tc .name , func (t * testing.T ) {
8210
+ reset (t )
8211
+ err := sync (ctx , tc .stateFile )
8212
+ require .NoError (t , err )
8213
+
8214
+ // re-sync with no error
8215
+ err = sync (ctx , tc .stateFile )
8216
+ require .NoError (t , err )
8217
+ })
8218
+ }
8219
+ }
0 commit comments