Skip to content

Commit b328512

Browse files
tests: add tests for custom entity partial apply (#1625)
* tests: add tests for custom entity partial apply * tests: combine enterprise and konnect test case * chore: bump go-database-reconciler
1 parent f7eae2c commit b328512

File tree

5 files changed

+70
-3
lines changed

5 files changed

+70
-3
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ require (
1313
github.com/fatih/color v1.18.0
1414
github.com/google/go-cmp v0.7.0
1515
github.com/kong/go-apiops v0.1.42
16-
github.com/kong/go-database-reconciler v1.22.6
16+
github.com/kong/go-database-reconciler v1.22.7
1717
github.com/kong/go-kong v0.65.1
1818
github.com/mitchellh/go-homedir v1.1.0
1919
github.com/spf13/cobra v1.8.1

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/q
246246
github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
247247
github.com/kong/go-apiops v0.1.42 h1:GF9KV1D06p/Ux2F5Dc4UJzGKFOeMzynpUWiAZwyEqxE=
248248
github.com/kong/go-apiops v0.1.42/go.mod h1:hKnHJ3UyeuG932SkI/yMpuT/PqSqGXNTS1zhno1lDqg=
249-
github.com/kong/go-database-reconciler v1.22.6 h1:G8rjG7057aVHem4q6tyyzEyJo3hH2weL0U9JAZk4H/0=
250-
github.com/kong/go-database-reconciler v1.22.6/go.mod h1:hLtPRsuxqTYv1rt6h/YrimjDQzkxlAFSIWoG1jEjWKE=
249+
github.com/kong/go-database-reconciler v1.22.7 h1:7sjQBpGvL46pHpEdjLRUX9+D7fjk2lUsPgBTob6UguM=
250+
github.com/kong/go-database-reconciler v1.22.7/go.mod h1:hLtPRsuxqTYv1rt6h/YrimjDQzkxlAFSIWoG1jEjWKE=
251251
github.com/kong/go-kong v0.65.1 h1:CM+8NlF+VbJckTxP2hGmSPKhA1GMliitXjQ7vJiPkaE=
252252
github.com/kong/go-kong v0.65.1/go.mod h1:sqdysTKrXIJ6mpxHwTwjgZhLW7jR1/puczTXHLUwJaE=
253253
github.com/kong/go-slugify v1.0.0 h1:vCFAyf2sdoSlBtLcrmDWUFn0ohlpKiKvQfXZkO5vSKY=

tests/integration/apply_test.go

+34
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,37 @@ func Test_Apply_3x(t *testing.T) {
107107
assert.Equal(t, expectedChanged, outChanged)
108108
})
109109
}
110+
111+
// test scope:
112+
// - enterprise: >=3.0.0
113+
// - konnect
114+
func Test_Apply_Custom_Entities(t *testing.T) {
115+
runWhenEnterpriseOrKonnect(t, ">=3.0.0")
116+
setup(t)
117+
118+
ctx := context.Background()
119+
tests := []struct {
120+
name string
121+
initialStateFile string
122+
targetPartialStateFile string
123+
}{
124+
{
125+
name: "degraphql routes",
126+
initialStateFile: "testdata/apply/008-custom-entities/initial-state.yaml",
127+
targetPartialStateFile: "testdata/apply/008-custom-entities/partial-update.yaml",
128+
},
129+
}
130+
131+
for _, tc := range tests {
132+
t.Run(tc.name, func(t *testing.T) {
133+
t.Cleanup(func() {
134+
reset(t)
135+
})
136+
err := sync(ctx, tc.initialStateFile)
137+
require.NoError(t, err)
138+
139+
err = apply(ctx, tc.targetPartialStateFile)
140+
require.NoError(t, err)
141+
})
142+
}
143+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
_format_version: "3.0"
2+
services:
3+
- connect_timeout: 60000
4+
enabled: true
5+
host: example.com
6+
name: example
7+
plugins:
8+
- config:
9+
graphql_server_path: /graphql
10+
enabled: true
11+
name: degraphql
12+
protocols:
13+
- grpc
14+
- grpcs
15+
- http
16+
- https
17+
port: 443
18+
protocol: https
19+
read_timeout: 60000
20+
retries: 5
21+
write_timeout: 60000
22+
tags:
23+
- foo'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
_format_version: "3.0"
2+
custom_entities:
3+
- fields:
4+
methods:
5+
- GET
6+
query: query { viewer { login } }
7+
service:
8+
name: example
9+
uri: /me
10+
type: degraphql_routes

0 commit comments

Comments
 (0)