From c2fb3152b9bc0b760bd2a1d2e39c5187a9196ceb Mon Sep 17 00:00:00 2001 From: CorrectRoadH Date: Mon, 5 Aug 2024 08:51:54 +0000 Subject: [PATCH] wip --- service/ysk_test.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/service/ysk_test.go b/service/ysk_test.go index fdb1ea3..55b1eb6 100644 --- a/service/ysk_test.go +++ b/service/ysk_test.go @@ -11,16 +11,19 @@ import ( "gotest.tools/assert" ) -func setup(t *testing.T) *service.YSKService { +func setup(t *testing.T) (*service.YSKService, func()) { repository, err := repository.NewDatabaseRepositoryInMemory() assert.NilError(t, err) yskService := service.NewYSKService(&repository) - return yskService + return yskService, func() { + repository.Close() + } } func TestInsertAndGetCardList(t *testing.T) { - yskService := setup(t) + yskService, cleanup := setup(t) + defer cleanup() cardList, err := yskService.YskCardList(context.Background()) assert.NilError(t, err) @@ -51,7 +54,8 @@ func TestInsertAndGetCardList(t *testing.T) { } func TestInsertAllTypeCardList(t *testing.T) { - yskService := setup(t) + yskService, cleanup := setup(t) + defer cleanup() cardList, err := yskService.YskCardList(context.Background()) assert.NilError(t, err)