diff options
author | Nanguan Lin <70063547+lng2020@users.noreply.github.com> | 2023-10-11 13:02:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-11 13:02:24 +0200 |
commit | dc04044716088e3786497e200abe1fdfb3a943b6 (patch) | |
tree | 45230f2067cbf0f130042e33eed36a38ed69e9b1 /modules/indexer/code | |
parent | Fix the robots.txt path (diff) | |
download | forgejo-dc04044716088e3786497e200abe1fdfb3a943b6.tar.xz forgejo-dc04044716088e3786497e200abe1fdfb3a943b6.zip |
Replace assert.Fail with assert.FailNow (#27578)
assert.Fail() will continue to execute the code while assert.FailNow()
not. I thought those uses of assert.Fail() should exit immediately.
PS: perhaps it's a good idea to use
[require](https://pkg.go.dev/github.com/stretchr/testify/require)
somewhere because the assert package's default behavior does not exit
when an error occurs, which makes it difficult to find the root error
reason.
Diffstat (limited to 'modules/indexer/code')
-rw-r--r-- | modules/indexer/code/indexer_test.go | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/modules/indexer/code/indexer_test.go b/modules/indexer/code/indexer_test.go index 5b2a97d3d5..5eb8e61e3d 100644 --- a/modules/indexer/code/indexer_test.go +++ b/modules/indexer/code/indexer_test.go @@ -96,11 +96,10 @@ func TestBleveIndexAndSearch(t *testing.T) { idx := bleve.NewIndexer(dir) _, err := idx.Init(context.Background()) if err != nil { - assert.Fail(t, "Unable to create bleve indexer Error: %v", err) if idx != nil { idx.Close() } - return + assert.FailNow(t, "Unable to create bleve indexer Error: %v", err) } defer idx.Close() @@ -118,11 +117,10 @@ func TestESIndexAndSearch(t *testing.T) { indexer := elasticsearch.NewIndexer(u, "gitea_codes") if _, err := indexer.Init(context.Background()); err != nil { - assert.Fail(t, "Unable to init ES indexer Error: %v", err) if indexer != nil { indexer.Close() } - return + assert.FailNow(t, "Unable to init ES indexer Error: %v", err) } defer indexer.Close() |