本站源代码
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.

45 lines
1.8KB

  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, maxResults, err := GetCommitStatuses(repo1, sha1, &CommitStatusOptions{})
  14. assert.NoError(t, err)
  15. assert.Equal(t, int(maxResults), 5)
  16. assert.Len(t, statuses, 5)
  17. assert.Equal(t, "ci/awesomeness", statuses[0].Context)
  18. assert.Equal(t, CommitStatusPending, statuses[0].State)
  19. assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/statuses/1234123412341234123412341234123412341234", statuses[0].APIURL())
  20. assert.Equal(t, "cov/awesomeness", statuses[1].Context)
  21. assert.Equal(t, CommitStatusWarning, statuses[1].State)
  22. assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/statuses/1234123412341234123412341234123412341234", statuses[1].APIURL())
  23. assert.Equal(t, "cov/awesomeness", statuses[2].Context)
  24. assert.Equal(t, CommitStatusSuccess, statuses[2].State)
  25. assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/statuses/1234123412341234123412341234123412341234", statuses[2].APIURL())
  26. assert.Equal(t, "ci/awesomeness", statuses[3].Context)
  27. assert.Equal(t, CommitStatusFailure, statuses[3].State)
  28. assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/statuses/1234123412341234123412341234123412341234", statuses[3].APIURL())
  29. assert.Equal(t, "deploy/awesomeness", statuses[4].Context)
  30. assert.Equal(t, CommitStatusError, statuses[4].State)
  31. assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/statuses/1234123412341234123412341234123412341234", statuses[4].APIURL())
  32. }
上海开阖软件有限公司 沪ICP备12045867号-1