From 3bf0f63ea0fcf44b3ef6feb8d519b10181a7ca4c Mon Sep 17 00:00:00 2001 From: Andrew Sisley Date: Mon, 11 Sep 2023 15:15:06 -0400 Subject: [PATCH] PR FIXUP - Fix AssertPanic --- .../query/one_to_many/with_cid_dockey_test.go | 2 +- .../one_to_one/with_count_filter_test.go | 2 +- tests/integration/utils2.go | 19 +++++++++++++------ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/tests/integration/query/one_to_many/with_cid_dockey_test.go b/tests/integration/query/one_to_many/with_cid_dockey_test.go index b792db5492..aa8dd1906e 100644 --- a/tests/integration/query/one_to_many/with_cid_dockey_test.go +++ b/tests/integration/query/one_to_many/with_cid_dockey_test.go @@ -60,7 +60,7 @@ import ( // }, // } -// testUtils.AssertPanicAndSkipChangeDetection(t, func() { executeTestCase(t, test) }) +// testUtils.AssertPanic(t, func() { executeTestCase(t, test) }) // } func TestQueryOneToManyWithCidAndDocKey(t *testing.T) { diff --git a/tests/integration/query/one_to_one/with_count_filter_test.go b/tests/integration/query/one_to_one/with_count_filter_test.go index f73e9cf0f8..c005acac01 100644 --- a/tests/integration/query/one_to_one/with_count_filter_test.go +++ b/tests/integration/query/one_to_one/with_count_filter_test.go @@ -110,7 +110,7 @@ func TestQueryOneToOneWithCountWithCompoundOrFilterThatIncludesRelation(t *testi }, } - testUtils.AssertPanicAndSkipChangeDetection( + testUtils.AssertPanic( t, func() { testUtils.ExecuteTestCase(t, test) diff --git a/tests/integration/utils2.go b/tests/integration/utils2.go index ab2bea2898..622478f513 100644 --- a/tests/integration/utils2.go +++ b/tests/integration/utils2.go @@ -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.") }