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.

44 lines
1.4 KiB

  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 models
  5. import (
  6. "path/filepath"
  7. "testing"
  8. "code.gitea.io/gitea/modules/setting"
  9. "github.com/stretchr/testify/assert"
  10. )
  11. func TestRepository_WikiCloneLink(t *testing.T) {
  12. assert.NoError(t, PrepareTestDatabase())
  13. repo := AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository)
  14. cloneLink := repo.WikiCloneLink()
  15. assert.Equal(t, "ssh://runuser@try.gitea.io:3000/user2/repo1.wiki.git", cloneLink.SSH)
  16. assert.Equal(t, "https://try.gitea.io/user2/repo1.wiki.git", cloneLink.HTTPS)
  17. }
  18. func TestWikiPath(t *testing.T) {
  19. assert.NoError(t, PrepareTestDatabase())
  20. expected := filepath.Join(setting.RepoRootPath, "user2/repo1.wiki.git")
  21. assert.Equal(t, expected, WikiPath("user2", "repo1"))
  22. }
  23. func TestRepository_WikiPath(t *testing.T) {
  24. assert.NoError(t, PrepareTestDatabase())
  25. repo := AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository)
  26. expected := filepath.Join(setting.RepoRootPath, "user2/repo1.wiki.git")
  27. assert.Equal(t, expected, repo.WikiPath())
  28. }
  29. func TestRepository_HasWiki(t *testing.T) {
  30. PrepareTestEnv(t)
  31. repo1 := AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository)
  32. assert.True(t, repo1.HasWiki())
  33. repo2 := AssertExistsAndLoadBean(t, &Repository{ID: 2}).(*Repository)
  34. assert.False(t, repo2.HasWiki())
  35. }