Skip to content

Commit

Permalink
Add a scenario about handling concurrent fetches
Browse files Browse the repository at this point in the history
Relates-to #211

It's debatable whether this deserves to be surfaced in an acceptance
test, but I'm not sure yet which layer is the right place to solve this,
so it makes sense to put it in our full-stack tests in any case. And
it's probably useful to document this capabilty.
  • Loading branch information
mattwynne committed Mar 4, 2021
1 parent aa9aed0 commit 25d0e7f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
9 changes: 8 additions & 1 deletion doc/features/fetch_after_connection.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Feature: Fetch after connection
Feature: Fetch automatically after connection

After a repo is connected, we automatically run a fetch in the
background.
Expand All @@ -7,3 +7,10 @@ Feature: Fetch after connection
Given a remote repo with commits on the "main" branch
When a consumer connects the remote repo
Then the repo should have been fetched

@wip
Scenario: Succesful manual fetch concurrent with automatic background fetch
Given a remote repo with commits on the "main" branch
When a consumer connects the remote repo
And a consumer triggers a manual fetch of the repo
Then the repo should have been fetched 2 times
13 changes: 13 additions & 0 deletions packages/acceptance-tests/src/step_definitions/steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,19 @@ Then('the events received by the consumer should be:', function (this: World, ex
assertThat(this.events, equalTo(expectedEvents.split('\n')))
})

Then('the repo should have been fetched {int} times', async function (this: World, expectedTimes: number) {
for (const _ of new Array(expectedTimes))
await promiseThat(
new Promise<void>((received) =>
this.domainEvents.on('repo.fetched', (event) => event.repoId.equals(this.repoId) && received())
),
fulfilled()
)
})

Then('the events received by the consumer should be:', function (this: World, expectedEvents: string) {
assertThat(this.events, equalTo(expectedEvents.split('\n')))
})
Then('it should respond with {int} status', function (this: World, expectedStatus: number) {
assertThat(this.lastResponse.status, equalTo(expectedStatus))
})
Expand Down

0 comments on commit 25d0e7f

Please sign in to comment.