Skip to content

Commit 7765593

Browse files
ethantkoeniglunny
authored andcommitted
Better settings for unit tests (#795)
1 parent 78535fb commit 7765593

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

models/setup_for_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ func TestMain(m *testing.M) {
3030
setting.RunUser = "runuser"
3131
setting.SSH.Port = 3000
3232
setting.SSH.Domain = "try.gitea.io"
33-
setting.RepoRootPath = "/repos"
34-
setting.AppDataPath = "/appdata"
33+
setting.RepoRootPath = "/tmp/repos"
34+
setting.AppDataPath = "/tmp/appdata"
3535

3636
os.Exit(m.Run())
3737
}

models/wiki_test.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55
package models
66

77
import (
8+
"path/filepath"
89
"testing"
910

11+
"code.gitea.io/gitea/modules/setting"
12+
1013
"github.com/stretchr/testify/assert"
1114
)
1215

@@ -33,13 +36,15 @@ func TestRepository_UncycloCloneLink(t *testing.T) {
3336

3437
func TestUncycloPath(t *testing.T) {
3538
assert.NoError(t, PrepareTestDatabase())
36-
assert.Equal(t, "/repos/user2/repo1.wiki.git", UncycloPath("user2", "repo1"))
39+
expected := filepath.Join(setting.RepoRootPath, "user2/repo1.wiki.git")
40+
assert.Equal(t, expected, UncycloPath("user2", "repo1"))
3741
}
3842

3943
func TestRepository_UncycloPath(t *testing.T) {
4044
assert.NoError(t, PrepareTestDatabase())
4145
repo := AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository)
42-
assert.Equal(t, "/repos/user2/repo1.wiki.git", repo.UncycloPath())
46+
expected := filepath.Join(setting.RepoRootPath, "user2/repo1.wiki.git")
47+
assert.Equal(t, expected, repo.UncycloPath())
4348
}
4449

4550
// TODO TestRepository_HasUncyclo
@@ -49,7 +54,8 @@ func TestRepository_UncycloPath(t *testing.T) {
4954
func TestRepository_LocalUncycloPath(t *testing.T) {
5055
assert.NoError(t, PrepareTestDatabase())
5156
repo := AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository)
52-
assert.Equal(t, "/appdata/tmp/local-wiki/1", repo.LocalUncycloPath())
57+
expected := filepath.Join(setting.AppDataPath, "tmp/local-wiki/1")
58+
assert.Equal(t, expected, repo.LocalUncycloPath())
5359
}
5460

5561
// TODO TestRepository_UpdateLocalUncyclo

0 commit comments

Comments
 (0)