Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bkcsoft committed Apr 7, 2017
1 parent 32a6680 commit ee1f2c0
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 0 deletions.
54 changes: 54 additions & 0 deletions models/fixtures/commit_status.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
-
id: 1
index: 1
repo_id: 1
state: pending
sha: 1234123412341234123412341234123412341234
target_url: https://example.com/builds/
description: My awesome CI-service
context: ci/awesomeness
creator_id: 2

-
id: 2
index: 2
repo_id: 1
state: warning
sha: 1234123412341234123412341234123412341234
target_url: https://example.com/converage/
description: My awesome Coverage service
context: cov/awesomeness
creator_id: 2

-
id: 3
index: 3
repo_id: 1
state: success
sha: 1234123412341234123412341234123412341234
target_url: https://example.com/converage/
description: My awesome Coverage service
context: cov/awesomeness
creator_id: 2

-
id: 4
index: 4
repo_id: 1
state: failed
sha: 1234123412341234123412341234123412341234
target_url: https://example.com/builds/
description: My awesome CI-service
context: ci/awesomeness
creator_id: 2

-
id: 5
index: 5
repo_id: 1
state: error
sha: 1234123412341234123412341234123412341234
target_url: https://example.com/builds/
description: My awesome deploy service
context: deploy/awesomeness
creator_id: 2
41 changes: 41 additions & 0 deletions models/status_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// 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.

// +build disabled

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, "ci/awesomeness")
assert.Equal(t, statuses[4].State, CommitStatusError)
}
}

0 comments on commit ee1f2c0

Please sign in to comment.