You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.1 KiB

  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.Equal(t, 5, len(statuses), "Expected to get 5 statuses") {
  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. }