Skip to content

Commit d7e3851

Browse files
committed
Tests
1 parent 2bee512 commit d7e3851

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

models/action_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,33 @@
11
package models
22

33
import (
4+
"path"
45
"strings"
56
"testing"
67

8+
"code.gitea.io/gitea/modules/setting"
9+
710
"github.com/stretchr/testify/assert"
811
)
912

13+
func TestAction_GetRepoPath(t *testing.T) {
14+
assert.NoError(t, PrepareTestDatabase())
15+
repo := AssertExistsAndLoadBean(t, &Repository{}).(*Repository)
16+
owner := AssertExistsAndLoadBean(t, &User{ID: repo.OwnerID}).(*User)
17+
action := &Action{RepoID: repo.ID}
18+
assert.Equal(t, path.Join(owner.Name, repo.Name), action.GetRepoPath())
19+
}
20+
21+
func TestAction_GetRepoLink(t *testing.T) {
22+
assert.NoError(t, PrepareTestDatabase())
23+
repo := AssertExistsAndLoadBean(t, &Repository{}).(*Repository)
24+
owner := AssertExistsAndLoadBean(t, &User{ID: repo.OwnerID}).(*User)
25+
action := &Action{RepoID: repo.ID}
26+
setting.AppSubURL = "/suburl/"
27+
expected := path.Join(setting.AppSubURL, owner.Name, repo.Name)
28+
assert.Equal(t, expected, action.GetRepoLink())
29+
}
30+
1031
func TestNewRepoAction(t *testing.T) {
1132
assert.NoError(t, PrepareTestDatabase())
1233

0 commit comments

Comments
 (0)