Procházet zdrojové kódy

Remove hardcoded paths to fix randomly failing tests (#3347)

* Remove hardcoded paths to fix randomly failing tests

* Use correct function for merge path
tags/v1.4.0-rc1
Lauris BH před 6 roky
rodič
revize
be1330ec89

+ 1
- 0
integrations/integration_test.go Zobrazit soubor

assert.NoError(t, models.LoadFixtures()) assert.NoError(t, models.LoadFixtures())
assert.NoError(t, os.RemoveAll(setting.RepoRootPath)) assert.NoError(t, os.RemoveAll(setting.RepoRootPath))
assert.NoError(t, os.RemoveAll(models.LocalCopyPath())) assert.NoError(t, os.RemoveAll(models.LocalCopyPath()))
assert.NoError(t, os.RemoveAll(models.LocalWikiPath()))


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

+ 1
- 0
integrations/mysql.ini.tmpl Zobrazit soubor



[repository.local] [repository.local]
LOCAL_COPY_PATH = tmp/local-repo-mysql LOCAL_COPY_PATH = tmp/local-repo-mysql
LOCAL_WIKI_PATH = tmp/local-wiki-mysql


[server] [server]
SSH_DOMAIN = localhost SSH_DOMAIN = localhost

+ 1
- 0
integrations/pgsql.ini.tmpl Zobrazit soubor



[repository.local] [repository.local]
LOCAL_COPY_PATH = tmp/local-repo-pgsql LOCAL_COPY_PATH = tmp/local-repo-pgsql
LOCAL_WIKI_PATH = tmp/local-wiki-pgsql


[server] [server]
SSH_DOMAIN = localhost SSH_DOMAIN = localhost

+ 2
- 0
integrations/sqlite.ini Zobrazit soubor



[repository.local] [repository.local]
LOCAL_COPY_PATH = tmp/local-repo-sqlite LOCAL_COPY_PATH = tmp/local-repo-sqlite
LOCAL_WIKI_PATH = tmp/local-wiki-sqlite


[server] [server]
SSH_DOMAIN = localhost SSH_DOMAIN = localhost
DISABLE_SSH = false DISABLE_SSH = false
SSH_PORT = 22 SSH_PORT = 22
LFS_START_SERVER = true LFS_START_SERVER = true
LFS_CONTENT_PATH = data/lfs-sqlite
OFFLINE_MODE = false OFFLINE_MODE = false
LFS_JWT_SECRET = Tv_MjmZuHqpIY6GFl12ebgkRAMt4RlWt0v4EHKSXO0w LFS_JWT_SECRET = Tv_MjmZuHqpIY6GFl12ebgkRAMt4RlWt0v4EHKSXO0w



+ 1
- 1
models/pull.go Zobrazit soubor

} }


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


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

+ 9
- 1
models/wiki.go Zobrazit soubor

return nil return nil
} }


// LocalWikiPath returns the local wiki repository copy path.
func LocalWikiPath() string {
if filepath.IsAbs(setting.Repository.Local.LocalWikiPath) {
return setting.Repository.Local.LocalWikiPath
}
return path.Join(setting.AppDataPath, setting.Repository.Local.LocalWikiPath)
}

// LocalWikiPath returns the path to the local wiki repository (?). // LocalWikiPath returns the path to the local wiki repository (?).
func (repo *Repository) LocalWikiPath() string { func (repo *Repository) LocalWikiPath() string {
return path.Join(setting.AppDataPath, "tmp/local-wiki", com.ToStr(repo.ID))
return path.Join(LocalWikiPath(), com.ToStr(repo.ID))
} }


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

+ 1
- 1
models/wiki_test.go Zobrazit soubor

func TestRepository_LocalWikiPath(t *testing.T) { func TestRepository_LocalWikiPath(t *testing.T) {
PrepareTestEnv(t) PrepareTestEnv(t)
repo := AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository) repo := AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository)
expected := filepath.Join(setting.AppDataPath, "tmp/local-wiki/1")
expected := filepath.Join(setting.AppDataPath, setting.Repository.Local.LocalWikiPath, "1")
assert.Equal(t, expected, repo.LocalWikiPath()) assert.Equal(t, expected, repo.LocalWikiPath())
} }



+ 3
- 0
modules/setting/setting.go Zobrazit soubor

// Repository local settings // Repository local settings
Local struct { Local struct {
LocalCopyPath string LocalCopyPath string
LocalWikiPath string
} `ini:"-"` } `ini:"-"`
}{ }{
AnsiCharset: "", AnsiCharset: "",
// Repository local settings // Repository local settings
Local: struct { Local: struct {
LocalCopyPath string LocalCopyPath string
LocalWikiPath string
}{ }{
LocalCopyPath: "tmp/local-repo", LocalCopyPath: "tmp/local-repo",
LocalWikiPath: "tmp/local-wiki",
}, },
} }
RepoRootPath string RepoRootPath string

Načítá se…
Zrušit
Uložit