Skip to content

Commit

Permalink
test: e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
bzp2010 committed Dec 26, 2024
1 parent 3e467c7 commit 367cc10
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions libs/backend-api7/e2e/resources/route.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,53 @@ describe('Route E2E', () => {
expect(result.services).toHaveLength(0);
});
});

describe('Vars', () => {
const serviceName = 'test';
const service = {
name: serviceName,
upstream: {
scheme: 'https',
nodes: [
{
host: 'httpbin.org',
port: 443,
weight: 100,
},
],
},
path_prefix: '/test',
strip_path_prefix: true,
} as ADCSDK.Service;
const route1Name = 'route1';
const route1 = {
name: route1Name,
uris: ['/route1'],
vars: [['remote_addr', '==', '1.1.1.1']],
} as ADCSDK.Route;

it('Create resources', async () =>
syncEvents(backend, [
createEvent(ADCSDK.ResourceType.SERVICE, serviceName, service),
createEvent(ADCSDK.ResourceType.ROUTE, route1Name, route1, serviceName),
]));

it('Dump', async () => {
const result = (await dumpConfiguration(backend)) as ADCSDK.Configuration;
expect(result.services).toHaveLength(1);
expect(result.services[0]).toMatchObject(service);
expect(result.services[0].routes).toHaveLength(1);
expect(result.services[0].routes[0]).toMatchObject(route1);
});

it('Delete', async () =>
syncEvents(backend, [
deleteEvent(ADCSDK.ResourceType.SERVICE, serviceName),
]));

it('Dump again (service should not exist)', async () => {
const result = (await dumpConfiguration(backend)) as ADCSDK.Configuration;
expect(result.services).toHaveLength(0);
});
});
});

0 comments on commit 367cc10

Please sign in to comment.