1
+ import { Differ } from '@api7/adc-differ' ;
1
2
import * as ADCSDK from '@api7/adc-sdk' ;
2
3
3
4
import { BackendAPISIX } from '../../src' ;
@@ -39,9 +40,7 @@ describe('Service-Upstreams E2E', () => {
39
40
} satisfies ADCSDK . Service ;
40
41
41
42
it ( 'Create service with inline upstream' , async ( ) =>
42
- syncEvents ( backend , [
43
- createEvent ( ADCSDK . ResourceType . SERVICE , serviceName , service ) ,
44
- ] ) ) ;
43
+ syncEvents ( backend , Differ . diff ( { services : [ service ] } , { } ) ) ) ;
45
44
46
45
it ( 'Dump (inline upstream should exist)' , async ( ) => {
47
46
const result = await dumpConfiguration ( backend ) ;
@@ -81,9 +80,10 @@ describe('Service-Upstreams E2E', () => {
81
80
} ,
82
81
} satisfies ADCSDK . Service ;
83
82
it ( 'Update service inline upstream' , async ( ) =>
84
- syncEvents ( backend , [
85
- updateEvent ( ADCSDK . ResourceType . SERVICE , serviceName , updatedService ) ,
86
- ] ) ) ;
83
+ syncEvents (
84
+ backend ,
85
+ Differ . diff ( { services : [ updatedService ] } , await dumpConfiguration ( backend ) ) ,
86
+ ) ) ;
87
87
88
88
it ( 'Dump (inline upstream should be updated)' , async ( ) => {
89
89
const result = await dumpConfiguration ( backend ) ;
@@ -101,15 +101,13 @@ describe('Service-Upstreams E2E', () => {
101
101
hosts : [ 'test.example.com' ] ,
102
102
} satisfies ADCSDK . Service ;
103
103
it ( 'Update service to remove inline upstream' , async ( ) =>
104
- syncEvents ( backend , [
105
- updateEvent (
106
- ADCSDK . ResourceType . SERVICE ,
107
- serviceName ,
108
- serviceWithoutUpstream ,
109
- undefined ,
110
- updatedService , // oldValue with upstream
104
+ syncEvents (
105
+ backend ,
106
+ Differ . diff (
107
+ { services : [ serviceWithoutUpstream ] } ,
108
+ await dumpConfiguration ( backend ) ,
111
109
) ,
112
- ] ) ) ;
110
+ ) ) ;
113
111
114
112
it ( 'Dump (inline upstream should be removed)' , async ( ) => {
115
113
const result = await dumpConfiguration ( backend ) ;
@@ -134,13 +132,13 @@ describe('Service-Upstreams E2E', () => {
134
132
} ,
135
133
} satisfies ADCSDK . Service ;
136
134
it ( 'Re-add inline upstream for deletion test' , async ( ) =>
137
- syncEvents ( backend , [
138
- updateEvent (
139
- ADCSDK . ResourceType . SERVICE ,
140
- serviceName ,
141
- serviceForDeletion ,
135
+ syncEvents (
136
+ backend ,
137
+ Differ . diff (
138
+ { services : [ serviceForDeletion ] } ,
139
+ await dumpConfiguration ( backend ) ,
142
140
) ,
143
- ] ) ) ;
141
+ ) ) ;
144
142
145
143
it ( 'Dump (inline upstream should exist again)' , async ( ) => {
146
144
const result = await dumpConfiguration ( backend ) ;
@@ -150,14 +148,7 @@ describe('Service-Upstreams E2E', () => {
150
148
} ) ;
151
149
152
150
it ( 'Delete service with inline upstream' , async ( ) =>
153
- syncEvents ( backend , [
154
- deleteEvent (
155
- ADCSDK . ResourceType . SERVICE ,
156
- serviceName ,
157
- undefined ,
158
- serviceForDeletion , // oldValue with upstream
159
- ) ,
160
- ] ) ) ;
151
+ syncEvents ( backend , Differ . diff ( { } , await dumpConfiguration ( backend ) ) ) ) ;
161
152
162
153
it ( 'Dump again (service should not exist)' , async ( ) => {
163
154
const result = await dumpConfiguration ( backend ) ;
0 commit comments