aboutsummaryrefslogtreecommitdiffstats
path: root/models/status_test.go
diff options
context:
space:
mode:
authorKim "BKC" Carlbäcker <kim.carlbacker@gmail.com>2017-04-21 13:32:31 +0200
committerLunny Xiao <xiaolunwen@gmail.com>2017-04-21 19:32:31 +0800
commit4bea2191286dd5a9c89696d3e8cd506caf997c7e (patch)
tree4f720881614581ccfa656a9f61d1a89313e05ceb /models/status_test.go
parent52627032bc55bd73694bea9e6e17df575b51664c (diff)
downloadgitea-4bea2191286dd5a9c89696d3e8cd506caf997c7e.tar.gz
gitea-4bea2191286dd5a9c89696d3e8cd506caf997c7e.zip
Status-API (#1332)
Diffstat (limited to 'models/status_test.go')
-rw-r--r--models/status_test.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/models/status_test.go b/models/status_test.go
new file mode 100644
index 0000000000..5585fb1dcc
--- /dev/null
+++ b/models/status_test.go
@@ -0,0 +1,39 @@
+// 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.
+
+package models
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+)
+
+func TestGetCommitStatuses(t *testing.T) {
+ assert.NoError(t, PrepareTestDatabase())
+
+ repo1 := AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository)
+
+ sha1 := "1234123412341234123412341234123412341234"
+
+ statuses, err := GetCommitStatuses(repo1, sha1, 0)
+ assert.NoError(t, err)
+ if assert.Equal(t, 5, len(statuses), "Expected to get 5 statuses") {
+
+ assert.Equal(t, statuses[0].Context, "ci/awesomeness")
+ assert.Equal(t, statuses[0].State, CommitStatusPending)
+
+ assert.Equal(t, statuses[1].Context, "cov/awesomeness")
+ assert.Equal(t, statuses[1].State, CommitStatusWarning)
+
+ assert.Equal(t, statuses[2].Context, "cov/awesomeness")
+ assert.Equal(t, statuses[2].State, CommitStatusSuccess)
+
+ assert.Equal(t, statuses[3].Context, "ci/awesomeness")
+ assert.Equal(t, statuses[3].State, CommitStatusFailure)
+
+ assert.Equal(t, statuses[4].Context, "deploy/awesomeness")
+ assert.Equal(t, statuses[4].State, CommitStatusError)
+ }
+}