]> juplo.de Git - demos/kafka/chat/commitdiff
feat: Shared the refinements with the provider
authorKai Moritz <kai@juplo.de>
Sat, 11 Oct 2025 18:34:53 +0000 (20:34 +0200)
committerKai Moritz <kai@juplo.de>
Sat, 11 Oct 2025 19:17:00 +0000 (21:17 +0200)
pacts
src/app/chatroom/chatroom.service.pact.spec.ts

diff --git a/pacts b/pacts
index 3f62f442fa6cdf81d3a49e55a481fc3374ed852c..9d3b95c268e7db8710f9b6bd5bd2690bac65a9ab 160000 (submodule)
--- a/pacts
+++ b/pacts
@@ -1 +1 @@
-Subproject commit 3f62f442fa6cdf81d3a49e55a481fc3374ed852c
+Subproject commit 9d3b95c268e7db8710f9b6bd5bd2690bac65a9ab
index d1080ecee64aa5cd33e1828ba6b19569426cf1d8..5ab6a71c0a7d5da6532bfc3a4608007220951c94 100644 (file)
@@ -19,9 +19,9 @@ describe('Pact between the ChatroomService and the backend', () => {
 
 
   const EXAMPLE_CHATROOM: Chatroom = {
-    id: "1",
-    name: "foo",
-    shard: 7
+    id: "5c73531c-6fc4-426c-adcb-afc5c140a0f7",
+    name: "FOO",
+    shard: 2
   };
 
 
@@ -29,7 +29,8 @@ describe('Pact between the ChatroomService and the backend', () => {
 
     await provider
       .addInteraction()
-      .given('some chatrooms are known')
+      .given('there are 10 shards')
+      .given('chatroom with ID "5c73531c-6fc4-426c-adcb-afc5c140a0f7" exists in shard "2"')
       .uponReceiving('a request for /list')
       .withRequest('GET', '/list')
       .willRespondWith(200, (builder) => {
@@ -56,7 +57,8 @@ describe('Pact between the ChatroomService and the backend', () => {
 
     await provider
       .addInteraction()
-      .given('no chatrooms are known')
+      .given('there are 10 shards')
+      .given('there is no chatroom at all')
       .uponReceiving('a request for /list')
       .withRequest('GET', '/list')
       .willRespondWith(200, (builder) => {
@@ -79,14 +81,15 @@ describe('Pact between the ChatroomService and the backend', () => {
       });
   });
 
-  it('a request for /1 with header "X-Shard: 7" returns an HTTP 200 and the chatroom, if the chatroom with id "1" exists in shard 7', async () => {
+  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 () => {
 
     await provider
       .addInteraction()
-      .given('chatroom with ID "1" exists in shard "7"')
-      .uponReceiving('a request for /1')
-      .withRequest('GET', '/1', (builder) => {
-        builder.headers({ 'X-Shard': 7 })
+      .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': 2 })
       })
       .willRespondWith(200, (builder) => {
         builder.headers({ 'Content-Type': 'application/json' });
@@ -102,19 +105,20 @@ describe('Pact between the ChatroomService and the backend', () => {
         });
 
         const service = TestBed.inject(ChatroomService);
-        const chatroom = await lastValueFrom(service.getChatroom("7", "1"));
+        const chatroom = await lastValueFrom(service.getChatroom("2", "5c73531c-6fc4-426c-adcb-afc5c140a0f7"));
 
         expect(chatroom).toEqual(EXAMPLE_CHATROOM);
       });
   });
 
-  it('a request for /1 with header "X-Shard: 6" returns HTTP 404, if the chatroom with id "1" exists in shard 7', async () => {
+  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 () => {
 
     await provider
       .addInteraction()
-      .given('chatroom with ID "1" exists in shard "7"')
-      .uponReceiving('a request for /1')
-      .withRequest('GET', '/1', (builder) => {
+      .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 })
       })
       .willRespondWith(404)
@@ -132,7 +136,7 @@ describe('Pact between the ChatroomService and the backend', () => {
         return new Promise<void>((resolve, reject) => {
 
           service
-            .getChatroom("6", "1")
+            .getChatroom("6", "5c73531c-6fc4-426c-adcb-afc5c140a0f7")
             .subscribe({
               next: (chatrooms) => {
                 reject('a status other than 200 should have rejected the observable')