const EXAMPLE_CHATROOM: Chatroom = {
- id: "1",
- name: "foo",
- shard: 7
+ id: "5c73531c-6fc4-426c-adcb-afc5c140a0f7",
+ name: "FOO",
+ shard: 2
};
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) => {
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) => {
});
});
- 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' });
});
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)
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')