Skip to content

Commit

Permalink
test(rulesets): define scenario for ruleset removal
Browse files Browse the repository at this point in the history
for #732
  • Loading branch information
travi committed Sep 15, 2024
1 parent e8221c3 commit 8e7cbbc
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/integration/features/rulesets.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,10 @@ Feature: Repository Rulesets
And the ruleset is modified in the config
When a settings sync is triggered
Then the ruleset is updated

@wip
Scenario: Delete a ruleset
Given a ruleset exists for the repository
And the ruleset is removed from the config
When a settings sync is triggered
Then the ruleset is deleted
23 changes: 23 additions & 0 deletions test/integration/features/step_definitions/rulesets-steps.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,33 @@ Given('the ruleset is modified in the config', async function () {
)
})

Given('the ruleset is removed from the config', async function () {
this.server.use(
http.get(
`https://api.github.com/repos/${repository.owner.name}/${repository.name}/contents/${encodeURIComponent(
settings.FILE_NAME
)}`,
({ request }) => HttpResponse.arrayBuffer(Buffer.from(dump({ rulesets: [] })))
),
http.delete(
`https://api.github.com/repos/${repository.owner.name}/${repository.name}/rulesets/:rulesetId`,
async ({ params }) => {
this.removedRuleset = params.rulesetId

return new HttpResponse(null, { status: StatusCodes.NO_CONTENT })
}
)
)
})

Then('the ruleset is enabled for the repository', async function () {
assert.deepEqual(this.createdRuleset, this.ruleset)
})

Then('the ruleset is updated', async function () {
assert.deepEqual(this.updatedRuleset, this.ruleset)
})

Then('the ruleset is deleted', async function () {
assert.equal(this.removedRuleset, rulesetId)
})

0 comments on commit 8e7cbbc

Please sign in to comment.