aboutsummaryrefslogtreecommitdiffstats
path: root/models/repo_test.go
diff options
context:
space:
mode:
authorPhil Hopper <philhopper@sibertec.com>2017-06-06 05:09:54 -0400
committerBo-Yi Wu <appleboy.tw@gmail.com>2017-06-06 04:09:54 -0500
commit6ec07a6bd7d1f88f0685efa4e1b62a32cbb25e43 (patch)
treefa6b6ef919193243d640b814b8ca82dbb5bd9d27 /models/repo_test.go
parentcbdd5f787c2124ab604c9ab60b1de20c05a26b4c (diff)
downloadgitea-6ec07a6bd7d1f88f0685efa4e1b62a32cbb25e43.tar.gz
gitea-6ec07a6bd7d1f88f0685efa4e1b62a32cbb25e43.zip
Make `LocalCopyPath` a setting instead of a hard-coded path (#1881)
Diffstat (limited to 'models/repo_test.go')
-rw-r--r--models/repo_test.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/models/repo_test.go b/models/repo_test.go
index a538d44c0e..13ac272b6d 100644
--- a/models/repo_test.go
+++ b/models/repo_test.go
@@ -5,11 +5,14 @@
package models
import (
+ "path"
"testing"
"code.gitea.io/gitea/modules/markdown"
+ "code.gitea.io/gitea/modules/setting"
"github.com/stretchr/testify/assert"
+ "github.com/Unknwon/com"
)
func TestRepo(t *testing.T) {
@@ -132,3 +135,22 @@ func TestRepoAPIURL(t *testing.T) {
assert.Equal(t, "https://try.gitea.io/api/v1/repos/user12/repo10", repo.APIURL())
}
+
+func TestRepoLocalCopyPath(t *testing.T) {
+ assert.NoError(t, PrepareTestDatabase())
+
+ repo, err := GetRepositoryByID(10)
+ assert.NoError(t, err)
+ assert.NotNil(t, repo)
+
+ // test default
+ repoID := com.ToStr(repo.ID)
+ expected := path.Join(setting.AppDataPath, setting.Repository.Local.LocalCopyPath, repoID)
+ assert.Equal(t, expected, repo.LocalCopyPath())
+
+ // test absolute setting
+ tempPath := "/tmp/gitea/local-copy-path"
+ expected = path.Join(tempPath, repoID)
+ setting.Repository.Local.LocalCopyPath = tempPath
+ assert.Equal(t, expected, repo.LocalCopyPath())
+}