From 3e541da489fa091ef31295c27258b8af42b30e4a Mon Sep 17 00:00:00 2001 From: Rahmat Hidayat Date: Mon, 9 Oct 2023 14:53:55 +0700 Subject: [PATCH] test(grant): cleanup grants table after each test in grant repository test --- internal/store/postgres/grant_repository_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/internal/store/postgres/grant_repository_test.go b/internal/store/postgres/grant_repository_test.go index b0709374a..6fb5a1c7e 100644 --- a/internal/store/postgres/grant_repository_test.go +++ b/internal/store/postgres/grant_repository_test.go @@ -103,6 +103,17 @@ func (s *GrantRepositoryTestSuite) SetupSuite() { s.Require().NoError(err) } +func (s *GrantRepositoryTestSuite) AfterTest(suiteName, testName string) { + // clean grants table + db, err := s.store.DB().DB() + if err != nil { + s.T().Fatal(err) + } + if _, err := db.Exec("DELETE FROM grants"); err != nil { + s.T().Fatal(err) + } +} + func (s *GrantRepositoryTestSuite) TearDownSuite() { // Clean tests db, err := s.store.DB().DB()