|
| 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 | + |
| 5 | +package models |
| 6 | + |
| 7 | +import ( |
| 8 | + "testing" |
| 9 | + |
| 10 | + "github.com/stretchr/testify/assert" |
| 11 | +) |
| 12 | + |
| 13 | +func TestToWikiPageURL(t *testing.T) { |
| 14 | + assert.Equal(t, "wiki-name", ToWikiPageURL("wiki-name")) |
| 15 | + assert.Equal(t, "wiki-name-with-many-spaces", ToWikiPageURL("wiki name with many spaces")) |
| 16 | +} |
| 17 | + |
| 18 | +func TestToWikiPageName(t *testing.T) { |
| 19 | + assert.Equal(t, "wiki name", ToWikiPageName("wiki name")) |
| 20 | + assert.Equal(t, "wiki name", ToWikiPageName("wiki-name")) |
| 21 | + assert.Equal(t, "wiki name", ToWikiPageName("wiki\tname")) |
| 22 | + assert.Equal(t, "wiki name", ToWikiPageName("./.././wiki/name")) |
| 23 | +} |
| 24 | + |
| 25 | +func TestRepository_WikiCloneLink(t *testing.T) { |
| 26 | + assert.NoError(t, PrepareTestDatabase()) |
| 27 | + |
| 28 | + repo := AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository) |
| 29 | + cloneLink := repo.WikiCloneLink() |
| 30 | + assert. Equal( t, "ssh://[email protected]:3000/user2/repo1.wiki.git", cloneLink. SSH) |
| 31 | + assert.Equal(t, "https://try.gitea.io/user2/repo1.wiki.git", cloneLink.HTTPS) |
| 32 | +} |
| 33 | + |
| 34 | +func TestWikiPath(t *testing.T) { |
| 35 | + assert.NoError(t, PrepareTestDatabase()) |
| 36 | + assert.Equal(t, "/repos/user2/repo1.wiki.git", WikiPath("user2", "repo1")) |
| 37 | +} |
| 38 | + |
| 39 | +func TestRepository_WikiPath(t *testing.T) { |
| 40 | + assert.NoError(t, PrepareTestDatabase()) |
| 41 | + repo := AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository) |
| 42 | + assert.Equal(t, "/repos/user2/repo1.wiki.git", repo.WikiPath()) |
| 43 | +} |
| 44 | + |
| 45 | +// TODO TestRepository_HasWiki |
| 46 | + |
| 47 | +// TODO TestRepository_InitWiki |
| 48 | + |
| 49 | +func TestRepository_LocalWikiPath(t *testing.T) { |
| 50 | + assert.NoError(t, PrepareTestDatabase()) |
| 51 | + repo := AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository) |
| 52 | + assert.Equal(t, "/appdata/tmp/local-wiki/1", repo.LocalWikiPath()) |
| 53 | +} |
| 54 | + |
| 55 | +// TODO TestRepository_UpdateLocalWiki |
| 56 | + |
| 57 | +// TODO ... (all remaining untested functions) |
0 commit comments