Fork to maintain patches against the official gitea for https://code.ceondo.com https://github.com/go-gitea/gitea

wiki_test.go 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 TestToWikiPageURL(t *testing.T) {
  12. assert.Equal(t, "wiki-name", ToWikiPageURL("wiki-name"))
  13. assert.Equal(t, "wiki-name-with-many-spaces", ToWikiPageURL("wiki name with many spaces"))
  14. }
  15. func TestToWikiPageName(t *testing.T) {
  16. assert.Equal(t, "wiki name", ToWikiPageName("wiki name"))
  17. assert.Equal(t, "wiki name", ToWikiPageName("wiki-name"))
  18. assert.Equal(t, "wiki name", ToWikiPageName("wiki\tname"))
  19. assert.Equal(t, "wiki name", ToWikiPageName("./.././wiki/name"))
  20. }
  21. func TestRepository_WikiCloneLink(t *testing.T) {
  22. assert.NoError(t, PrepareTestDatabase())
  23. repo := AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository)
  24. cloneLink := repo.WikiCloneLink()
  25. assert.Equal(t, "ssh://runuser@try.gitea.io:3000/user2/repo1.wiki.git", cloneLink.SSH)
  26. assert.Equal(t, "https://try.gitea.io/user2/repo1.wiki.git", cloneLink.HTTPS)
  27. }
  28. func TestWikiPath(t *testing.T) {
  29. assert.NoError(t, PrepareTestDatabase())
  30. expected := filepath.Join(setting.RepoRootPath, "user2/repo1.wiki.git")
  31. assert.Equal(t, expected, WikiPath("user2", "repo1"))
  32. }
  33. func TestRepository_WikiPath(t *testing.T) {
  34. assert.NoError(t, PrepareTestDatabase())
  35. repo := AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository)
  36. expected := filepath.Join(setting.RepoRootPath, "user2/repo1.wiki.git")
  37. assert.Equal(t, expected, repo.WikiPath())
  38. }
  39. // TODO TestRepository_HasWiki
  40. // TODO TestRepository_InitWiki
  41. func TestRepository_LocalWikiPath(t *testing.T) {
  42. assert.NoError(t, PrepareTestDatabase())
  43. repo := AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository)
  44. expected := filepath.Join(setting.AppDataPath, "tmp/local-wiki/1")
  45. assert.Equal(t, expected, repo.LocalWikiPath())
  46. }
  47. // TODO TestRepository_UpdateLocalWiki
  48. // TODO ... (all remaining untested functions)