mirror of
https://github.com/go-gitea/gitea.git
synced 2024-11-22 06:26:43 +08:00
Use more specific test methods (#24265)
Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Giteabot <teabot@gitea.io>
This commit is contained in:
parent
ac384c4e1d
commit
f1173d6879
|
@ -67,7 +67,7 @@ func TestMigratePackages(t *testing.T) {
|
||||||
|
|
||||||
entries, err := os.ReadDir(p)
|
entries, err := os.ReadDir(p)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.EqualValues(t, 2, len(entries))
|
assert.Len(t, entries, 2)
|
||||||
assert.EqualValues(t, "01", entries[0].Name())
|
assert.EqualValues(t, "01", entries[0].Name())
|
||||||
assert.EqualValues(t, "tmp", entries[1].Name())
|
assert.EqualValues(t, "tmp", entries[1].Name())
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ func TestFind(t *testing.T) {
|
||||||
var repoUnits []repo_model.RepoUnit
|
var repoUnits []repo_model.RepoUnit
|
||||||
err = db.Find(db.DefaultContext, &opts, &repoUnits)
|
err = db.Find(db.DefaultContext, &opts, &repoUnits)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.EqualValues(t, repoUnitCount, len(repoUnits))
|
assert.Len(t, repoUnits, repoUnitCount)
|
||||||
|
|
||||||
cnt, err := db.Count(db.DefaultContext, &opts, new(repo_model.RepoUnit))
|
cnt, err := db.Count(db.DefaultContext, &opts, new(repo_model.RepoUnit))
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
|
@ -88,12 +88,12 @@ func TestFindRenamedBranch(t *testing.T) {
|
||||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||||
branch, exist, err := git_model.FindRenamedBranch(db.DefaultContext, 1, "dev")
|
branch, exist, err := git_model.FindRenamedBranch(db.DefaultContext, 1, "dev")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, true, exist)
|
assert.True(t, exist)
|
||||||
assert.Equal(t, "master", branch.To)
|
assert.Equal(t, "master", branch.To)
|
||||||
|
|
||||||
_, exist, err = git_model.FindRenamedBranch(db.DefaultContext, 1, "unknow")
|
_, exist, err = git_model.FindRenamedBranch(db.DefaultContext, 1, "unknow")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, false, exist)
|
assert.False(t, exist)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRenameBranch(t *testing.T) {
|
func TestRenameBranch(t *testing.T) {
|
||||||
|
@ -115,7 +115,7 @@ func TestRenameBranch(t *testing.T) {
|
||||||
return nil
|
return nil
|
||||||
}))
|
}))
|
||||||
|
|
||||||
assert.Equal(t, true, _isDefault)
|
assert.True(t, _isDefault)
|
||||||
repo1 = unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
|
repo1 = unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
|
||||||
assert.Equal(t, "main", repo1.DefaultBranch)
|
assert.Equal(t, "main", repo1.DefaultBranch)
|
||||||
|
|
||||||
|
|
|
@ -109,11 +109,11 @@ func TestHasUnmergedPullRequestsByHeadInfo(t *testing.T) {
|
||||||
|
|
||||||
exist, err := issues_model.HasUnmergedPullRequestsByHeadInfo(db.DefaultContext, 1, "branch2")
|
exist, err := issues_model.HasUnmergedPullRequestsByHeadInfo(db.DefaultContext, 1, "branch2")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, true, exist)
|
assert.True(t, exist)
|
||||||
|
|
||||||
exist, err = issues_model.HasUnmergedPullRequestsByHeadInfo(db.DefaultContext, 1, "not_exist_branch")
|
exist, err = issues_model.HasUnmergedPullRequestsByHeadInfo(db.DefaultContext, 1, "not_exist_branch")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, false, exist)
|
assert.False(t, exist)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetUnmergedPullRequestsByHeadInfo(t *testing.T) {
|
func TestGetUnmergedPullRequestsByHeadInfo(t *testing.T) {
|
||||||
|
|
|
@ -35,7 +35,7 @@ func TestAddTime(t *testing.T) {
|
||||||
assert.Equal(t, int64(3661), tt.Time)
|
assert.Equal(t, int64(3661), tt.Time)
|
||||||
|
|
||||||
comment := unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{Type: issues_model.CommentTypeAddTimeManual, PosterID: 3, IssueID: 1})
|
comment := unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{Type: issues_model.CommentTypeAddTimeManual, PosterID: 3, IssueID: 1})
|
||||||
assert.Equal(t, comment.Content, "1 hour 1 minute")
|
assert.Equal(t, "1 hour 1 minute", comment.Content)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetTrackedTimes(t *testing.T) {
|
func TestGetTrackedTimes(t *testing.T) {
|
||||||
|
|
|
@ -152,7 +152,7 @@ func init() {
|
||||||
Query()
|
Query()
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
assert.EqualValues(t, label.int("NumIssues"), len(issueLabels), "Unexpected number of issue for label id: %d", label.int("ID"))
|
assert.Len(t, issueLabels, label.int("NumIssues"), "Unexpected number of issue for label id: %d", label.int("ID"))
|
||||||
|
|
||||||
issueIDs := make([]int, len(issueLabels))
|
issueIDs := make([]int, len(issueLabels))
|
||||||
for i, issueLabel := range issueLabels {
|
for i, issueLabel := range issueLabels {
|
||||||
|
|
|
@ -36,10 +36,10 @@ func TestGetUserEmailsByNames(t *testing.T) {
|
||||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||||
|
|
||||||
// ignore none active user email
|
// ignore none active user email
|
||||||
assert.Equal(t, []string{"user8@example.com"}, user_model.GetUserEmailsByNames(db.DefaultContext, []string{"user8", "user9"}))
|
assert.ElementsMatch(t, []string{"user8@example.com"}, user_model.GetUserEmailsByNames(db.DefaultContext, []string{"user8", "user9"}))
|
||||||
assert.Equal(t, []string{"user8@example.com", "user5@example.com"}, user_model.GetUserEmailsByNames(db.DefaultContext, []string{"user8", "user5"}))
|
assert.ElementsMatch(t, []string{"user8@example.com", "user5@example.com"}, user_model.GetUserEmailsByNames(db.DefaultContext, []string{"user8", "user5"}))
|
||||||
|
|
||||||
assert.Equal(t, []string{"user8@example.com"}, user_model.GetUserEmailsByNames(db.DefaultContext, []string{"user8", "user7"}))
|
assert.ElementsMatch(t, []string{"user8@example.com"}, user_model.GetUserEmailsByNames(db.DefaultContext, []string{"user8", "user7"}))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCanCreateOrganization(t *testing.T) {
|
func TestCanCreateOrganization(t *testing.T) {
|
||||||
|
|
|
@ -19,7 +19,7 @@ func Test_nulSeparatedAttributeWriter_ReadAttribute(t *testing.T) {
|
||||||
|
|
||||||
n, err := wr.Write([]byte(testStr))
|
n, err := wr.Write([]byte(testStr))
|
||||||
|
|
||||||
assert.Equal(t, n, len(testStr))
|
assert.Len(t, testStr, n)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
select {
|
select {
|
||||||
case attr := <-wr.ReadAttribute():
|
case attr := <-wr.ReadAttribute():
|
||||||
|
@ -32,7 +32,7 @@ func Test_nulSeparatedAttributeWriter_ReadAttribute(t *testing.T) {
|
||||||
// Write a second attribute again
|
// Write a second attribute again
|
||||||
n, err = wr.Write([]byte(testStr))
|
n, err = wr.Write([]byte(testStr))
|
||||||
|
|
||||||
assert.Equal(t, n, len(testStr))
|
assert.Len(t, testStr, n)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
select {
|
select {
|
||||||
|
|
|
@ -97,6 +97,6 @@ func TestRepository_CommitsBetweenIDs(t *testing.T) {
|
||||||
for i, c := range cases {
|
for i, c := range cases {
|
||||||
commits, err := bareRepo1.CommitsBetweenIDs(c.NewID, c.OldID)
|
commits, err := bareRepo1.CommitsBetweenIDs(c.NewID, c.OldID)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, c.ExpectedCommits, len(commits), "case %d", i)
|
assert.Len(t, commits, c.ExpectedCommits, "case %d", i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ func TestRepository_GetTags(t *testing.T) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
assert.Len(t, tags, 2)
|
assert.Len(t, tags, 2)
|
||||||
assert.Equal(t, len(tags), total)
|
assert.Len(t, tags, total)
|
||||||
assert.EqualValues(t, "signed-tag", tags[0].Name)
|
assert.EqualValues(t, "signed-tag", tags[0].Name)
|
||||||
assert.EqualValues(t, "36f97d9a96457e2bab511db30fe2db03893ebc64", tags[0].ID.String())
|
assert.EqualValues(t, "36f97d9a96457e2bab511db30fe2db03893ebc64", tags[0].ID.String())
|
||||||
assert.EqualValues(t, "tag", tags[0].Type)
|
assert.EqualValues(t, "tag", tags[0].Type)
|
||||||
|
|
|
@ -69,7 +69,7 @@ func testIndexer(name string, t *testing.T, indexer Indexer) {
|
||||||
t.Run(kw.Keyword, func(t *testing.T) {
|
t.Run(kw.Keyword, func(t *testing.T) {
|
||||||
total, res, langs, err := indexer.Search(context.TODO(), kw.RepoIDs, "", kw.Keyword, 1, 10, false)
|
total, res, langs, err := indexer.Search(context.TODO(), kw.RepoIDs, "", kw.Keyword, 1, 10, false)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.EqualValues(t, len(kw.IDs), total)
|
assert.Len(t, kw.IDs, int(total))
|
||||||
assert.Len(t, langs, kw.Langs)
|
assert.Len(t, langs, kw.Langs)
|
||||||
|
|
||||||
ids := make([]int64, 0, len(res))
|
ids := make([]int64, 0, len(res))
|
||||||
|
|
|
@ -162,7 +162,7 @@ func TestHTTPClientDownload(t *testing.T) {
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
assert.Equal(t, "download", batchRequest.Operation)
|
assert.Equal(t, "download", batchRequest.Operation)
|
||||||
assert.Equal(t, 1, len(batchRequest.Objects))
|
assert.Len(t, batchRequest.Objects, 1)
|
||||||
assert.Equal(t, p.Oid, batchRequest.Objects[0].Oid)
|
assert.Equal(t, p.Oid, batchRequest.Objects[0].Oid)
|
||||||
assert.Equal(t, p.Size, batchRequest.Objects[0].Size)
|
assert.Equal(t, p.Size, batchRequest.Objects[0].Size)
|
||||||
|
|
||||||
|
@ -269,7 +269,7 @@ func TestHTTPClientUpload(t *testing.T) {
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
assert.Equal(t, "upload", batchRequest.Operation)
|
assert.Equal(t, "upload", batchRequest.Operation)
|
||||||
assert.Equal(t, 1, len(batchRequest.Objects))
|
assert.Len(t, batchRequest.Objects, 1)
|
||||||
assert.Equal(t, p.Oid, batchRequest.Objects[0].Oid)
|
assert.Equal(t, p.Oid, batchRequest.Objects[0].Oid)
|
||||||
assert.Equal(t, p.Size, batchRequest.Objects[0].Size)
|
assert.Equal(t, p.Size, batchRequest.Objects[0].Size)
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ func TestFileLogger(t *testing.T) {
|
||||||
|
|
||||||
fileLogger := NewFileLogger()
|
fileLogger := NewFileLogger()
|
||||||
realFileLogger, ok := fileLogger.(*FileLogger)
|
realFileLogger, ok := fileLogger.(*FileLogger)
|
||||||
assert.Equal(t, true, ok)
|
assert.True(t, ok)
|
||||||
|
|
||||||
location, _ := time.LoadLocation("EST")
|
location, _ := time.LoadLocation("EST")
|
||||||
|
|
||||||
|
|
|
@ -593,5 +593,5 @@ func TestIssue18471(t *testing.T) {
|
||||||
}, strings.NewReader(data), &res)
|
}, strings.NewReader(data), &res)
|
||||||
|
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, res.String(), "<a href=\"http://domain/org/repo/compare/783b039...da951ce\" class=\"compare\"><code class=\"nohighlight\">783b039...da951ce</code></a>")
|
assert.Equal(t, "<a href=\"http://domain/org/repo/compare/783b039...da951ce\" class=\"compare\"><code class=\"nohighlight\">783b039...da951ce</code></a>", res.String())
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ func TestParseImageConfig(t *testing.T) {
|
||||||
assert.Equal(t, projectURL, metadata.ProjectURL)
|
assert.Equal(t, projectURL, metadata.ProjectURL)
|
||||||
assert.Equal(t, repositoryURL, metadata.RepositoryURL)
|
assert.Equal(t, repositoryURL, metadata.RepositoryURL)
|
||||||
assert.Equal(t, documentationURL, metadata.DocumentationURL)
|
assert.Equal(t, documentationURL, metadata.DocumentationURL)
|
||||||
assert.Equal(t, []string{"do it 1", "do it 2"}, metadata.ImageLayers)
|
assert.ElementsMatch(t, []string{"do it 1", "do it 2"}, metadata.ImageLayers)
|
||||||
assert.Equal(
|
assert.Equal(
|
||||||
t,
|
t,
|
||||||
map[string]string{
|
map[string]string{
|
||||||
|
|
|
@ -70,19 +70,19 @@ func TestPaginator(t *testing.T) {
|
||||||
t.Run("Generate pages", func(t *testing.T) {
|
t.Run("Generate pages", func(t *testing.T) {
|
||||||
p := New(0, 10, 1, 0)
|
p := New(0, 10, 1, 0)
|
||||||
pages := p.Pages()
|
pages := p.Pages()
|
||||||
assert.Equal(t, 0, len(pages))
|
assert.Empty(t, pages)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("Only current page", func(t *testing.T) {
|
t.Run("Only current page", func(t *testing.T) {
|
||||||
p := New(0, 10, 1, 1)
|
p := New(0, 10, 1, 1)
|
||||||
pages := p.Pages()
|
pages := p.Pages()
|
||||||
assert.Equal(t, 1, len(pages))
|
assert.Len(t, pages, 1)
|
||||||
assert.Equal(t, 1, pages[0].Num())
|
assert.Equal(t, 1, pages[0].Num())
|
||||||
assert.True(t, pages[0].IsCurrent())
|
assert.True(t, pages[0].IsCurrent())
|
||||||
|
|
||||||
p = New(1, 10, 1, 1)
|
p = New(1, 10, 1, 1)
|
||||||
pages = p.Pages()
|
pages = p.Pages()
|
||||||
assert.Equal(t, 1, len(pages))
|
assert.Len(t, pages, 1)
|
||||||
assert.Equal(t, 1, pages[0].Num())
|
assert.Equal(t, 1, pages[0].Num())
|
||||||
assert.True(t, pages[0].IsCurrent())
|
assert.True(t, pages[0].IsCurrent())
|
||||||
})
|
})
|
||||||
|
@ -90,13 +90,13 @@ func TestPaginator(t *testing.T) {
|
||||||
t.Run("Total page number is less or equal", func(t *testing.T) {
|
t.Run("Total page number is less or equal", func(t *testing.T) {
|
||||||
p := New(1, 10, 1, 2)
|
p := New(1, 10, 1, 2)
|
||||||
pages := p.Pages()
|
pages := p.Pages()
|
||||||
assert.Equal(t, 1, len(pages))
|
assert.Len(t, pages, 1)
|
||||||
assert.Equal(t, 1, pages[0].Num())
|
assert.Equal(t, 1, pages[0].Num())
|
||||||
assert.True(t, pages[0].IsCurrent())
|
assert.True(t, pages[0].IsCurrent())
|
||||||
|
|
||||||
p = New(11, 10, 1, 2)
|
p = New(11, 10, 1, 2)
|
||||||
pages = p.Pages()
|
pages = p.Pages()
|
||||||
assert.Equal(t, 2, len(pages))
|
assert.Len(t, pages, 2)
|
||||||
assert.Equal(t, 1, pages[0].Num())
|
assert.Equal(t, 1, pages[0].Num())
|
||||||
assert.True(t, pages[0].IsCurrent())
|
assert.True(t, pages[0].IsCurrent())
|
||||||
assert.Equal(t, 2, pages[1].Num())
|
assert.Equal(t, 2, pages[1].Num())
|
||||||
|
@ -104,7 +104,7 @@ func TestPaginator(t *testing.T) {
|
||||||
|
|
||||||
p = New(11, 10, 2, 2)
|
p = New(11, 10, 2, 2)
|
||||||
pages = p.Pages()
|
pages = p.Pages()
|
||||||
assert.Equal(t, 2, len(pages))
|
assert.Len(t, pages, 2)
|
||||||
assert.Equal(t, 1, pages[0].Num())
|
assert.Equal(t, 1, pages[0].Num())
|
||||||
assert.False(t, pages[0].IsCurrent())
|
assert.False(t, pages[0].IsCurrent())
|
||||||
assert.Equal(t, 2, pages[1].Num())
|
assert.Equal(t, 2, pages[1].Num())
|
||||||
|
@ -112,7 +112,7 @@ func TestPaginator(t *testing.T) {
|
||||||
|
|
||||||
p = New(25, 10, 2, 3)
|
p = New(25, 10, 2, 3)
|
||||||
pages = p.Pages()
|
pages = p.Pages()
|
||||||
assert.Equal(t, 3, len(pages))
|
assert.Len(t, pages, 3)
|
||||||
assert.Equal(t, 1, pages[0].Num())
|
assert.Equal(t, 1, pages[0].Num())
|
||||||
assert.False(t, pages[0].IsCurrent())
|
assert.False(t, pages[0].IsCurrent())
|
||||||
assert.Equal(t, 2, pages[1].Num())
|
assert.Equal(t, 2, pages[1].Num())
|
||||||
|
@ -125,7 +125,7 @@ func TestPaginator(t *testing.T) {
|
||||||
// ... 2
|
// ... 2
|
||||||
p := New(11, 10, 2, 1)
|
p := New(11, 10, 2, 1)
|
||||||
pages := p.Pages()
|
pages := p.Pages()
|
||||||
assert.Equal(t, 2, len(pages))
|
assert.Len(t, pages, 2)
|
||||||
assert.Equal(t, -1, pages[0].Num())
|
assert.Equal(t, -1, pages[0].Num())
|
||||||
assert.False(t, pages[0].IsCurrent())
|
assert.False(t, pages[0].IsCurrent())
|
||||||
assert.Equal(t, 2, pages[1].Num())
|
assert.Equal(t, 2, pages[1].Num())
|
||||||
|
@ -134,7 +134,7 @@ func TestPaginator(t *testing.T) {
|
||||||
// ... 2 3
|
// ... 2 3
|
||||||
p = New(21, 10, 2, 2)
|
p = New(21, 10, 2, 2)
|
||||||
pages = p.Pages()
|
pages = p.Pages()
|
||||||
assert.Equal(t, 3, len(pages))
|
assert.Len(t, pages, 3)
|
||||||
assert.Equal(t, -1, pages[0].Num())
|
assert.Equal(t, -1, pages[0].Num())
|
||||||
assert.False(t, pages[0].IsCurrent())
|
assert.False(t, pages[0].IsCurrent())
|
||||||
assert.Equal(t, 2, pages[1].Num())
|
assert.Equal(t, 2, pages[1].Num())
|
||||||
|
@ -145,7 +145,7 @@ func TestPaginator(t *testing.T) {
|
||||||
// ... 2 3 4
|
// ... 2 3 4
|
||||||
p = New(31, 10, 3, 3)
|
p = New(31, 10, 3, 3)
|
||||||
pages = p.Pages()
|
pages = p.Pages()
|
||||||
assert.Equal(t, 4, len(pages))
|
assert.Len(t, pages, 4)
|
||||||
assert.Equal(t, -1, pages[0].Num())
|
assert.Equal(t, -1, pages[0].Num())
|
||||||
assert.False(t, pages[0].IsCurrent())
|
assert.False(t, pages[0].IsCurrent())
|
||||||
assert.Equal(t, 2, pages[1].Num())
|
assert.Equal(t, 2, pages[1].Num())
|
||||||
|
@ -158,7 +158,7 @@ func TestPaginator(t *testing.T) {
|
||||||
// ... 3 4 5
|
// ... 3 4 5
|
||||||
p = New(41, 10, 4, 3)
|
p = New(41, 10, 4, 3)
|
||||||
pages = p.Pages()
|
pages = p.Pages()
|
||||||
assert.Equal(t, 4, len(pages))
|
assert.Len(t, pages, 4)
|
||||||
assert.Equal(t, -1, pages[0].Num())
|
assert.Equal(t, -1, pages[0].Num())
|
||||||
assert.False(t, pages[0].IsCurrent())
|
assert.False(t, pages[0].IsCurrent())
|
||||||
assert.Equal(t, 3, pages[1].Num())
|
assert.Equal(t, 3, pages[1].Num())
|
||||||
|
@ -171,7 +171,7 @@ func TestPaginator(t *testing.T) {
|
||||||
// ... 4 5 6 7 8 9 10
|
// ... 4 5 6 7 8 9 10
|
||||||
p = New(100, 10, 9, 7)
|
p = New(100, 10, 9, 7)
|
||||||
pages = p.Pages()
|
pages = p.Pages()
|
||||||
assert.Equal(t, 8, len(pages))
|
assert.Len(t, pages, 8)
|
||||||
assert.Equal(t, -1, pages[0].Num())
|
assert.Equal(t, -1, pages[0].Num())
|
||||||
assert.False(t, pages[0].IsCurrent())
|
assert.False(t, pages[0].IsCurrent())
|
||||||
assert.Equal(t, 4, pages[1].Num())
|
assert.Equal(t, 4, pages[1].Num())
|
||||||
|
@ -194,7 +194,7 @@ func TestPaginator(t *testing.T) {
|
||||||
// 1 ...
|
// 1 ...
|
||||||
p := New(21, 10, 1, 1)
|
p := New(21, 10, 1, 1)
|
||||||
pages := p.Pages()
|
pages := p.Pages()
|
||||||
assert.Equal(t, 2, len(pages))
|
assert.Len(t, pages, 2)
|
||||||
assert.Equal(t, 1, pages[0].Num())
|
assert.Equal(t, 1, pages[0].Num())
|
||||||
assert.True(t, pages[0].IsCurrent())
|
assert.True(t, pages[0].IsCurrent())
|
||||||
assert.Equal(t, -1, pages[1].Num())
|
assert.Equal(t, -1, pages[1].Num())
|
||||||
|
@ -203,7 +203,7 @@ func TestPaginator(t *testing.T) {
|
||||||
// 1 2 ...
|
// 1 2 ...
|
||||||
p = New(21, 10, 1, 2)
|
p = New(21, 10, 1, 2)
|
||||||
pages = p.Pages()
|
pages = p.Pages()
|
||||||
assert.Equal(t, 3, len(pages))
|
assert.Len(t, pages, 3)
|
||||||
assert.Equal(t, 1, pages[0].Num())
|
assert.Equal(t, 1, pages[0].Num())
|
||||||
assert.True(t, pages[0].IsCurrent())
|
assert.True(t, pages[0].IsCurrent())
|
||||||
assert.Equal(t, 2, pages[1].Num())
|
assert.Equal(t, 2, pages[1].Num())
|
||||||
|
@ -214,7 +214,7 @@ func TestPaginator(t *testing.T) {
|
||||||
// 1 2 3 ...
|
// 1 2 3 ...
|
||||||
p = New(31, 10, 2, 3)
|
p = New(31, 10, 2, 3)
|
||||||
pages = p.Pages()
|
pages = p.Pages()
|
||||||
assert.Equal(t, 4, len(pages))
|
assert.Len(t, pages, 4)
|
||||||
assert.Equal(t, 1, pages[0].Num())
|
assert.Equal(t, 1, pages[0].Num())
|
||||||
assert.False(t, pages[0].IsCurrent())
|
assert.False(t, pages[0].IsCurrent())
|
||||||
assert.Equal(t, 2, pages[1].Num())
|
assert.Equal(t, 2, pages[1].Num())
|
||||||
|
@ -227,7 +227,7 @@ func TestPaginator(t *testing.T) {
|
||||||
// 1 2 3 ...
|
// 1 2 3 ...
|
||||||
p = New(41, 10, 2, 3)
|
p = New(41, 10, 2, 3)
|
||||||
pages = p.Pages()
|
pages = p.Pages()
|
||||||
assert.Equal(t, 4, len(pages))
|
assert.Len(t, pages, 4)
|
||||||
assert.Equal(t, 1, pages[0].Num())
|
assert.Equal(t, 1, pages[0].Num())
|
||||||
assert.False(t, pages[0].IsCurrent())
|
assert.False(t, pages[0].IsCurrent())
|
||||||
assert.Equal(t, 2, pages[1].Num())
|
assert.Equal(t, 2, pages[1].Num())
|
||||||
|
@ -240,7 +240,7 @@ func TestPaginator(t *testing.T) {
|
||||||
// 1 2 3 4 5 6 7 ...
|
// 1 2 3 4 5 6 7 ...
|
||||||
p = New(100, 10, 1, 7)
|
p = New(100, 10, 1, 7)
|
||||||
pages = p.Pages()
|
pages = p.Pages()
|
||||||
assert.Equal(t, 8, len(pages))
|
assert.Len(t, pages, 8)
|
||||||
assert.Equal(t, 1, pages[0].Num())
|
assert.Equal(t, 1, pages[0].Num())
|
||||||
assert.True(t, pages[0].IsCurrent())
|
assert.True(t, pages[0].IsCurrent())
|
||||||
assert.Equal(t, 2, pages[1].Num())
|
assert.Equal(t, 2, pages[1].Num())
|
||||||
|
@ -261,7 +261,7 @@ func TestPaginator(t *testing.T) {
|
||||||
// 1 2 3 4 5 6 7 ...
|
// 1 2 3 4 5 6 7 ...
|
||||||
p = New(100, 10, 2, 7)
|
p = New(100, 10, 2, 7)
|
||||||
pages = p.Pages()
|
pages = p.Pages()
|
||||||
assert.Equal(t, 8, len(pages))
|
assert.Len(t, pages, 8)
|
||||||
assert.Equal(t, 1, pages[0].Num())
|
assert.Equal(t, 1, pages[0].Num())
|
||||||
assert.False(t, pages[0].IsCurrent())
|
assert.False(t, pages[0].IsCurrent())
|
||||||
assert.Equal(t, 2, pages[1].Num())
|
assert.Equal(t, 2, pages[1].Num())
|
||||||
|
@ -284,7 +284,7 @@ func TestPaginator(t *testing.T) {
|
||||||
// ... 2 3 ...
|
// ... 2 3 ...
|
||||||
p := New(35, 10, 2, 2)
|
p := New(35, 10, 2, 2)
|
||||||
pages := p.Pages()
|
pages := p.Pages()
|
||||||
assert.Equal(t, 4, len(pages))
|
assert.Len(t, pages, 4)
|
||||||
assert.Equal(t, -1, pages[0].Num())
|
assert.Equal(t, -1, pages[0].Num())
|
||||||
assert.False(t, pages[0].IsCurrent())
|
assert.False(t, pages[0].IsCurrent())
|
||||||
assert.Equal(t, 2, pages[1].Num())
|
assert.Equal(t, 2, pages[1].Num())
|
||||||
|
@ -297,7 +297,7 @@ func TestPaginator(t *testing.T) {
|
||||||
// ... 2 3 4 ...
|
// ... 2 3 4 ...
|
||||||
p = New(49, 10, 3, 3)
|
p = New(49, 10, 3, 3)
|
||||||
pages = p.Pages()
|
pages = p.Pages()
|
||||||
assert.Equal(t, 5, len(pages))
|
assert.Len(t, pages, 5)
|
||||||
assert.Equal(t, -1, pages[0].Num())
|
assert.Equal(t, -1, pages[0].Num())
|
||||||
assert.False(t, pages[0].IsCurrent())
|
assert.False(t, pages[0].IsCurrent())
|
||||||
assert.Equal(t, 2, pages[1].Num())
|
assert.Equal(t, 2, pages[1].Num())
|
||||||
|
|
|
@ -208,7 +208,7 @@ func TestPersistableChannelUniqueQueue(t *testing.T) {
|
||||||
|
|
||||||
mapLock.Lock()
|
mapLock.Lock()
|
||||||
assert.Equal(t, 101, len(executedInitial[name])+len(executedEmpty[name]))
|
assert.Equal(t, 101, len(executedInitial[name])+len(executedEmpty[name]))
|
||||||
assert.Equal(t, 0, len(hasEmpty[name]))
|
assert.Empty(t, hasEmpty[name])
|
||||||
mapLock.Unlock()
|
mapLock.Unlock()
|
||||||
})
|
})
|
||||||
close(done)
|
close(done)
|
||||||
|
|
|
@ -15,9 +15,9 @@ func TestEncryptDecrypt(t *testing.T) {
|
||||||
|
|
||||||
hex, _ = EncryptSecret("foo", "baz")
|
hex, _ = EncryptSecret("foo", "baz")
|
||||||
str, _ = DecryptSecret("foo", hex)
|
str, _ = DecryptSecret("foo", hex)
|
||||||
assert.Equal(t, str, "baz")
|
assert.Equal(t, "baz", str)
|
||||||
|
|
||||||
hex, _ = EncryptSecret("bar", "baz")
|
hex, _ = EncryptSecret("bar", "baz")
|
||||||
str, _ = DecryptSecret("foo", hex)
|
str, _ = DecryptSecret("foo", hex)
|
||||||
assert.NotEqual(t, str, "baz")
|
assert.NotEqual(t, "baz", str)
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,6 +89,6 @@ func TestLocalStorageIterator(t *testing.T) {
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, count, len(expected))
|
assert.Len(t, expected, count)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,26 +22,26 @@ func TestLogChecker(t *testing.T) {
|
||||||
log.Info("test")
|
log.Info("test")
|
||||||
|
|
||||||
filtered, stopped := lc.Check(100 * time.Millisecond)
|
filtered, stopped := lc.Check(100 * time.Millisecond)
|
||||||
assert.EqualValues(t, []bool{false, false}, filtered)
|
assert.ElementsMatch(t, []bool{false, false}, filtered)
|
||||||
assert.EqualValues(t, false, stopped)
|
assert.False(t, stopped)
|
||||||
|
|
||||||
log.Info("First")
|
log.Info("First")
|
||||||
filtered, stopped = lc.Check(100 * time.Millisecond)
|
filtered, stopped = lc.Check(100 * time.Millisecond)
|
||||||
assert.EqualValues(t, []bool{true, false}, filtered)
|
assert.ElementsMatch(t, []bool{true, false}, filtered)
|
||||||
assert.EqualValues(t, false, stopped)
|
assert.False(t, stopped)
|
||||||
|
|
||||||
log.Info("Second")
|
log.Info("Second")
|
||||||
filtered, stopped = lc.Check(100 * time.Millisecond)
|
filtered, stopped = lc.Check(100 * time.Millisecond)
|
||||||
assert.EqualValues(t, []bool{true, false}, filtered)
|
assert.ElementsMatch(t, []bool{true, false}, filtered)
|
||||||
assert.EqualValues(t, false, stopped)
|
assert.False(t, stopped)
|
||||||
|
|
||||||
log.Info("Third")
|
log.Info("Third")
|
||||||
filtered, stopped = lc.Check(100 * time.Millisecond)
|
filtered, stopped = lc.Check(100 * time.Millisecond)
|
||||||
assert.EqualValues(t, []bool{true, true}, filtered)
|
assert.ElementsMatch(t, []bool{true, true}, filtered)
|
||||||
assert.EqualValues(t, false, stopped)
|
assert.False(t, stopped)
|
||||||
|
|
||||||
log.Info("End")
|
log.Info("End")
|
||||||
filtered, stopped = lc.Check(100 * time.Millisecond)
|
filtered, stopped = lc.Check(100 * time.Millisecond)
|
||||||
assert.EqualValues(t, []bool{true, true}, filtered)
|
assert.ElementsMatch(t, []bool{true, true}, filtered)
|
||||||
assert.EqualValues(t, true, stopped)
|
assert.True(t, stopped)
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,8 +51,8 @@ sub = Changed Sub String
|
||||||
assert.Equal(t, `test value; <span style="color: red; background: none;">more text</span>`, result)
|
assert.Equal(t, `test value; <span style="color: red; background: none;">more text</span>`, result)
|
||||||
|
|
||||||
langs, descs := ls.ListLangNameDesc()
|
langs, descs := ls.ListLangNameDesc()
|
||||||
assert.Equal(t, []string{"lang1", "lang2"}, langs)
|
assert.ElementsMatch(t, []string{"lang1", "lang2"}, langs)
|
||||||
assert.Equal(t, []string{"Lang1", "Lang2"}, descs)
|
assert.ElementsMatch(t, []string{"Lang1", "Lang2"}, descs)
|
||||||
|
|
||||||
found := ls.Has("lang1", "no-such")
|
found := ls.Has("lang1", "no-such")
|
||||||
assert.False(t, found)
|
assert.False(t, found)
|
||||||
|
|
|
@ -74,15 +74,15 @@ func TestSliceEqual(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSliceRemoveAll(t *testing.T) {
|
func TestSliceRemoveAll(t *testing.T) {
|
||||||
assert.Equal(t, SliceRemoveAll([]int{2, 0, 2, 3}, 0), []int{2, 2, 3})
|
assert.ElementsMatch(t, []int{2, 2, 3}, SliceRemoveAll([]int{2, 0, 2, 3}, 0))
|
||||||
assert.Equal(t, SliceRemoveAll([]int{2, 0, 2, 3}, 2), []int{0, 3})
|
assert.ElementsMatch(t, []int{0, 3}, SliceRemoveAll([]int{2, 0, 2, 3}, 2))
|
||||||
assert.Equal(t, SliceRemoveAll([]int{0, 0, 0, 0}, 0), []int{})
|
assert.Empty(t, SliceRemoveAll([]int{0, 0, 0, 0}, 0))
|
||||||
assert.Equal(t, SliceRemoveAll([]int{2, 0, 2, 3}, 4), []int{2, 0, 2, 3})
|
assert.ElementsMatch(t, []int{2, 0, 2, 3}, SliceRemoveAll([]int{2, 0, 2, 3}, 4))
|
||||||
assert.Equal(t, SliceRemoveAll([]int{}, 0), []int{})
|
assert.Empty(t, SliceRemoveAll([]int{}, 0))
|
||||||
assert.Equal(t, SliceRemoveAll([]int(nil), 0), []int(nil))
|
assert.ElementsMatch(t, []int(nil), SliceRemoveAll([]int(nil), 0))
|
||||||
assert.Equal(t, SliceRemoveAll([]int{}, 0), []int{})
|
assert.Empty(t, SliceRemoveAll([]int{}, 0))
|
||||||
|
|
||||||
assert.Equal(t, SliceRemoveAll([]string{"2", "0", "2", "3"}, "0"), []string{"2", "2", "3"})
|
assert.ElementsMatch(t, []string{"2", "2", "3"}, SliceRemoveAll([]string{"2", "0", "2", "3"}, "0"))
|
||||||
assert.Equal(t, SliceRemoveAll([]float64{2, 0, 2, 3}, 0), []float64{2, 2, 3})
|
assert.ElementsMatch(t, []float64{2, 2, 3}, SliceRemoveAll([]float64{2, 0, 2, 3}, 0))
|
||||||
assert.Equal(t, SliceRemoveAll([]bool{false, true, false}, true), []bool{false, false})
|
assert.ElementsMatch(t, []bool{false, false}, SliceRemoveAll([]bool{false, true, false}, true))
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ func TestSplitString(t *testing.T) {
|
||||||
assert.Equal(t, c.ellipsis+c.input[len(c.leftSub):], r, "test split %s at %d, expected rightSub: %q", c.input, c.n, c.input[len(c.leftSub):])
|
assert.Equal(t, c.ellipsis+c.input[len(c.leftSub):], r, "test split %s at %d, expected rightSub: %q", c.input, c.n, c.input[len(c.leftSub):])
|
||||||
} else {
|
} else {
|
||||||
assert.Equal(t, c.leftSub, l, "test split %q at %d, expected leftSub: %q", c.input, c.n, c.leftSub)
|
assert.Equal(t, c.leftSub, l, "test split %q at %d, expected leftSub: %q", c.input, c.n, c.leftSub)
|
||||||
assert.Equal(t, "", r, "test split %q at %d, expected rightSub: %q", c.input, c.n, "")
|
assert.Empty(t, r, "test split %q at %d, expected rightSub: %q", c.input, c.n, "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ func TestDeleteNotPassedAssignee(t *testing.T) {
|
||||||
// Fake issue with assignees
|
// Fake issue with assignees
|
||||||
issue, err := issues_model.GetIssueWithAttrsByID(1)
|
issue, err := issues_model.GetIssueWithAttrsByID(1)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.EqualValues(t, 1, len(issue.Assignees))
|
assert.Len(t, issue.Assignees, 1)
|
||||||
|
|
||||||
user1, err := user_model.GetUserByID(db.DefaultContext, 1) // This user is already assigned (see the definition in fixtures), so running UpdateAssignee should unassign him
|
user1, err := user_model.GetUserByID(db.DefaultContext, 1) // This user is already assigned (see the definition in fixtures), so running UpdateAssignee should unassign him
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
@ -33,10 +33,10 @@ func TestDeleteNotPassedAssignee(t *testing.T) {
|
||||||
// Clean everyone
|
// Clean everyone
|
||||||
err = DeleteNotPassedAssignee(db.DefaultContext, issue, user1, []*user_model.User{})
|
err = DeleteNotPassedAssignee(db.DefaultContext, issue, user1, []*user_model.User{})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.EqualValues(t, 0, len(issue.Assignees))
|
assert.Empty(t, issue.Assignees)
|
||||||
|
|
||||||
// Check they're gone
|
// Check they're gone
|
||||||
assert.NoError(t, issue.LoadAssignees(db.DefaultContext))
|
assert.NoError(t, issue.LoadAssignees(db.DefaultContext))
|
||||||
assert.EqualValues(t, 0, len(issue.Assignees))
|
assert.Empty(t, issue.Assignees)
|
||||||
assert.Empty(t, issue.Assignee)
|
assert.Empty(t, issue.Assignee)
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ func TestIssue_DeleteIssue(t *testing.T) {
|
||||||
|
|
||||||
issueIDs, err := issues_model.GetIssueIDsByRepoID(db.DefaultContext, 1)
|
issueIDs, err := issues_model.GetIssueIDsByRepoID(db.DefaultContext, 1)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.EqualValues(t, 5, len(issueIDs))
|
assert.Len(t, issueIDs, 5)
|
||||||
|
|
||||||
issue := &issues_model.Issue{
|
issue := &issues_model.Issue{
|
||||||
RepoID: 1,
|
RepoID: 1,
|
||||||
|
@ -48,7 +48,7 @@ func TestIssue_DeleteIssue(t *testing.T) {
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
issueIDs, err = issues_model.GetIssueIDsByRepoID(db.DefaultContext, 1)
|
issueIDs, err = issues_model.GetIssueIDsByRepoID(db.DefaultContext, 1)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.EqualValues(t, 4, len(issueIDs))
|
assert.Len(t, issueIDs, 4)
|
||||||
|
|
||||||
// check attachment removal
|
// check attachment removal
|
||||||
attachments, err := repo_model.GetAttachmentsByIssueID(db.DefaultContext, 4)
|
attachments, err := repo_model.GetAttachmentsByIssueID(db.DefaultContext, 4)
|
||||||
|
@ -57,7 +57,7 @@ func TestIssue_DeleteIssue(t *testing.T) {
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
err = deleteIssue(db.DefaultContext, issue)
|
err = deleteIssue(db.DefaultContext, issue)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.EqualValues(t, 2, len(attachments))
|
assert.Len(t, attachments, 2)
|
||||||
for i := range attachments {
|
for i := range attachments {
|
||||||
attachment, err := repo_model.GetAttachmentByUUID(db.DefaultContext, attachments[i].UUID)
|
attachment, err := repo_model.GetAttachmentByUUID(db.DefaultContext, attachments[i].UUID)
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
|
|
|
@ -30,7 +30,7 @@ func TestCheckUnadoptedRepositories_Add(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.Equal(t, total, unadopted.index)
|
assert.Equal(t, total, unadopted.index)
|
||||||
assert.Equal(t, end-start, len(unadopted.repositories))
|
assert.Len(t, unadopted.repositories, end-start)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCheckUnadoptedRepositories(t *testing.T) {
|
func TestCheckUnadoptedRepositories(t *testing.T) {
|
||||||
|
@ -41,7 +41,7 @@ func TestCheckUnadoptedRepositories(t *testing.T) {
|
||||||
unadopted := &unadoptedRepositories{start: 0, end: 100}
|
unadopted := &unadoptedRepositories{start: 0, end: 100}
|
||||||
err := checkUnadoptedRepositories(db.DefaultContext, "notauser", []string{"repo"}, unadopted)
|
err := checkUnadoptedRepositories(db.DefaultContext, "notauser", []string{"repo"}, unadopted)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, 0, len(unadopted.repositories))
|
assert.Empty(t, unadopted.repositories)
|
||||||
//
|
//
|
||||||
// Unadopted repository is returned
|
// Unadopted repository is returned
|
||||||
// Existing (adopted) repository is not returned
|
// Existing (adopted) repository is not returned
|
||||||
|
@ -59,7 +59,7 @@ func TestCheckUnadoptedRepositories(t *testing.T) {
|
||||||
unadopted = &unadoptedRepositories{start: 0, end: 100}
|
unadopted = &unadoptedRepositories{start: 0, end: 100}
|
||||||
err = checkUnadoptedRepositories(db.DefaultContext, userName, []string{repoName}, unadopted)
|
err = checkUnadoptedRepositories(db.DefaultContext, userName, []string{repoName}, unadopted)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, 0, len(unadopted.repositories))
|
assert.Empty(t, unadopted.repositories)
|
||||||
assert.Equal(t, 0, unadopted.index)
|
assert.Equal(t, 0, unadopted.index)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,7 @@ func TestAPIListUsers(t *testing.T) {
|
||||||
}
|
}
|
||||||
assert.True(t, found)
|
assert.True(t, found)
|
||||||
numberOfUsers := unittest.GetCount(t, &user_model.User{}, "type = 0")
|
numberOfUsers := unittest.GetCount(t, &user_model.User{}, "type = 0")
|
||||||
assert.Equal(t, numberOfUsers, len(users))
|
assert.Len(t, users, numberOfUsers)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAPIListUsersNotLoggedIn(t *testing.T) {
|
func TestAPIListUsersNotLoggedIn(t *testing.T) {
|
||||||
|
|
|
@ -68,7 +68,7 @@ func TestAPIListCommentAttachments(t *testing.T) {
|
||||||
var apiAttachments []*api.Attachment
|
var apiAttachments []*api.Attachment
|
||||||
DecodeJSON(t, resp, &apiAttachments)
|
DecodeJSON(t, resp, &apiAttachments)
|
||||||
expectedCount := unittest.GetCount(t, &repo_model.Attachment{CommentID: comment.ID})
|
expectedCount := unittest.GetCount(t, &repo_model.Attachment{CommentID: comment.ID})
|
||||||
assert.EqualValues(t, expectedCount, len(apiAttachments))
|
assert.Len(t, apiAttachments, expectedCount)
|
||||||
|
|
||||||
unittest.AssertExistsAndLoadBean(t, &repo_model.Attachment{ID: apiAttachments[0].ID, CommentID: comment.ID})
|
unittest.AssertExistsAndLoadBean(t, &repo_model.Attachment{ID: apiAttachments[0].ID, CommentID: comment.ID})
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ func TestAPIListIssueComments(t *testing.T) {
|
||||||
DecodeJSON(t, resp, &comments)
|
DecodeJSON(t, resp, &comments)
|
||||||
expectedCount := unittest.GetCount(t, &issues_model.Comment{IssueID: issue.ID},
|
expectedCount := unittest.GetCount(t, &issues_model.Comment{IssueID: issue.ID},
|
||||||
unittest.Cond("type = ?", issues_model.CommentTypeComment))
|
unittest.Cond("type = ?", issues_model.CommentTypeComment))
|
||||||
assert.EqualValues(t, expectedCount, len(comments))
|
assert.Len(t, comments, expectedCount)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAPICreateComment(t *testing.T) {
|
func TestAPICreateComment(t *testing.T) {
|
||||||
|
@ -196,5 +196,5 @@ func TestAPIListIssueTimeline(t *testing.T) {
|
||||||
var comments []*api.TimelineComment
|
var comments []*api.TimelineComment
|
||||||
DecodeJSON(t, resp, &comments)
|
DecodeJSON(t, resp, &comments)
|
||||||
expectedCount := unittest.GetCount(t, &issues_model.Comment{IssueID: issue.ID})
|
expectedCount := unittest.GetCount(t, &issues_model.Comment{IssueID: issue.ID})
|
||||||
assert.EqualValues(t, expectedCount, len(comments))
|
assert.Len(t, comments, expectedCount)
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,5 +48,5 @@ func TestAPIReposValidateDefaultIssueConfig(t *testing.T) {
|
||||||
DecodeJSON(t, resp, &issueConfigValidation)
|
DecodeJSON(t, resp, &issueConfigValidation)
|
||||||
|
|
||||||
assert.True(t, issueConfigValidation.Valid)
|
assert.True(t, issueConfigValidation.Valid)
|
||||||
assert.Equal(t, issueConfigValidation.Message, "")
|
assert.Empty(t, issueConfigValidation.Message)
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,8 +170,8 @@ func TestAPIPullReview(t *testing.T) {
|
||||||
DecodeJSON(t, resp, &commentReview)
|
DecodeJSON(t, resp, &commentReview)
|
||||||
assert.EqualValues(t, "COMMENT", commentReview.State)
|
assert.EqualValues(t, "COMMENT", commentReview.State)
|
||||||
assert.EqualValues(t, 2, commentReview.CodeCommentsCount)
|
assert.EqualValues(t, 2, commentReview.CodeCommentsCount)
|
||||||
assert.EqualValues(t, "", commentReview.Body)
|
assert.Empty(t, commentReview.Body)
|
||||||
assert.EqualValues(t, false, commentReview.Dismissed)
|
assert.False(t, commentReview.Dismissed)
|
||||||
|
|
||||||
// test CreatePullReview Comment with body but without comments
|
// test CreatePullReview Comment with body but without comments
|
||||||
commentBody := "This is a body of the comment."
|
commentBody := "This is a body of the comment."
|
||||||
|
@ -186,7 +186,7 @@ func TestAPIPullReview(t *testing.T) {
|
||||||
assert.EqualValues(t, "COMMENT", commentReview.State)
|
assert.EqualValues(t, "COMMENT", commentReview.State)
|
||||||
assert.EqualValues(t, 0, commentReview.CodeCommentsCount)
|
assert.EqualValues(t, 0, commentReview.CodeCommentsCount)
|
||||||
assert.EqualValues(t, commentBody, commentReview.Body)
|
assert.EqualValues(t, commentBody, commentReview.Body)
|
||||||
assert.EqualValues(t, false, commentReview.Dismissed)
|
assert.False(t, commentReview.Dismissed)
|
||||||
|
|
||||||
// test CreatePullReview Comment without body and no comments
|
// test CreatePullReview Comment without body and no comments
|
||||||
req = NewRequestWithJSON(t, http.MethodPost, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/reviews?token=%s", repo.OwnerName, repo.Name, pullIssue.Index, token), &api.CreatePullReviewOptions{
|
req = NewRequestWithJSON(t, http.MethodPost, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/reviews?token=%s", repo.OwnerName, repo.Name, pullIssue.Index, token), &api.CreatePullReviewOptions{
|
||||||
|
|
|
@ -49,12 +49,12 @@ func TestAPIViewPulls(t *testing.T) {
|
||||||
t.Run(fmt.Sprintf("APIGetPullFiles_%d", pull.ID),
|
t.Run(fmt.Sprintf("APIGetPullFiles_%d", pull.ID),
|
||||||
doAPIGetPullFiles(ctx, pull, func(t *testing.T, files []*api.ChangedFile) {
|
doAPIGetPullFiles(ctx, pull, func(t *testing.T, files []*api.ChangedFile) {
|
||||||
if assert.Len(t, files, 1) {
|
if assert.Len(t, files, 1) {
|
||||||
assert.EqualValues(t, "File-WoW", files[0].Filename)
|
assert.Equal(t, "File-WoW", files[0].Filename)
|
||||||
assert.EqualValues(t, "", files[0].PreviousFilename)
|
assert.Empty(t, files[0].PreviousFilename)
|
||||||
assert.EqualValues(t, 1, files[0].Additions)
|
assert.EqualValues(t, 1, files[0].Additions)
|
||||||
assert.EqualValues(t, 1, files[0].Changes)
|
assert.EqualValues(t, 1, files[0].Changes)
|
||||||
assert.EqualValues(t, 0, files[0].Deletions)
|
assert.EqualValues(t, 0, files[0].Deletions)
|
||||||
assert.EqualValues(t, "added", files[0].Status)
|
assert.Equal(t, "added", files[0].Status)
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,21 +32,21 @@ func TestAPIDownloadArchive(t *testing.T) {
|
||||||
resp := MakeRequest(t, NewRequest(t, "GET", link.String()), http.StatusOK)
|
resp := MakeRequest(t, NewRequest(t, "GET", link.String()), http.StatusOK)
|
||||||
bs, err := io.ReadAll(resp.Body)
|
bs, err := io.ReadAll(resp.Body)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.EqualValues(t, 320, len(bs))
|
assert.Len(t, bs, 320)
|
||||||
|
|
||||||
link, _ = url.Parse(fmt.Sprintf("/api/v1/repos/%s/%s/archive/master.tar.gz", user2.Name, repo.Name))
|
link, _ = url.Parse(fmt.Sprintf("/api/v1/repos/%s/%s/archive/master.tar.gz", user2.Name, repo.Name))
|
||||||
link.RawQuery = url.Values{"token": {token}}.Encode()
|
link.RawQuery = url.Values{"token": {token}}.Encode()
|
||||||
resp = MakeRequest(t, NewRequest(t, "GET", link.String()), http.StatusOK)
|
resp = MakeRequest(t, NewRequest(t, "GET", link.String()), http.StatusOK)
|
||||||
bs, err = io.ReadAll(resp.Body)
|
bs, err = io.ReadAll(resp.Body)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.EqualValues(t, 266, len(bs))
|
assert.Len(t, bs, 266)
|
||||||
|
|
||||||
link, _ = url.Parse(fmt.Sprintf("/api/v1/repos/%s/%s/archive/master.bundle", user2.Name, repo.Name))
|
link, _ = url.Parse(fmt.Sprintf("/api/v1/repos/%s/%s/archive/master.bundle", user2.Name, repo.Name))
|
||||||
link.RawQuery = url.Values{"token": {token}}.Encode()
|
link.RawQuery = url.Values{"token": {token}}.Encode()
|
||||||
resp = MakeRequest(t, NewRequest(t, "GET", link.String()), http.StatusOK)
|
resp = MakeRequest(t, NewRequest(t, "GET", link.String()), http.StatusOK)
|
||||||
bs, err = io.ReadAll(resp.Body)
|
bs, err = io.ReadAll(resp.Body)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.EqualValues(t, 382, len(bs))
|
assert.Len(t, bs, 382)
|
||||||
|
|
||||||
link, _ = url.Parse(fmt.Sprintf("/api/v1/repos/%s/%s/archive/master", user2.Name, repo.Name))
|
link, _ = url.Parse(fmt.Sprintf("/api/v1/repos/%s/%s/archive/master", user2.Name, repo.Name))
|
||||||
link.RawQuery = url.Values{"token": {token}}.Encode()
|
link.RawQuery = url.Values{"token": {token}}.Encode()
|
||||||
|
|
|
@ -194,10 +194,10 @@ func TestAPIRepoEdit(t *testing.T) {
|
||||||
// check repo1 was written to database
|
// check repo1 was written to database
|
||||||
repo1edited = unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
|
repo1edited = unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
|
||||||
repo1editedOption = getRepoEditOptionFromRepo(repo1edited)
|
repo1editedOption = getRepoEditOptionFromRepo(repo1edited)
|
||||||
assert.Equal(t, *repo1editedOption.HasIssues, true)
|
assert.True(t, *repo1editedOption.HasIssues)
|
||||||
assert.Nil(t, repo1editedOption.ExternalTracker)
|
assert.Nil(t, repo1editedOption.ExternalTracker)
|
||||||
assert.Equal(t, *repo1editedOption.InternalTracker, *repoEditOption.InternalTracker)
|
assert.Equal(t, *repo1editedOption.InternalTracker, *repoEditOption.InternalTracker)
|
||||||
assert.Equal(t, *repo1editedOption.HasWiki, true)
|
assert.True(t, *repo1editedOption.HasWiki)
|
||||||
assert.Nil(t, repo1editedOption.ExternalWiki)
|
assert.Nil(t, repo1editedOption.ExternalWiki)
|
||||||
|
|
||||||
// Test editing repo1 to use external issue and wiki
|
// Test editing repo1 to use external issue and wiki
|
||||||
|
@ -216,9 +216,9 @@ func TestAPIRepoEdit(t *testing.T) {
|
||||||
// check repo1 was written to database
|
// check repo1 was written to database
|
||||||
repo1edited = unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
|
repo1edited = unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
|
||||||
repo1editedOption = getRepoEditOptionFromRepo(repo1edited)
|
repo1editedOption = getRepoEditOptionFromRepo(repo1edited)
|
||||||
assert.Equal(t, *repo1editedOption.HasIssues, true)
|
assert.True(t, *repo1editedOption.HasIssues)
|
||||||
assert.Equal(t, *repo1editedOption.ExternalTracker, *repoEditOption.ExternalTracker)
|
assert.Equal(t, *repo1editedOption.ExternalTracker, *repoEditOption.ExternalTracker)
|
||||||
assert.Equal(t, *repo1editedOption.HasWiki, true)
|
assert.True(t, *repo1editedOption.HasWiki)
|
||||||
assert.Equal(t, *repo1editedOption.ExternalWiki, *repoEditOption.ExternalWiki)
|
assert.Equal(t, *repo1editedOption.ExternalWiki, *repoEditOption.ExternalWiki)
|
||||||
|
|
||||||
repoEditOption.ExternalTracker.ExternalTrackerStyle = "regexp"
|
repoEditOption.ExternalTracker.ExternalTrackerStyle = "regexp"
|
||||||
|
@ -229,7 +229,7 @@ func TestAPIRepoEdit(t *testing.T) {
|
||||||
assert.NotNil(t, repo)
|
assert.NotNil(t, repo)
|
||||||
repo1edited = unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
|
repo1edited = unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
|
||||||
repo1editedOption = getRepoEditOptionFromRepo(repo1edited)
|
repo1editedOption = getRepoEditOptionFromRepo(repo1edited)
|
||||||
assert.Equal(t, *repo1editedOption.HasIssues, true)
|
assert.True(t, *repo1editedOption.HasIssues)
|
||||||
assert.Equal(t, *repo1editedOption.ExternalTracker, *repoEditOption.ExternalTracker)
|
assert.Equal(t, *repo1editedOption.ExternalTracker, *repoEditOption.ExternalTracker)
|
||||||
|
|
||||||
// Do some tests with invalid URL for external tracker and wiki
|
// Do some tests with invalid URL for external tracker and wiki
|
||||||
|
@ -259,9 +259,9 @@ func TestAPIRepoEdit(t *testing.T) {
|
||||||
repo1edited = unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
|
repo1edited = unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
|
||||||
repo1editedOption = getRepoEditOptionFromRepo(repo1edited)
|
repo1editedOption = getRepoEditOptionFromRepo(repo1edited)
|
||||||
assert.Equal(t, *repo1editedOption.Description, *repoEditOption.Description)
|
assert.Equal(t, *repo1editedOption.Description, *repoEditOption.Description)
|
||||||
assert.Equal(t, *repo1editedOption.HasIssues, true)
|
assert.True(t, *repo1editedOption.HasIssues)
|
||||||
assert.NotNil(t, *repo1editedOption.ExternalTracker)
|
assert.NotNil(t, *repo1editedOption.ExternalTracker)
|
||||||
assert.Equal(t, *repo1editedOption.HasWiki, true)
|
assert.True(t, *repo1editedOption.HasWiki)
|
||||||
assert.NotNil(t, *repo1editedOption.ExternalWiki)
|
assert.NotNil(t, *repo1editedOption.ExternalWiki)
|
||||||
|
|
||||||
// reset repo in db
|
// reset repo in db
|
||||||
|
|
|
@ -412,7 +412,7 @@ func TestAPIMirrorSyncNonMirrorRepo(t *testing.T) {
|
||||||
req := NewRequest(t, "GET", "/api/v1/repos/user2/repo1")
|
req := NewRequest(t, "GET", "/api/v1/repos/user2/repo1")
|
||||||
resp := MakeRequest(t, req, http.StatusOK)
|
resp := MakeRequest(t, req, http.StatusOK)
|
||||||
DecodeJSON(t, resp, &repo)
|
DecodeJSON(t, resp, &repo)
|
||||||
assert.EqualValues(t, false, repo.Mirror)
|
assert.False(t, repo.Mirror)
|
||||||
|
|
||||||
req = NewRequestf(t, "POST", "/api/v1/repos/user2/repo1/mirror-sync?token=%s", token)
|
req = NewRequestf(t, "POST", "/api/v1/repos/user2/repo1/mirror-sync?token=%s", token)
|
||||||
resp = MakeRequest(t, req, http.StatusBadRequest)
|
resp = MakeRequest(t, req, http.StatusBadRequest)
|
||||||
|
@ -469,7 +469,7 @@ func testAPIRepoCreateConflict(t *testing.T, u *url.URL) {
|
||||||
resp := httpContext.Session.MakeRequest(t, req, http.StatusConflict)
|
resp := httpContext.Session.MakeRequest(t, req, http.StatusConflict)
|
||||||
respJSON := map[string]string{}
|
respJSON := map[string]string{}
|
||||||
DecodeJSON(t, resp, &respJSON)
|
DecodeJSON(t, resp, &respJSON)
|
||||||
assert.Equal(t, respJSON["message"], "The repository with the same name already exists.")
|
assert.Equal(t, "The repository with the same name already exists.", respJSON["message"])
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -203,7 +203,7 @@ func TestLDAPAuthChange(t *testing.T) {
|
||||||
host, _ := doc.Find(`input[name="host"]`).Attr("value")
|
host, _ := doc.Find(`input[name="host"]`).Attr("value")
|
||||||
assert.Equal(t, host, getLDAPServerHost())
|
assert.Equal(t, host, getLDAPServerHost())
|
||||||
binddn, _ := doc.Find(`input[name="bind_dn"]`).Attr("value")
|
binddn, _ := doc.Find(`input[name="bind_dn"]`).Attr("value")
|
||||||
assert.Equal(t, binddn, "uid=gitea,ou=service,dc=planetexpress,dc=com")
|
assert.Equal(t, "uid=gitea,ou=service,dc=planetexpress,dc=com", binddn)
|
||||||
|
|
||||||
req = NewRequestWithValues(t, "POST", href, buildAuthSourceLDAPPayload(csrf, "", "", "", "off"))
|
req = NewRequestWithValues(t, "POST", href, buildAuthSourceLDAPPayload(csrf, "", "", "", "off"))
|
||||||
session.MakeRequest(t, req, http.StatusSeeOther)
|
session.MakeRequest(t, req, http.StatusSeeOther)
|
||||||
|
@ -214,7 +214,7 @@ func TestLDAPAuthChange(t *testing.T) {
|
||||||
host, _ = doc.Find(`input[name="host"]`).Attr("value")
|
host, _ = doc.Find(`input[name="host"]`).Attr("value")
|
||||||
assert.Equal(t, host, getLDAPServerHost())
|
assert.Equal(t, host, getLDAPServerHost())
|
||||||
binddn, _ = doc.Find(`input[name="bind_dn"]`).Attr("value")
|
binddn, _ = doc.Find(`input[name="bind_dn"]`).Attr("value")
|
||||||
assert.Equal(t, binddn, "uid=gitea,ou=service,dc=planetexpress,dc=com")
|
assert.Equal(t, "uid=gitea,ou=service,dc=planetexpress,dc=com", binddn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLDAPUserSync(t *testing.T) {
|
func TestLDAPUserSync(t *testing.T) {
|
||||||
|
@ -397,8 +397,8 @@ func TestLDAPGroupTeamSyncAddMember(t *testing.T) {
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
if user.Name == "fry" || user.Name == "leela" || user.Name == "bender" {
|
if user.Name == "fry" || user.Name == "leela" || user.Name == "bender" {
|
||||||
// assert members of LDAP group "cn=ship_crew" are added to mapped teams
|
// assert members of LDAP group "cn=ship_crew" are added to mapped teams
|
||||||
assert.Equal(t, len(usersOrgs), 1, "User [%s] should be member of one organization", user.Name)
|
assert.Len(t, usersOrgs, 1, "User [%s] should be member of one organization", user.Name)
|
||||||
assert.Equal(t, usersOrgs[0].Name, "org26", "Membership should be added to the right organization")
|
assert.Equal(t, "org26", usersOrgs[0].Name, "Membership should be added to the right organization")
|
||||||
isMember, err := organization.IsTeamMember(db.DefaultContext, usersOrgs[0].ID, team.ID, user.ID)
|
isMember, err := organization.IsTeamMember(db.DefaultContext, usersOrgs[0].ID, team.ID, user.ID)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.True(t, isMember, "Membership should be added to the right team")
|
assert.True(t, isMember, "Membership should be added to the right team")
|
||||||
|
|
|
@ -19,5 +19,5 @@ func TestCORSNotSet(t *testing.T) {
|
||||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||||
assert.Equal(t, resp.Code, http.StatusOK)
|
assert.Equal(t, resp.Code, http.StatusOK)
|
||||||
corsHeader := resp.Header().Get("Access-Control-Allow-Origin")
|
corsHeader := resp.Header().Get("Access-Control-Allow-Origin")
|
||||||
assert.Equal(t, corsHeader, "", "Access-Control-Allow-Origin: generated header should match") // header not set
|
assert.Empty(t, corsHeader, "Access-Control-Allow-Origin: generated header should match") // header not set
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ func TestEmptyRepoAddFile(t *testing.T) {
|
||||||
req := NewRequest(t, "GET", "/user30/empty/_new/"+setting.Repository.DefaultBranch)
|
req := NewRequest(t, "GET", "/user30/empty/_new/"+setting.Repository.DefaultBranch)
|
||||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||||
doc := NewHTMLParser(t, resp.Body).Find(`input[name="commit_choice"]`)
|
doc := NewHTMLParser(t, resp.Body).Find(`input[name="commit_choice"]`)
|
||||||
assert.Equal(t, "", doc.AttrOr("checked", "_no_"))
|
assert.Empty(t, doc.AttrOr("checked", "_no_"))
|
||||||
req = NewRequestWithValues(t, "POST", "/user30/empty/_new/"+setting.Repository.DefaultBranch, map[string]string{
|
req = NewRequestWithValues(t, "POST", "/user30/empty/_new/"+setting.Repository.DefaultBranch, map[string]string{
|
||||||
"_csrf": GetCSRF(t, session, "/user/settings"),
|
"_csrf": GetCSRF(t, session, "/user/settings"),
|
||||||
"commit_choice": "direct",
|
"commit_choice": "direct",
|
||||||
|
@ -76,7 +76,7 @@ func TestEmptyRepoUploadFile(t *testing.T) {
|
||||||
req := NewRequest(t, "GET", "/user30/empty/_new/"+setting.Repository.DefaultBranch)
|
req := NewRequest(t, "GET", "/user30/empty/_new/"+setting.Repository.DefaultBranch)
|
||||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||||
doc := NewHTMLParser(t, resp.Body).Find(`input[name="commit_choice"]`)
|
doc := NewHTMLParser(t, resp.Body).Find(`input[name="commit_choice"]`)
|
||||||
assert.Equal(t, "", doc.AttrOr("checked", "_no_"))
|
assert.Empty(t, doc.AttrOr("checked", "_no_"))
|
||||||
|
|
||||||
body := &bytes.Buffer{}
|
body := &bytes.Buffer{}
|
||||||
mpForm := multipart.NewWriter(body)
|
mpForm := multipart.NewWriter(body)
|
||||||
|
|
|
@ -763,7 +763,7 @@ func doCreateAgitFlowPull(dstPath string, ctx *APITestContext, baseBranch, headB
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
assert.Equal(t, "user2/"+headBranch, pr1.HeadBranch)
|
assert.Equal(t, "user2/"+headBranch, pr1.HeadBranch)
|
||||||
assert.Equal(t, false, prMsg.HasMerged)
|
assert.False(t, prMsg.HasMerged)
|
||||||
assert.Contains(t, "Testing commit 1", prMsg.Body)
|
assert.Contains(t, "Testing commit 1", prMsg.Body)
|
||||||
assert.Equal(t, commit, prMsg.Head.Sha)
|
assert.Equal(t, commit, prMsg.Head.Sha)
|
||||||
|
|
||||||
|
@ -785,7 +785,7 @@ func doCreateAgitFlowPull(dstPath string, ctx *APITestContext, baseBranch, headB
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
assert.Equal(t, "user2/test/"+headBranch, pr2.HeadBranch)
|
assert.Equal(t, "user2/test/"+headBranch, pr2.HeadBranch)
|
||||||
assert.Equal(t, false, prMsg.HasMerged)
|
assert.False(t, prMsg.HasMerged)
|
||||||
})
|
})
|
||||||
|
|
||||||
if pr1 == nil || pr2 == nil {
|
if pr1 == nil || pr2 == nil {
|
||||||
|
@ -829,7 +829,7 @@ func doCreateAgitFlowPull(dstPath string, ctx *APITestContext, baseBranch, headB
|
||||||
if !assert.NoError(t, err) {
|
if !assert.NoError(t, err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
assert.Equal(t, false, prMsg.HasMerged)
|
assert.False(t, prMsg.HasMerged)
|
||||||
assert.Equal(t, commit, prMsg.Head.Sha)
|
assert.Equal(t, commit, prMsg.Head.Sha)
|
||||||
|
|
||||||
_, _, err = git.NewCommand(git.DefaultContext, "push", "origin").AddDynamicArguments("HEAD:refs/for/master/test/" + headBranch).RunStdString(&git.RunOpts{Dir: dstPath})
|
_, _, err = git.NewCommand(git.DefaultContext, "push", "origin").AddDynamicArguments("HEAD:refs/for/master/test/" + headBranch).RunStdString(&git.RunOpts{Dir: dstPath})
|
||||||
|
@ -841,7 +841,7 @@ func doCreateAgitFlowPull(dstPath string, ctx *APITestContext, baseBranch, headB
|
||||||
if !assert.NoError(t, err) {
|
if !assert.NoError(t, err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
assert.Equal(t, false, prMsg.HasMerged)
|
assert.False(t, prMsg.HasMerged)
|
||||||
assert.Equal(t, commit, prMsg.Head.Sha)
|
assert.Equal(t, commit, prMsg.Head.Sha)
|
||||||
})
|
})
|
||||||
t.Run("Merge", doAPIMergePullRequest(*ctx, ctx.Username, ctx.Reponame, pr1.Index))
|
t.Run("Merge", doAPIMergePullRequest(*ctx, ctx.Username, ctx.Reponame, pr1.Index))
|
||||||
|
|
|
@ -414,7 +414,7 @@ func TestConflictChecking(t *testing.T) {
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
// Ensure conflictedFiles is populated.
|
// Ensure conflictedFiles is populated.
|
||||||
assert.Equal(t, 1, len(conflictingPR.ConflictedFiles))
|
assert.Len(t, conflictingPR.ConflictedFiles, 1)
|
||||||
// Check if status is correct.
|
// Check if status is correct.
|
||||||
assert.Equal(t, issues_model.PullRequestStatusConflict, conflictingPR.Status)
|
assert.Equal(t, issues_model.PullRequestStatusConflict, conflictingPR.Status)
|
||||||
// Ensure that mergeable returns false
|
// Ensure that mergeable returns false
|
||||||
|
|
|
@ -376,7 +376,7 @@ func TestMarkDownReadmeImage(t *testing.T) {
|
||||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||||
src, exists := htmlDoc.doc.Find(`.markdown img`).Attr("src")
|
src, exists := htmlDoc.doc.Find(`.markdown img`).Attr("src")
|
||||||
assert.True(t, exists, "Image not found in README")
|
assert.True(t, exists, "Image not found in README")
|
||||||
assert.Equal(t, src, "/user2/repo1/media/branch/home-md-img-check/test-fake-img.jpg")
|
assert.Equal(t, "/user2/repo1/media/branch/home-md-img-check/test-fake-img.jpg", src)
|
||||||
|
|
||||||
req = NewRequest(t, "GET", "/user2/repo1/src/branch/home-md-img-check/README.md")
|
req = NewRequest(t, "GET", "/user2/repo1/src/branch/home-md-img-check/README.md")
|
||||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||||
|
@ -384,7 +384,7 @@ func TestMarkDownReadmeImage(t *testing.T) {
|
||||||
htmlDoc = NewHTMLParser(t, resp.Body)
|
htmlDoc = NewHTMLParser(t, resp.Body)
|
||||||
src, exists = htmlDoc.doc.Find(`.markdown img`).Attr("src")
|
src, exists = htmlDoc.doc.Find(`.markdown img`).Attr("src")
|
||||||
assert.True(t, exists, "Image not found in markdown file")
|
assert.True(t, exists, "Image not found in markdown file")
|
||||||
assert.Equal(t, src, "/user2/repo1/media/branch/home-md-img-check/test-fake-img.jpg")
|
assert.Equal(t, "/user2/repo1/media/branch/home-md-img-check/test-fake-img.jpg", src)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMarkDownReadmeImageSubfolder(t *testing.T) {
|
func TestMarkDownReadmeImageSubfolder(t *testing.T) {
|
||||||
|
@ -399,7 +399,7 @@ func TestMarkDownReadmeImageSubfolder(t *testing.T) {
|
||||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||||
src, exists := htmlDoc.doc.Find(`.markdown img`).Attr("src")
|
src, exists := htmlDoc.doc.Find(`.markdown img`).Attr("src")
|
||||||
assert.True(t, exists, "Image not found in README")
|
assert.True(t, exists, "Image not found in README")
|
||||||
assert.Equal(t, src, "/user2/repo1/media/branch/sub-home-md-img-check/docs/test-fake-img.jpg")
|
assert.Equal(t, "/user2/repo1/media/branch/sub-home-md-img-check/docs/test-fake-img.jpg", src)
|
||||||
|
|
||||||
req = NewRequest(t, "GET", "/user2/repo1/src/branch/sub-home-md-img-check/docs/README.md")
|
req = NewRequest(t, "GET", "/user2/repo1/src/branch/sub-home-md-img-check/docs/README.md")
|
||||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||||
|
@ -407,5 +407,5 @@ func TestMarkDownReadmeImageSubfolder(t *testing.T) {
|
||||||
htmlDoc = NewHTMLParser(t, resp.Body)
|
htmlDoc = NewHTMLParser(t, resp.Body)
|
||||||
src, exists = htmlDoc.doc.Find(`.markdown img`).Attr("src")
|
src, exists = htmlDoc.doc.Find(`.markdown img`).Attr("src")
|
||||||
assert.True(t, exists, "Image not found in markdown file")
|
assert.True(t, exists, "Image not found in markdown file")
|
||||||
assert.Equal(t, src, "/user2/repo1/media/branch/sub-home-md-img-check/docs/test-fake-img.jpg")
|
assert.Equal(t, "/user2/repo1/media/branch/sub-home-md-img-check/docs/test-fake-img.jpg", src)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user