Skip to content

Commit dde4c49

Browse files
committed
feat: rm temp data
1 parent 174e1bc commit dde4c49

21 files changed

+73
-67
lines changed

integrationtest/helper_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func TestDoubleInit(t *testing.T) { //nolint
5757
type Closer func()
5858

5959
func SetupDaemon(t *testing.T, ctx context.Context) (string, Closer) { //nolint
60-
pg, connectString, _ := testhelper.SetupDatabase(ctx, t)
60+
closeDB, connectString, _ := testhelper.SetupDatabase(ctx, t)
6161

6262
port, err := freeport.GetFreePort()
6363
require.NoError(t, err)
@@ -70,7 +70,8 @@ func SetupDaemon(t *testing.T, ctx context.Context) (string, Closer) { //nolint
7070

7171
closer := func() {
7272
cancel()
73-
require.NoError(t, pg.Stop())
73+
require.NoError(t, os.RemoveAll(tmpDir))
74+
closeDB()
7475
}
7576
go func() {
7677
err := Daemon(ctx, buf, tmpDir, url)

models/branch_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import (
1515

1616
func TestRefRepoInsert(t *testing.T) {
1717
ctx := context.Background()
18-
postgres, _, db := testhelper.SetupDatabase(ctx, t)
19-
defer postgres.Stop() //nolint
18+
closeDB, _, db := testhelper.SetupDatabase(ctx, t)
19+
defer closeDB()
2020

2121
repo := models.NewBranchRepo(db)
2222

models/commit_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import (
1414

1515
func TestCommitRepo(t *testing.T) {
1616
ctx := context.Background()
17-
postgres, _, db := testhelper.SetupDatabase(ctx, t)
18-
defer postgres.Stop() //nolint
17+
closeDB, _, db := testhelper.SetupDatabase(ctx, t)
18+
defer closeDB()
1919

2020
repoID := uuid.New()
2121
commitRepo := models.NewCommitRepo(db, repoID)
@@ -41,8 +41,8 @@ func TestCommitRepo(t *testing.T) {
4141

4242
func TestDeleteCommit(t *testing.T) {
4343
ctx := context.Background()
44-
postgres, _, db := testhelper.SetupDatabase(ctx, t)
45-
defer postgres.Stop() //nolint
44+
closeDB, _, db := testhelper.SetupDatabase(ctx, t)
45+
defer closeDB()
4646
t.Run("delete commit", func(t *testing.T) {
4747
repoID := uuid.New()
4848
commitRepo := models.NewCommitRepo(db, repoID)

models/merge_request_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import (
1717

1818
func TestMergeRequestRepoInsert(t *testing.T) {
1919
ctx := context.Background()
20-
postgres, _, db := testhelper.SetupDatabase(ctx, t)
21-
defer postgres.Stop() //nolint
20+
closeDB, _, db := testhelper.SetupDatabase(ctx, t)
21+
defer closeDB()
2222

2323
mrRepo := models.NewMergeRequestRepo(db)
2424

models/repo_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import (
1616

1717
func TestRepoTransaction(t *testing.T) {
1818
ctx := context.Background()
19-
postgres, _, db := testhelper.SetupDatabase(ctx, t)
20-
defer postgres.Stop() //nolint
19+
closeDB, _, db := testhelper.SetupDatabase(ctx, t)
20+
defer closeDB()
2121

2222
t.Run("simple", func(t *testing.T) {
2323
pgRepo := models.NewRepo(db)

models/repository_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import (
1515

1616
func TestRepositoryUpdate(t *testing.T) {
1717
ctx := context.Background()
18-
postgres, _, db := testhelper.SetupDatabase(ctx, t)
19-
defer postgres.Stop() //nolint
18+
closeDB, _, db := testhelper.SetupDatabase(ctx, t)
19+
defer closeDB()
2020

2121
repo := models.NewRepositoryRepo(db)
2222

@@ -49,8 +49,8 @@ func TestRepositoryUpdate(t *testing.T) {
4949

5050
func TestRepositoryRepoInsert(t *testing.T) {
5151
ctx := context.Background()
52-
postgres, _, db := testhelper.SetupDatabase(ctx, t)
53-
defer postgres.Stop() //nolint
52+
closeDB, _, db := testhelper.SetupDatabase(ctx, t)
53+
defer closeDB()
5454

5555
repo := models.NewRepositoryRepo(db)
5656

models/tag_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import (
1414

1515
func TestTagRepo(t *testing.T) {
1616
ctx := context.Background()
17-
postgres, _, db := testhelper.SetupDatabase(ctx, t)
18-
defer postgres.Stop() //nolint
17+
closeDB, _, db := testhelper.SetupDatabase(ctx, t)
18+
defer closeDB()
1919

2020
repoID := uuid.New()
2121
tagRepo := models.NewTagRepo(db, repoID)
@@ -41,8 +41,8 @@ func TestTagRepo(t *testing.T) {
4141

4242
func TestDeleteTag(t *testing.T) {
4343
ctx := context.Background()
44-
postgres, _, db := testhelper.SetupDatabase(ctx, t)
45-
defer postgres.Stop() //nolint
44+
closeDB, _, db := testhelper.SetupDatabase(ctx, t)
45+
defer closeDB()
4646
t.Run("delete tag", func(t *testing.T) {
4747
repoID := uuid.New()
4848
tagRepo := models.NewTagRepo(db, repoID)

models/tree_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ func Test_sortSubObjects(t *testing.T) {
3939

4040
func TestObjectRepo_Insert(t *testing.T) {
4141
ctx := context.Background()
42-
postgres, _, db := testhelper.SetupDatabase(ctx, t)
43-
defer postgres.Stop() //nolint
42+
closeDB, _, db := testhelper.SetupDatabase(ctx, t)
43+
defer closeDB()
4444

4545
repoID := uuid.New()
4646
repo := models.NewFileTree(db, repoID)
@@ -99,8 +99,8 @@ func TestNewTreeNode(t *testing.T) {
9999

100100
func TestFileTreeRepo_Delete(t *testing.T) {
101101
ctx := context.Background()
102-
postgres, _, db := testhelper.SetupDatabase(ctx, t)
103-
defer postgres.Stop() //nolint
102+
closeDB, _, db := testhelper.SetupDatabase(ctx, t)
103+
defer closeDB()
104104

105105
repoID := uuid.New()
106106
repo := models.NewFileTree(db, repoID)

models/user_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ var dbTimeCmpOpt = cmp.Comparer(func(x, y time.Time) bool {
1919

2020
func TestNewUserRepo(t *testing.T) {
2121
ctx := context.Background()
22-
postgres, _, db := testhelper.SetupDatabase(ctx, t)
23-
defer postgres.Stop() //nolint
22+
closeDB, _, db := testhelper.SetupDatabase(ctx, t)
23+
defer closeDB()
2424

2525
repo := models.NewUserRepo(db)
2626

models/wip_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import (
1515

1616
func TestWipRepo(t *testing.T) {
1717
ctx := context.Background()
18-
postgres, _, db := testhelper.SetupDatabase(ctx, t)
19-
defer postgres.Stop() //nolint
18+
closeDB, _, db := testhelper.SetupDatabase(ctx, t)
19+
defer closeDB()
2020

2121
repo := models.NewWipRepo(db)
2222

@@ -72,8 +72,8 @@ func TestWipRepo(t *testing.T) {
7272

7373
func TestWipRepoUpdateByID(t *testing.T) {
7474
ctx := context.Background()
75-
postgres, _, db := testhelper.SetupDatabase(ctx, t)
76-
defer postgres.Stop() //nolint
75+
closeDB, _, db := testhelper.SetupDatabase(ctx, t)
76+
defer closeDB()
7777

7878
repo := models.NewWipRepo(db)
7979

0 commit comments

Comments
 (0)