Skip to content

Commit ee1f2c0

Browse files
committed
tests
1 parent 32a6680 commit ee1f2c0

File tree

2 files changed

+95
-0
lines changed

2 files changed

+95
-0
lines changed

models/fixtures/commit_status.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
-
2+
id: 1
3+
index: 1
4+
repo_id: 1
5+
state: pending
6+
sha: 1234123412341234123412341234123412341234
7+
target_url: https://example.com/builds/
8+
description: My awesome CI-service
9+
context: ci/awesomeness
10+
creator_id: 2
11+
12+
-
13+
id: 2
14+
index: 2
15+
repo_id: 1
16+
state: warning
17+
sha: 1234123412341234123412341234123412341234
18+
target_url: https://example.com/converage/
19+
description: My awesome Coverage service
20+
context: cov/awesomeness
21+
creator_id: 2
22+
23+
-
24+
id: 3
25+
index: 3
26+
repo_id: 1
27+
state: success
28+
sha: 1234123412341234123412341234123412341234
29+
target_url: https://example.com/converage/
30+
description: My awesome Coverage service
31+
context: cov/awesomeness
32+
creator_id: 2
33+
34+
-
35+
id: 4
36+
index: 4
37+
repo_id: 1
38+
state: failed
39+
sha: 1234123412341234123412341234123412341234
40+
target_url: https://example.com/builds/
41+
description: My awesome CI-service
42+
context: ci/awesomeness
43+
creator_id: 2
44+
45+
-
46+
id: 5
47+
index: 5
48+
repo_id: 1
49+
state: error
50+
sha: 1234123412341234123412341234123412341234
51+
target_url: https://example.com/builds/
52+
description: My awesome deploy service
53+
context: deploy/awesomeness
54+
creator_id: 2

models/status_test.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright 2017 Gitea. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
// +build disabled
6+
7+
package models
8+
9+
import (
10+
"testing"
11+
12+
"github.com/stretchr/testify/assert"
13+
)
14+
15+
func TestGetCommitStatuses(t *testing.T) {
16+
assert.NoError(t, PrepareTestDatabase())
17+
18+
repo1 := AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository)
19+
20+
sha1 := "1234123412341234123412341234123412341234"
21+
22+
statuses, err := GetCommitStatuses(repo1, sha1, 0)
23+
assert.NoError(t, err)
24+
if assert.Equal(t, 5, len(statuses), "Expected to get 5 statuses") {
25+
26+
assert.Equal(t, statuses[0].Context, "ci/awesomeness")
27+
assert.Equal(t, statuses[0].State, CommitStatusPending)
28+
29+
assert.Equal(t, statuses[1].Context, "cov/awesomeness")
30+
assert.Equal(t, statuses[1].State, CommitStatusWarning)
31+
32+
assert.Equal(t, statuses[2].Context, "cov/awesomeness")
33+
assert.Equal(t, statuses[2].State, CommitStatusSuccess)
34+
35+
assert.Equal(t, statuses[3].Context, "ci/awesomeness")
36+
assert.Equal(t, statuses[3].State, CommitStatusFailure)
37+
38+
assert.Equal(t, statuses[4].Context, "ci/awesomeness")
39+
assert.Equal(t, statuses[4].State, CommitStatusError)
40+
}
41+
}

0 commit comments

Comments
 (0)