* Move access and repo permission to models/perm/access * fix test * Move some git related files into sub package models/git * Fix build * fix git test * move lfs to sub package * move more git related functions to models/git * Move functions sequence * Some improvements per @KN4CK3R and @delvh
Showing the changes to models/git/commit_status_test.go (1 of 67 files). Show all
Unified · Split
| @@ -0,0 +1,50 @@ | |||
| 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 | package git_test | ||
| 6 | |||
| 7 | import ( | ||
| 8 | "testing" | ||
| 9 | |||
| 10 | "code.gitea.io/gitea/models/db" | ||
| 11 | git_model "code.gitea.io/gitea/models/git" | ||
| 12 | repo_model "code.gitea.io/gitea/models/repo" | ||
| 13 | "code.gitea.io/gitea/models/unittest" | ||
| 14 | "code.gitea.io/gitea/modules/structs" | ||
| 15 | |||
| 16 | "github.com/stretchr/testify/assert" | ||
| 17 | ) | ||
| 18 | |||
| 19 | func TestGetCommitStatuses(t *testing.T) { | ||
| 20 | assert.NoError(t, unittest.PrepareTestDatabase()) | ||
| 21 | |||
| 22 | repo1 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}).(*repo_model.Repository) | ||
| 23 | |||
| 24 | sha1 := "1234123412341234123412341234123412341234" | ||
| 25 | |||
| 26 | statuses, maxResults, err := git_model.GetCommitStatuses(repo1, sha1, &git_model.CommitStatusOptions{ListOptions: db.ListOptions{Page: 1, PageSize: 50}}) | ||
| 27 | assert.NoError(t, err) | ||
| 28 | assert.Equal(t, int(maxResults), 5) | ||
| 29 | assert.Len(t, statuses, 5) | ||
| 30 | |||
| 31 | assert.Equal(t, "ci/awesomeness", statuses[0].Context) | ||
| 32 | assert.Equal(t, structs.CommitStatusPending, statuses[0].State) | ||
| 33 | assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/statuses/1234123412341234123412341234123412341234", statuses[0].APIURL()) | ||
| 34 | |||
| 35 | assert.Equal(t, "cov/awesomeness", statuses[1].Context) | ||
| 36 | assert.Equal(t, structs.CommitStatusWarning, statuses[1].State) | ||
| 37 | assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/statuses/1234123412341234123412341234123412341234", statuses[1].APIURL()) | ||
| 38 | |||
| 39 | assert.Equal(t, "cov/awesomeness", statuses[2].Context) | ||
| 40 | assert.Equal(t, structs.CommitStatusSuccess, statuses[2].State) | ||
| 41 | assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/statuses/1234123412341234123412341234123412341234", statuses[2].APIURL()) | ||
| 42 | |||
| 43 | assert.Equal(t, "ci/awesomeness", statuses[3].Context) | ||
| 44 | assert.Equal(t, structs.CommitStatusFailure, statuses[3].State) | ||
| 45 | assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/statuses/1234123412341234123412341234123412341234", statuses[3].APIURL()) | ||
| 46 | |||
| 47 | assert.Equal(t, "deploy/awesomeness", statuses[4].Context) | ||
| 48 | assert.Equal(t, structs.CommitStatusError, statuses[4].State) | ||
| 49 | assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/statuses/1234123412341234123412341234123412341234", statuses[4].APIURL()) | ||
| 50 | } | ||