Skip to content

Commit

Permalink
PR FIXUP - Fix AssertPanic
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewSisley committed Sep 14, 2023
1 parent 81b4c96 commit 959c79e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import (
// },
// }

// testUtils.AssertPanicAndSkipChangeDetection(t, func() { executeTestCase(t, test) })
// testUtils.AssertPanic(t, func() { executeTestCase(t, test) })
// }

func TestQueryOneToManyWithCidAndDocKey(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func TestQueryOneToOneWithCountWithCompoundOrFilterThatIncludesRelation(t *testi
},
}

testUtils.AssertPanicAndSkipChangeDetection(
testUtils.AssertPanic(
t,
func() {
testUtils.ExecuteTestCase(t, test)
Expand Down
19 changes: 13 additions & 6 deletions tests/integration/utils2.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,17 +196,24 @@ func init() {
}
}

// AssertPanicAndSkipChangeDetection asserts that the code of function actually panics,
// AssertPanic asserts that the code inside the specified PanicTestFunc panics.
//
// also ensures the change detection is skipped so no false fails happen.
// This function is not supported by either the change detector, or the http-client.
// Calling this within either of them will result in the test being skipped.
//
// Usage: AssertPanicAndSkipChangeDetection(t, func() { executeTestCase(t, test) })
func AssertPanicAndSkipChangeDetection(t *testing.T, f assert.PanicTestFunc) bool {
// Usage: AssertPanic(t, func() { executeTestCase(t, test) })
func AssertPanic(t *testing.T, f assert.PanicTestFunc) bool {
if IsDetectingDbChanges() {
// The `assert.Panics` call will falsely fail if this test is executed during
// a detect changes test run
t.Skip()
// a detect changes test run.
t.Skip("Assert panic with the change detector is not currently supported.")
}

if httpClient {
// The http-client will return an error instead of panicing at the moment.
t.Skip("Assert panic with the http client is not currently supported.")
}

return assert.Panics(t, f, "expected a panic, but none found.")
}

Expand Down

0 comments on commit 959c79e

Please sign in to comment.