summaryrefslogtreecommitdiffstats
path: root/models/action_test.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2020-01-10 17:34:21 +0800
committerGitHub <noreply@github.com>2020-01-10 17:34:21 +0800
commit99d869fa63e07780f1a17d1a9599187b9b689d9b (patch)
treeecadeba077cf0ae58d0a21f232d280fec60c779a /models/action_test.go
parent384c2b342ec01fadb520572666127cb5564e1050 (diff)
downloadgitea-99d869fa63e07780f1a17d1a9599187b9b689d9b.tar.gz
gitea-99d869fa63e07780f1a17d1a9599187b9b689d9b.zip
Move push commits from models to modules/repository (#9370)
* Move push commits from models to modules/repository * fix test * fix test * fix test * fix test * fix test Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'models/action_test.go')
-rw-r--r--models/action_test.go100
1 files changed, 0 insertions, 100 deletions
diff --git a/models/action_test.go b/models/action_test.go
index c0344ebd44..a4e224853c 100644
--- a/models/action_test.go
+++ b/models/action_test.go
@@ -27,106 +27,6 @@ func TestAction_GetRepoLink(t *testing.T) {
assert.Equal(t, expected, action.GetRepoLink())
}
-func TestPushCommits_ToAPIPayloadCommits(t *testing.T) {
- pushCommits := NewPushCommits()
- pushCommits.Commits = []*PushCommit{
- {
- Sha1: "69554a6",
- CommitterEmail: "user2@example.com",
- CommitterName: "User2",
- AuthorEmail: "user2@example.com",
- AuthorName: "User2",
- Message: "not signed commit",
- },
- {
- Sha1: "27566bd",
- CommitterEmail: "user2@example.com",
- CommitterName: "User2",
- AuthorEmail: "user2@example.com",
- AuthorName: "User2",
- Message: "good signed commit (with not yet validated email)",
- },
- {
- Sha1: "5099b81",
- CommitterEmail: "user2@example.com",
- CommitterName: "User2",
- AuthorEmail: "user2@example.com",
- AuthorName: "User2",
- Message: "good signed commit",
- },
- }
- pushCommits.Len = len(pushCommits.Commits)
-
- repo := AssertExistsAndLoadBean(t, &Repository{ID: 16}).(*Repository)
- payloadCommits, err := pushCommits.ToAPIPayloadCommits(repo.RepoPath(), "/user2/repo16")
- assert.NoError(t, err)
- assert.EqualValues(t, 3, len(payloadCommits))
-
- assert.Equal(t, "69554a6", payloadCommits[0].ID)
- assert.Equal(t, "not signed commit", payloadCommits[0].Message)
- assert.Equal(t, "/user2/repo16/commit/69554a6", payloadCommits[0].URL)
- assert.Equal(t, "User2", payloadCommits[0].Committer.Name)
- assert.Equal(t, "user2", payloadCommits[0].Committer.UserName)
- assert.Equal(t, "User2", payloadCommits[0].Author.Name)
- assert.Equal(t, "user2", payloadCommits[0].Author.UserName)
- assert.EqualValues(t, []string{}, payloadCommits[0].Added)
- assert.EqualValues(t, []string{}, payloadCommits[0].Removed)
- assert.EqualValues(t, []string{"readme.md"}, payloadCommits[0].Modified)
-
- assert.Equal(t, "27566bd", payloadCommits[1].ID)
- assert.Equal(t, "good signed commit (with not yet validated email)", payloadCommits[1].Message)
- assert.Equal(t, "/user2/repo16/commit/27566bd", payloadCommits[1].URL)
- assert.Equal(t, "User2", payloadCommits[1].Committer.Name)
- assert.Equal(t, "user2", payloadCommits[1].Committer.UserName)
- assert.Equal(t, "User2", payloadCommits[1].Author.Name)
- assert.Equal(t, "user2", payloadCommits[1].Author.UserName)
- assert.EqualValues(t, []string{}, payloadCommits[1].Added)
- assert.EqualValues(t, []string{}, payloadCommits[1].Removed)
- assert.EqualValues(t, []string{"readme.md"}, payloadCommits[1].Modified)
-
- assert.Equal(t, "5099b81", payloadCommits[2].ID)
- assert.Equal(t, "good signed commit", payloadCommits[2].Message)
- assert.Equal(t, "/user2/repo16/commit/5099b81", payloadCommits[2].URL)
- assert.Equal(t, "User2", payloadCommits[2].Committer.Name)
- assert.Equal(t, "user2", payloadCommits[2].Committer.UserName)
- assert.Equal(t, "User2", payloadCommits[2].Author.Name)
- assert.Equal(t, "user2", payloadCommits[2].Author.UserName)
- assert.EqualValues(t, []string{"readme.md"}, payloadCommits[2].Added)
- assert.EqualValues(t, []string{}, payloadCommits[2].Removed)
- assert.EqualValues(t, []string{}, payloadCommits[2].Modified)
-}
-
-func TestPushCommits_AvatarLink(t *testing.T) {
- pushCommits := NewPushCommits()
- pushCommits.Commits = []*PushCommit{
- {
- Sha1: "abcdef1",
- CommitterEmail: "user2@example.com",
- CommitterName: "User Two",
- AuthorEmail: "user4@example.com",
- AuthorName: "User Four",
- Message: "message1",
- },
- {
- Sha1: "abcdef2",
- CommitterEmail: "user2@example.com",
- CommitterName: "User Two",
- AuthorEmail: "user2@example.com",
- AuthorName: "User Two",
- Message: "message2",
- },
- }
- pushCommits.Len = len(pushCommits.Commits)
-
- assert.Equal(t,
- "/suburl/user/avatar/user2/-1",
- pushCommits.AvatarLink("user2@example.com"))
-
- assert.Equal(t,
- "https://secure.gravatar.com/avatar/19ade630b94e1e0535b3df7387434154?d=identicon",
- pushCommits.AvatarLink("nonexistent@example.com"))
-}
-
func TestGetFeeds(t *testing.T) {
// test with an individual user
assert.NoError(t, PrepareTestDatabase())