Fork to maintain patches against the official gitea for https://code.ceondo.com https://github.com/go-gitea/gitea

status_test.go 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. package models
  5. import (
  6. "testing"
  7. "github.com/stretchr/testify/assert"
  8. )
  9. func TestGetCommitStatuses(t *testing.T) {
  10. assert.NoError(t, PrepareTestDatabase())
  11. repo1 := AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository)
  12. sha1 := "1234123412341234123412341234123412341234"
  13. statuses, err := GetCommitStatuses(repo1, sha1, 0)
  14. assert.NoError(t, err)
  15. if assert.Len(t, statuses, 5) {
  16. assert.Equal(t, statuses[0].Context, "ci/awesomeness")
  17. assert.Equal(t, statuses[0].State, CommitStatusPending)
  18. assert.Equal(t, statuses[1].Context, "cov/awesomeness")
  19. assert.Equal(t, statuses[1].State, CommitStatusWarning)
  20. assert.Equal(t, statuses[2].Context, "cov/awesomeness")
  21. assert.Equal(t, statuses[2].State, CommitStatusSuccess)
  22. assert.Equal(t, statuses[3].Context, "ci/awesomeness")
  23. assert.Equal(t, statuses[3].State, CommitStatusFailure)
  24. assert.Equal(t, statuses[4].Context, "deploy/awesomeness")
  25. assert.Equal(t, statuses[4].State, CommitStatusError)
  26. }
  27. }