};
- 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) => {
});
});
- 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) => {
});
});
- 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 })
});
});
- 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) => {
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')