aboutsummaryrefslogtreecommitdiffstats
path: root/integrations/repo_commits_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'integrations/repo_commits_test.go')
-rw-r--r--integrations/repo_commits_test.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/integrations/repo_commits_test.go b/integrations/repo_commits_test.go
index 1f70d69251..7a4761adc6 100644
--- a/integrations/repo_commits_test.go
+++ b/integrations/repo_commits_test.go
@@ -5,10 +5,13 @@
package integrations
import (
+ "encoding/json"
"net/http"
+ "net/http/httptest"
"path"
"testing"
+ "code.gitea.io/gitea/modules/setting"
api "code.gitea.io/gitea/modules/structs"
"github.com/stretchr/testify/assert"
@@ -67,6 +70,29 @@ func doTestRepoCommitWithStatus(t *testing.T, state string, classes ...string) {
for _, class := range classes {
assert.True(t, sel.HasClass(class))
}
+
+ //By SHA
+ req = NewRequest(t, "GET", "/api/v1/repos/user2/repo1/commits/"+path.Base(commitURL)+"/statuses")
+ testRepoCommitsWithStatus(t, session.MakeRequest(t, req, http.StatusOK), state)
+ //By Ref
+ req = NewRequest(t, "GET", "/api/v1/repos/user2/repo1/commits/master/statuses")
+ testRepoCommitsWithStatus(t, session.MakeRequest(t, req, http.StatusOK), state)
+ req = NewRequest(t, "GET", "/api/v1/repos/user2/repo1/commits/v1.1/statuses")
+ testRepoCommitsWithStatus(t, session.MakeRequest(t, req, http.StatusOK), state)
+}
+
+func testRepoCommitsWithStatus(t *testing.T, resp *httptest.ResponseRecorder, state string) {
+ decoder := json.NewDecoder(resp.Body)
+ statuses := []*api.Status{}
+ assert.NoError(t, decoder.Decode(&statuses))
+ assert.Len(t, statuses, 1)
+ for _, s := range statuses {
+ assert.Equal(t, api.StatusState(state), s.State)
+ assert.Equal(t, setting.AppURL+"api/v1/repos/user2/repo1/statuses/65f1bf27bc3bf70f64657658635e66094edbcb4d", s.URL)
+ assert.Equal(t, "http://test.ci/", s.TargetURL)
+ assert.Equal(t, "", s.Description)
+ assert.Equal(t, "testci", s.Context)
+ }
}
func TestRepoCommitsWithStatusPending(t *testing.T) {