code.gitea.io/gitea@v1.21.7/models/repo/wiki_test.go (about) 1 // Copyright 2017 The Gitea Authors. All rights reserved. 2 // SPDX-License-Identifier: MIT 3 4 package repo_test 5 6 import ( 7 "path/filepath" 8 "testing" 9 10 repo_model "code.gitea.io/gitea/models/repo" 11 "code.gitea.io/gitea/models/unittest" 12 "code.gitea.io/gitea/modules/setting" 13 14 "github.com/stretchr/testify/assert" 15 ) 16 17 func TestRepository_WikiCloneLink(t *testing.T) { 18 assert.NoError(t, unittest.PrepareTestDatabase()) 19 20 repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}) 21 cloneLink := repo.WikiCloneLink() 22 assert.Equal(t, "ssh://sshuser@try.gitea.io:3000/user2/repo1.wiki.git", cloneLink.SSH) 23 assert.Equal(t, "https://try.gitea.io/user2/repo1.wiki.git", cloneLink.HTTPS) 24 } 25 26 func TestWikiPath(t *testing.T) { 27 assert.NoError(t, unittest.PrepareTestDatabase()) 28 expected := filepath.Join(setting.RepoRootPath, "user2/repo1.wiki.git") 29 assert.Equal(t, expected, repo_model.WikiPath("user2", "repo1")) 30 } 31 32 func TestRepository_WikiPath(t *testing.T) { 33 assert.NoError(t, unittest.PrepareTestDatabase()) 34 repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}) 35 expected := filepath.Join(setting.RepoRootPath, "user2/repo1.wiki.git") 36 assert.Equal(t, expected, repo.WikiPath()) 37 } 38 39 func TestRepository_HasWiki(t *testing.T) { 40 unittest.PrepareTestEnv(t) 41 repo1 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}) 42 assert.True(t, repo1.HasWiki()) 43 repo2 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 2}) 44 assert.False(t, repo2.HasWiki()) 45 }