]> juplo.de Git - demos/kafka/chat/commitdiff
feat: Shared the refinements with the provider
authorKai Moritz <kai@juplo.de>
Sat, 11 Oct 2025 20:38:33 +0000 (22:38 +0200)
committerKai Moritz <kai@juplo.de>
Sat, 11 Oct 2025 20:51:24 +0000 (22:51 +0200)
pacts
src/app/chatroom/chatroom.service.pact.spec.ts

diff --git a/pacts b/pacts
index aebebad7afa79a6854a25a45cc2b940224f0dad9..b2bf161fa71acd4128b040ebb81af65fc1509cac 160000 (submodule)
--- a/pacts
+++ b/pacts
@@ -1 +1 @@
-Subproject commit aebebad7afa79a6854a25a45cc2b940224f0dad9
+Subproject commit b2bf161fa71acd4128b040ebb81af65fc1509cac
index c87be9425fd68f68df50130680ceda869583a250..3eab0f0808d2d0a6188afa977bb7daed20c42863 100644 (file)
@@ -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<void>((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')