You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

wiki_test.go 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright 2017 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package repo
  5. import (
  6. "path/filepath"
  7. "testing"
  8. "code.gitea.io/gitea/models/unittest"
  9. "code.gitea.io/gitea/modules/setting"
  10. "github.com/stretchr/testify/assert"
  11. )
  12. func TestRepository_WikiCloneLink(t *testing.T) {
  13. assert.NoError(t, unittest.PrepareTestDatabase())
  14. repo := unittest.AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository)
  15. cloneLink := repo.WikiCloneLink()
  16. assert.Equal(t, "ssh://sshuser@try.gitea.io:3000/user2/repo1.wiki.git", cloneLink.SSH)
  17. assert.Equal(t, "https://try.gitea.io/user2/repo1.wiki.git", cloneLink.HTTPS)
  18. }
  19. func TestWikiPath(t *testing.T) {
  20. assert.NoError(t, unittest.PrepareTestDatabase())
  21. expected := filepath.Join(setting.RepoRootPath, "user2/repo1.wiki.git")
  22. assert.Equal(t, expected, WikiPath("user2", "repo1"))
  23. }
  24. func TestRepository_WikiPath(t *testing.T) {
  25. assert.NoError(t, unittest.PrepareTestDatabase())
  26. repo := unittest.AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository)
  27. expected := filepath.Join(setting.RepoRootPath, "user2/repo1.wiki.git")
  28. assert.Equal(t, expected, repo.WikiPath())
  29. }
  30. func TestRepository_HasWiki(t *testing.T) {
  31. unittest.PrepareTestEnv(t)
  32. repo1 := unittest.AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository)
  33. assert.True(t, repo1.HasWiki())
  34. repo2 := unittest.AssertExistsAndLoadBean(t, &Repository{ID: 2}).(*Repository)
  35. assert.False(t, repo2.HasWiki())
  36. }