Skip to content

Commit

Permalink
Write a test for when the check fails
Browse files Browse the repository at this point in the history
  • Loading branch information
brettcannon committed May 18, 2024
1 parent 18517d8 commit 6797580
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions tests/Main_test.res
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ zora("checkForChangedFiles()", async t => {
t->ok(r->String.includes(expected), `log message should contain "${expected}"`)
)

let errorContains = (t, given: result<string, 'b>, expected: string) =>
switch given {
| Ok(_) => t->fail("should not return `Some`")
| Error(r) => t->ok(r->String.includes(expected), `log message should contain "${expected}"`)
}

// Default test data should cause a failure, forcing tests to change things
// to having the test pass.
let pull_request: GH.prType = {
Expand Down Expand Up @@ -93,19 +99,21 @@ zora("checkForChangedFiles()", async t => {
)
})

t->skip("a file matches", async t => {
// Fails
t->test("a file matches", async t => {
let filePattern = "Dir3/C"
let inputs = {...inputs, filePattern}

t->okContains(
await payload->Main.checkforChangedFiles(inputs, ~_changedFilesImpl=fakeChangedFiles),
"XXX",
filePattern,
)
})

t->skip("failure", async t => {
// Fails
t->okContains(
t->test("failure", async t => {
let errorMessage = inputs->Main.formatFailureMessage
t->errorContains(
await payload->Main.checkforChangedFiles(inputs, ~_changedFilesImpl=fakeChangedFiles),
"XXX",
errorMessage,
)
})
})

0 comments on commit 6797580

Please sign in to comment.