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.
51 lines
2.2 KiB
51 lines
2.2 KiB
8 years ago
|
// Copyright 2017 Gitea. All rights reserved.
|
||
|
// Use of this source code is governed by a MIT-style
|
||
|
// license that can be found in the LICENSE file.
|
||
|
|
||
3 years ago
|
package git_test
|
||
8 years ago
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
3 years ago
|
"code.gitea.io/gitea/models/db"
|
||
3 years ago
|
git_model "code.gitea.io/gitea/models/git"
|
||
3 years ago
|
repo_model "code.gitea.io/gitea/models/repo"
|
||
3 years ago
|
"code.gitea.io/gitea/models/unittest"
|
||
5 years ago
|
"code.gitea.io/gitea/modules/structs"
|
||
3 years ago
|
|
||
8 years ago
|
"github.com/stretchr/testify/assert"
|
||
|
)
|
||
|
|
||
|
func TestGetCommitStatuses(t *testing.T) {
|
||
3 years ago
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
||
8 years ago
|
|
||
3 years ago
|
repo1 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}).(*repo_model.Repository)
|
||
8 years ago
|
|
||
|
sha1 := "1234123412341234123412341234123412341234"
|
||
|
|
||
3 years ago
|
statuses, maxResults, err := git_model.GetCommitStatuses(repo1, sha1, &git_model.CommitStatusOptions{ListOptions: db.ListOptions{Page: 1, PageSize: 50}})
|
||
8 years ago
|
assert.NoError(t, err)
|
||
5 years ago
|
assert.Equal(t, int(maxResults), 5)
|
||
5 years ago
|
assert.Len(t, statuses, 5)
|
||
8 years ago
|
|
||
5 years ago
|
assert.Equal(t, "ci/awesomeness", statuses[0].Context)
|
||
5 years ago
|
assert.Equal(t, structs.CommitStatusPending, statuses[0].State)
|
||
5 years ago
|
assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/statuses/1234123412341234123412341234123412341234", statuses[0].APIURL())
|
||
8 years ago
|
|
||
5 years ago
|
assert.Equal(t, "cov/awesomeness", statuses[1].Context)
|
||
5 years ago
|
assert.Equal(t, structs.CommitStatusWarning, statuses[1].State)
|
||
5 years ago
|
assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/statuses/1234123412341234123412341234123412341234", statuses[1].APIURL())
|
||
8 years ago
|
|
||
5 years ago
|
assert.Equal(t, "cov/awesomeness", statuses[2].Context)
|
||
5 years ago
|
assert.Equal(t, structs.CommitStatusSuccess, statuses[2].State)
|
||
5 years ago
|
assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/statuses/1234123412341234123412341234123412341234", statuses[2].APIURL())
|
||
8 years ago
|
|
||
5 years ago
|
assert.Equal(t, "ci/awesomeness", statuses[3].Context)
|
||
5 years ago
|
assert.Equal(t, structs.CommitStatusFailure, statuses[3].State)
|
||
5 years ago
|
assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/statuses/1234123412341234123412341234123412341234", statuses[3].APIURL())
|
||
|
|
||
|
assert.Equal(t, "deploy/awesomeness", statuses[4].Context)
|
||
5 years ago
|
assert.Equal(t, structs.CommitStatusError, statuses[4].State)
|
||
5 years ago
|
assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/statuses/1234123412341234123412341234123412341234", statuses[4].APIURL())
|
||
8 years ago
|
}
|