invoices: replace defer cleanup with t.Cleanup

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
Eng Zer Jun committed 2022-10-13 17:47:03 +08:00
1 parent 8d50d54ade
commit 945180f0ea
2 files changed
+7 -24

No files matched your search

+4 -7
View File
@@ -183,8 +183,7 @@ type testContext struct {
notifier *mockChainNotifier
clock *clock.TestClock
cleanup func()
t *testing.T
t *testing.T
}
func newTestContext(t *testing.T) *testContext {
@@ -213,6 +212,9 @@ func newTestContext(t *testing.T) *testContext {
if err != nil {
t.Fatal(err)
}
t.Cleanup(func() {
require.NoError(t, registry.Stop())
})
ctx := testContext{
cdb: cdb,
@@ -220,11 +222,6 @@ func newTestContext(t *testing.T) *testContext {
notifier: notifier,
clock: clock,
t: t,
cleanup: func() {
if err = registry.Stop(); err != nil {
t.Fatalf("failed to stop invoice registry: %v", err)
}
},
}
return &ctx