From: Kai Moritz Date: Sat, 11 Oct 2025 20:38:33 +0000 (+0200) Subject: feat: Shared the refinements with the provider X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=6fb4ffb90445b7363ca6e8c1d0de1fb8e7b26454;p=demos%2Fkafka%2Fchat feat: Shared the refinements with the provider --- diff --git a/pacts b/pacts index aebebad7..b2bf161f 160000 --- a/pacts +++ b/pacts @@ -1 +1 @@ -Subproject commit aebebad7afa79a6854a25a45cc2b940224f0dad9 +Subproject commit b2bf161fa71acd4128b040ebb81af65fc1509cac diff --git a/src/app/chatroom/chatroom.service.pact.spec.ts b/src/app/chatroom/chatroom.service.pact.spec.ts index c87be942..3eab0f08 100644 --- a/src/app/chatroom/chatroom.service.pact.spec.ts +++ b/src/app/chatroom/chatroom.service.pact.spec.ts @@ -25,12 +25,13 @@ describe('Pact between the ChatroomService and the backend', () => { }; - it('a request for /list returns an HTTP 200 and a list of chatrooms, if some chatrooms are known', async () => { + it('GET /list -- chatrooms available', async () => { await provider .addInteraction() .given('there are 10 shards') - .given('chatroom with ID "5c73531c-6fc4-426c-adcb-afc5c140a0f7" exists in shard "2"') + .given('the server is responsible for shard 2') + .given('chatroom 5c73531c-6fc4-426c-adcb-afc5c140a0f7 exists in shard 2') .uponReceiving('a request for /list') .withRequest('GET', '/list') .willRespondWith(200, (builder) => { @@ -53,12 +54,13 @@ describe('Pact between the ChatroomService and the backend', () => { }); }); - it('a request for /list returns an HTTP 200 and an empty list, if no chatrooms are known', async () => { + it('GET /list -- no chatrooms available', async () => { await provider .addInteraction() .given('there are 10 shards') - .given('there is no chatroom at all') + .given('the server is responsible for shard 2') + .given('there are no chatrooms available at all in shard 2') .uponReceiving('a request for /list') .withRequest('GET', '/list') .willRespondWith(200, (builder) => { @@ -81,12 +83,13 @@ describe('Pact between the ChatroomService and the backend', () => { }); }); - it('a request for "/5c73531c-6fc4-426c-adcb-afc5c140a0f7" with header "X-Shard: 2" returns an HTTP 200 and the chatroom, if the chatroom with id "5c73531c-6fc4-426c-adcb-afc5c140a0f7" exists in shard 2', async () => { + it('GET /{CHATROOM-ID} -- existing chatroom, responsible shard', async () => { await provider .addInteraction() .given('there are 10 shards') - .given('chatroom with ID "5c73531c-6fc4-426c-adcb-afc5c140a0f7" exists in shard "2"') + .given('the server is responsible for shard 2') + .given('chatroom 5c73531c-6fc4-426c-adcb-afc5c140a0f7 exists in shard 2') .uponReceiving('a request for /5c73531c-6fc4-426c-adcb-afc5c140a0f7') .withRequest('GET', '/5c73531c-6fc4-426c-adcb-afc5c140a0f7', (builder) => { builder.headers({ 'X-Shard': 2 }) @@ -111,15 +114,16 @@ describe('Pact between the ChatroomService and the backend', () => { }); }); - it('a request for /5c73531c-6fc4-426c-adcb-afc5c140a0f7 with header "X-Shard: 6" returns HTTP 404, if the chatroom with id "5c73531c-6fc4-426c-adcb-afc5c140a0f7" exists in shard 2', async () => { + it('GET /{CHATROOM-ID} -- shard not responsible', async () => { await provider .addInteraction() .given('there are 10 shards') - .given('chatroom with ID "5c73531c-6fc4-426c-adcb-afc5c140a0f7" exists in shard "2"') - .uponReceiving('a request for /5c73531c-6fc4-426c-adcb-afc5c140a0f7') - .withRequest('GET', '/5c73531c-6fc4-426c-adcb-afc5c140a0f7', (builder) => { - builder.headers({ 'X-Shard': 6 }) + .given('the server is responsible for shard 2') + .given('chatroom 7f59ec77-832e-4a17-8d22-55ef46242c17 does not exists in shard 2') + .uponReceiving('a request for /7f59ec77-832e-4a17-8d22-55ef46242c17') + .withRequest('GET', '/7f59ec77-832e-4a17-8d22-55ef46242c17', (builder) => { + builder.headers({ 'X-Shard': 2 }) }) .willRespondWith(404) .executeTest(async (mockserver) => { @@ -136,7 +140,7 @@ describe('Pact between the ChatroomService and the backend', () => { return new Promise((resolve, reject) => { service - .getChatroom("6", "5c73531c-6fc4-426c-adcb-afc5c140a0f7") + .getChatroom("2", "7f59ec77-832e-4a17-8d22-55ef46242c17") .subscribe({ next: (chatrooms) => { reject('a status other than 200 should have rejected the observable')