Skip to content

Commit be1330e

Browse files
lafriksbkcsoft
authored andcommitted
Remove hardcoded paths to fix randomly failing tests (#3347)
* Remove hardcoded paths to fix randomly failing tests * Use correct function for merge path
1 parent d8dff30 commit be1330e

File tree

8 files changed

+19
-3
lines changed

8 files changed

+19
-3
lines changed

integrations/integration_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ func prepareTestEnv(t testing.TB) {
138138
assert.NoError(t, models.LoadFixtures())
139139
assert.NoError(t, os.RemoveAll(setting.RepoRootPath))
140140
assert.NoError(t, os.RemoveAll(models.LocalCopyPath()))
141+
assert.NoError(t, os.RemoveAll(models.LocalUncycloPath()))
141142

142143
assert.NoError(t, com.CopyDir(path.Join(filepath.Dir(setting.AppPath), "integrations/gitea-repositories-meta"),
143144
setting.RepoRootPath))

integrations/mysql.ini.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ ROOT = integrations/gitea-integration-mysql/gitea-repositories
2020

2121
[repository.local]
2222
LOCAL_COPY_PATH = tmp/local-repo-mysql
23+
LOCAL_WIKI_PATH = tmp/local-wiki-mysql
2324

2425
[server]
2526
SSH_DOMAIN = localhost

integrations/pgsql.ini.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ ROOT = integrations/gitea-integration-pgsql/gitea-repositories
2020

2121
[repository.local]
2222
LOCAL_COPY_PATH = tmp/local-repo-pgsql
23+
LOCAL_WIKI_PATH = tmp/local-wiki-pgsql
2324

2425
[server]
2526
SSH_DOMAIN = localhost

integrations/sqlite.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ ROOT = integrations/gitea-integration-sqlite/gitea-repositories
1515

1616
[repository.local]
1717
LOCAL_COPY_PATH = tmp/local-repo-sqlite
18+
LOCAL_WIKI_PATH = tmp/local-wiki-sqlite
1819

1920
[server]
2021
SSH_DOMAIN = localhost
@@ -23,6 +24,7 @@ ROOT_URL = http://localhost:3003/
2324
DISABLE_SSH = false
2425
SSH_PORT = 22
2526
LFS_START_SERVER = true
27+
LFS_CONTENT_PATH = data/lfs-sqlite
2628
OFFLINE_MODE = false
2729
LFS_JWT_SECRET = Tv_MjmZuHqpIY6GFl12ebgkRAMt4RlWt0v4EHKSXO0w
2830

models/pull.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle
299299
}
300300

301301
// Clone base repo.
302-
tmpBasePath := path.Join(setting.AppDataPath, "tmp/repos", com.ToStr(time.Now().Nanosecond())+".git")
302+
tmpBasePath := path.Join(LocalCopyPath(), "merge-"+com.ToStr(time.Now().Nanosecond())+".git")
303303

304304
if err := os.MkdirAll(path.Dir(tmpBasePath), os.ModePerm); err != nil {
305305
return fmt.Errorf("Failed to create dir %s: %v", tmpBasePath, err)

models/wiki.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,17 @@ func (repo *Repository) InitUncyclo() error {
9090
return nil
9191
}
9292

93+
// LocalUncycloPath returns the local wiki repository copy path.
94+
func LocalUncycloPath() string {
95+
if filepath.IsAbs(setting.Repository.Local.LocalUncycloPath) {
96+
return setting.Repository.Local.LocalUncycloPath
97+
}
98+
return path.Join(setting.AppDataPath, setting.Repository.Local.LocalUncycloPath)
99+
}
100+
93101
// LocalUncycloPath returns the path to the local wiki repository (?).
94102
func (repo *Repository) LocalUncycloPath() string {
95-
return path.Join(setting.AppDataPath, "tmp/local-wiki", com.ToStr(repo.ID))
103+
return path.Join(LocalUncycloPath(), com.ToStr(repo.ID))
96104
}
97105

98106
// UpdateLocalUncyclo makes sure the local copy of repository wiki is up-to-date.

models/wiki_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func TestRepository_InitUncyclo(t *testing.T) {
145145
func TestRepository_LocalUncycloPath(t *testing.T) {
146146
PrepareTestEnv(t)
147147
repo := AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository)
148-
expected := filepath.Join(setting.AppDataPath, "tmp/local-wiki/1")
148+
expected := filepath.Join(setting.AppDataPath, setting.Repository.Local.LocalUncycloPath, "1")
149149
assert.Equal(t, expected, repo.LocalUncycloPath())
150150
}
151151

modules/setting/setting.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ var (
215215
// Repository local settings
216216
Local struct {
217217
LocalCopyPath string
218+
LocalUncycloPath string
218219
} `ini:"-"`
219220
}{
220221
AnsiCharset: "",
@@ -254,8 +255,10 @@ var (
254255
// Repository local settings
255256
Local: struct {
256257
LocalCopyPath string
258+
LocalUncycloPath string
257259
}{
258260
LocalCopyPath: "tmp/local-repo",
261+
LocalUncycloPath: "tmp/local-wiki",
259262
},
260263
}
261264
RepoRootPath string

0 commit comments

Comments
 (0)