aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/git/repo_attribute_test.go4
-rw-r--r--modules/git/repo_commit_test.go2
-rw-r--r--modules/git/repo_tag_test.go2
-rw-r--r--modules/indexer/code/indexer_test.go2
-rw-r--r--modules/lfs/http_client_test.go4
-rw-r--r--modules/log/file_test.go2
-rw-r--r--modules/markup/html_test.go2
-rw-r--r--modules/packages/container/metadata_test.go2
-rw-r--r--modules/paginator/paginator_test.go40
-rw-r--r--modules/queue/unique_queue_disk_channel_test.go2
-rw-r--r--modules/secret/secret_test.go4
-rw-r--r--modules/storage/local_test.go2
-rw-r--r--modules/test/logchecker_test.go20
-rw-r--r--modules/translation/i18n/i18n_test.go4
-rw-r--r--modules/util/slice_test.go22
-rw-r--r--modules/util/truncate_test.go2
16 files changed, 58 insertions, 58 deletions
diff --git a/modules/git/repo_attribute_test.go b/modules/git/repo_attribute_test.go
index f88ae95407..350b69dd25 100644
--- a/modules/git/repo_attribute_test.go
+++ b/modules/git/repo_attribute_test.go
@@ -19,7 +19,7 @@ func Test_nulSeparatedAttributeWriter_ReadAttribute(t *testing.T) {
n, err := wr.Write([]byte(testStr))
- assert.Equal(t, n, len(testStr))
+ assert.Len(t, testStr, n)
assert.NoError(t, err)
select {
case attr := <-wr.ReadAttribute():
@@ -32,7 +32,7 @@ func Test_nulSeparatedAttributeWriter_ReadAttribute(t *testing.T) {
// Write a second attribute again
n, err = wr.Write([]byte(testStr))
- assert.Equal(t, n, len(testStr))
+ assert.Len(t, testStr, n)
assert.NoError(t, err)
select {
diff --git a/modules/git/repo_commit_test.go b/modules/git/repo_commit_test.go
index 729fb0ba10..fee145e924 100644
--- a/modules/git/repo_commit_test.go
+++ b/modules/git/repo_commit_test.go
@@ -97,6 +97,6 @@ func TestRepository_CommitsBetweenIDs(t *testing.T) {
for i, c := range cases {
commits, err := bareRepo1.CommitsBetweenIDs(c.NewID, c.OldID)
assert.NoError(t, err)
- assert.Equal(t, c.ExpectedCommits, len(commits), "case %d", i)
+ assert.Len(t, commits, c.ExpectedCommits, "case %d", i)
}
}
diff --git a/modules/git/repo_tag_test.go b/modules/git/repo_tag_test.go
index 8ccfec3eb2..fb6a7cdd1a 100644
--- a/modules/git/repo_tag_test.go
+++ b/modules/git/repo_tag_test.go
@@ -26,7 +26,7 @@ func TestRepository_GetTags(t *testing.T) {
return
}
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, "36f97d9a96457e2bab511db30fe2db03893ebc64", tags[0].ID.String())
assert.EqualValues(t, "tag", tags[0].Type)
diff --git a/modules/indexer/code/indexer_test.go b/modules/indexer/code/indexer_test.go
index c353d5b688..52f7e76e41 100644
--- a/modules/indexer/code/indexer_test.go
+++ b/modules/indexer/code/indexer_test.go
@@ -69,7 +69,7 @@ func testIndexer(name string, t *testing.T, indexer Indexer) {
t.Run(kw.Keyword, func(t *testing.T) {
total, res, langs, err := indexer.Search(context.TODO(), kw.RepoIDs, "", kw.Keyword, 1, 10, false)
assert.NoError(t, err)
- assert.EqualValues(t, len(kw.IDs), total)
+ assert.Len(t, kw.IDs, int(total))
assert.Len(t, langs, kw.Langs)
ids := make([]int64, 0, len(res))
diff --git a/modules/lfs/http_client_test.go b/modules/lfs/http_client_test.go
index a8c7e379f6..cb71b9008a 100644
--- a/modules/lfs/http_client_test.go
+++ b/modules/lfs/http_client_test.go
@@ -162,7 +162,7 @@ func TestHTTPClientDownload(t *testing.T) {
assert.NoError(t, err)
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.Size, batchRequest.Objects[0].Size)
@@ -269,7 +269,7 @@ func TestHTTPClientUpload(t *testing.T) {
assert.NoError(t, err)
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.Size, batchRequest.Objects[0].Size)
diff --git a/modules/log/file_test.go b/modules/log/file_test.go
index f1ca23d342..34f7459806 100644
--- a/modules/log/file_test.go
+++ b/modules/log/file_test.go
@@ -51,7 +51,7 @@ func TestFileLogger(t *testing.T) {
fileLogger := NewFileLogger()
realFileLogger, ok := fileLogger.(*FileLogger)
- assert.Equal(t, true, ok)
+ assert.True(t, ok)
location, _ := time.LoadLocation("EST")
diff --git a/modules/markup/html_test.go b/modules/markup/html_test.go
index f8b84485c0..cb1216ec94 100644
--- a/modules/markup/html_test.go
+++ b/modules/markup/html_test.go
@@ -593,5 +593,5 @@ func TestIssue18471(t *testing.T) {
}, strings.NewReader(data), &res)
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())
}
diff --git a/modules/packages/container/metadata_test.go b/modules/packages/container/metadata_test.go
index 48809f4c99..195b3982cb 100644
--- a/modules/packages/container/metadata_test.go
+++ b/modules/packages/container/metadata_test.go
@@ -33,7 +33,7 @@ func TestParseImageConfig(t *testing.T) {
assert.Equal(t, projectURL, metadata.ProjectURL)
assert.Equal(t, repositoryURL, metadata.RepositoryURL)
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(
t,
map[string]string{
diff --git a/modules/paginator/paginator_test.go b/modules/paginator/paginator_test.go
index 41bb305337..8a56ee5121 100644
--- a/modules/paginator/paginator_test.go
+++ b/modules/paginator/paginator_test.go
@@ -70,19 +70,19 @@ func TestPaginator(t *testing.T) {
t.Run("Generate pages", func(t *testing.T) {
p := New(0, 10, 1, 0)
pages := p.Pages()
- assert.Equal(t, 0, len(pages))
+ assert.Empty(t, pages)
})
t.Run("Only current page", func(t *testing.T) {
p := New(0, 10, 1, 1)
pages := p.Pages()
- assert.Equal(t, 1, len(pages))
+ assert.Len(t, pages, 1)
assert.Equal(t, 1, pages[0].Num())
assert.True(t, pages[0].IsCurrent())
p = New(1, 10, 1, 1)
pages = p.Pages()
- assert.Equal(t, 1, len(pages))
+ assert.Len(t, pages, 1)
assert.Equal(t, 1, pages[0].Num())
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) {
p := New(1, 10, 1, 2)
pages := p.Pages()
- assert.Equal(t, 1, len(pages))
+ assert.Len(t, pages, 1)
assert.Equal(t, 1, pages[0].Num())
assert.True(t, pages[0].IsCurrent())
p = New(11, 10, 1, 2)
pages = p.Pages()
- assert.Equal(t, 2, len(pages))
+ assert.Len(t, pages, 2)
assert.Equal(t, 1, pages[0].Num())
assert.True(t, pages[0].IsCurrent())
assert.Equal(t, 2, pages[1].Num())
@@ -104,7 +104,7 @@ func TestPaginator(t *testing.T) {
p = New(11, 10, 2, 2)
pages = p.Pages()
- assert.Equal(t, 2, len(pages))
+ assert.Len(t, pages, 2)
assert.Equal(t, 1, pages[0].Num())
assert.False(t, pages[0].IsCurrent())
assert.Equal(t, 2, pages[1].Num())
@@ -112,7 +112,7 @@ func TestPaginator(t *testing.T) {
p = New(25, 10, 2, 3)
pages = p.Pages()
- assert.Equal(t, 3, len(pages))
+ assert.Len(t, pages, 3)
assert.Equal(t, 1, pages[0].Num())
assert.False(t, pages[0].IsCurrent())
assert.Equal(t, 2, pages[1].Num())
@@ -125,7 +125,7 @@ func TestPaginator(t *testing.T) {
// ... 2
p := New(11, 10, 2, 1)
pages := p.Pages()
- assert.Equal(t, 2, len(pages))
+ assert.Len(t, pages, 2)
assert.Equal(t, -1, pages[0].Num())
assert.False(t, pages[0].IsCurrent())
assert.Equal(t, 2, pages[1].Num())
@@ -134,7 +134,7 @@ func TestPaginator(t *testing.T) {
// ... 2 3
p = New(21, 10, 2, 2)
pages = p.Pages()
- assert.Equal(t, 3, len(pages))
+ assert.Len(t, pages, 3)
assert.Equal(t, -1, pages[0].Num())
assert.False(t, pages[0].IsCurrent())
assert.Equal(t, 2, pages[1].Num())
@@ -145,7 +145,7 @@ func TestPaginator(t *testing.T) {
// ... 2 3 4
p = New(31, 10, 3, 3)
pages = p.Pages()
- assert.Equal(t, 4, len(pages))
+ assert.Len(t, pages, 4)
assert.Equal(t, -1, pages[0].Num())
assert.False(t, pages[0].IsCurrent())
assert.Equal(t, 2, pages[1].Num())
@@ -158,7 +158,7 @@ func TestPaginator(t *testing.T) {
// ... 3 4 5
p = New(41, 10, 4, 3)
pages = p.Pages()
- assert.Equal(t, 4, len(pages))
+ assert.Len(t, pages, 4)
assert.Equal(t, -1, pages[0].Num())
assert.False(t, pages[0].IsCurrent())
assert.Equal(t, 3, pages[1].Num())
@@ -171,7 +171,7 @@ func TestPaginator(t *testing.T) {
// ... 4 5 6 7 8 9 10
p = New(100, 10, 9, 7)
pages = p.Pages()
- assert.Equal(t, 8, len(pages))
+ assert.Len(t, pages, 8)
assert.Equal(t, -1, pages[0].Num())
assert.False(t, pages[0].IsCurrent())
assert.Equal(t, 4, pages[1].Num())
@@ -194,7 +194,7 @@ func TestPaginator(t *testing.T) {
// 1 ...
p := New(21, 10, 1, 1)
pages := p.Pages()
- assert.Equal(t, 2, len(pages))
+ assert.Len(t, pages, 2)
assert.Equal(t, 1, pages[0].Num())
assert.True(t, pages[0].IsCurrent())
assert.Equal(t, -1, pages[1].Num())
@@ -203,7 +203,7 @@ func TestPaginator(t *testing.T) {
// 1 2 ...
p = New(21, 10, 1, 2)
pages = p.Pages()
- assert.Equal(t, 3, len(pages))
+ assert.Len(t, pages, 3)
assert.Equal(t, 1, pages[0].Num())
assert.True(t, pages[0].IsCurrent())
assert.Equal(t, 2, pages[1].Num())
@@ -214,7 +214,7 @@ func TestPaginator(t *testing.T) {
// 1 2 3 ...
p = New(31, 10, 2, 3)
pages = p.Pages()
- assert.Equal(t, 4, len(pages))
+ assert.Len(t, pages, 4)
assert.Equal(t, 1, pages[0].Num())
assert.False(t, pages[0].IsCurrent())
assert.Equal(t, 2, pages[1].Num())
@@ -227,7 +227,7 @@ func TestPaginator(t *testing.T) {
// 1 2 3 ...
p = New(41, 10, 2, 3)
pages = p.Pages()
- assert.Equal(t, 4, len(pages))
+ assert.Len(t, pages, 4)
assert.Equal(t, 1, pages[0].Num())
assert.False(t, pages[0].IsCurrent())
assert.Equal(t, 2, pages[1].Num())
@@ -240,7 +240,7 @@ func TestPaginator(t *testing.T) {
// 1 2 3 4 5 6 7 ...
p = New(100, 10, 1, 7)
pages = p.Pages()
- assert.Equal(t, 8, len(pages))
+ assert.Len(t, pages, 8)
assert.Equal(t, 1, pages[0].Num())
assert.True(t, pages[0].IsCurrent())
assert.Equal(t, 2, pages[1].Num())
@@ -261,7 +261,7 @@ func TestPaginator(t *testing.T) {
// 1 2 3 4 5 6 7 ...
p = New(100, 10, 2, 7)
pages = p.Pages()
- assert.Equal(t, 8, len(pages))
+ assert.Len(t, pages, 8)
assert.Equal(t, 1, pages[0].Num())
assert.False(t, pages[0].IsCurrent())
assert.Equal(t, 2, pages[1].Num())
@@ -284,7 +284,7 @@ func TestPaginator(t *testing.T) {
// ... 2 3 ...
p := New(35, 10, 2, 2)
pages := p.Pages()
- assert.Equal(t, 4, len(pages))
+ assert.Len(t, pages, 4)
assert.Equal(t, -1, pages[0].Num())
assert.False(t, pages[0].IsCurrent())
assert.Equal(t, 2, pages[1].Num())
@@ -297,7 +297,7 @@ func TestPaginator(t *testing.T) {
// ... 2 3 4 ...
p = New(49, 10, 3, 3)
pages = p.Pages()
- assert.Equal(t, 5, len(pages))
+ assert.Len(t, pages, 5)
assert.Equal(t, -1, pages[0].Num())
assert.False(t, pages[0].IsCurrent())
assert.Equal(t, 2, pages[1].Num())
diff --git a/modules/queue/unique_queue_disk_channel_test.go b/modules/queue/unique_queue_disk_channel_test.go
index fd76163f4a..e1a2132dd6 100644
--- a/modules/queue/unique_queue_disk_channel_test.go
+++ b/modules/queue/unique_queue_disk_channel_test.go
@@ -208,7 +208,7 @@ func TestPersistableChannelUniqueQueue(t *testing.T) {
mapLock.Lock()
assert.Equal(t, 101, len(executedInitial[name])+len(executedEmpty[name]))
- assert.Equal(t, 0, len(hasEmpty[name]))
+ assert.Empty(t, hasEmpty[name])
mapLock.Unlock()
})
close(done)
diff --git a/modules/secret/secret_test.go b/modules/secret/secret_test.go
index 0a189ecebf..4b018fddb6 100644
--- a/modules/secret/secret_test.go
+++ b/modules/secret/secret_test.go
@@ -15,9 +15,9 @@ func TestEncryptDecrypt(t *testing.T) {
hex, _ = EncryptSecret("foo", "baz")
str, _ = DecryptSecret("foo", hex)
- assert.Equal(t, str, "baz")
+ assert.Equal(t, "baz", str)
hex, _ = EncryptSecret("bar", "baz")
str, _ = DecryptSecret("foo", hex)
- assert.NotEqual(t, str, "baz")
+ assert.NotEqual(t, "baz", str)
}
diff --git a/modules/storage/local_test.go b/modules/storage/local_test.go
index 9649761a0f..0873f8e14e 100644
--- a/modules/storage/local_test.go
+++ b/modules/storage/local_test.go
@@ -89,6 +89,6 @@ func TestLocalStorageIterator(t *testing.T) {
return nil
})
assert.NoError(t, err)
- assert.Equal(t, count, len(expected))
+ assert.Len(t, expected, count)
}
}
diff --git a/modules/test/logchecker_test.go b/modules/test/logchecker_test.go
index 1ed7f427f4..4dfea8c3e3 100644
--- a/modules/test/logchecker_test.go
+++ b/modules/test/logchecker_test.go
@@ -22,26 +22,26 @@ func TestLogChecker(t *testing.T) {
log.Info("test")
filtered, stopped := lc.Check(100 * time.Millisecond)
- assert.EqualValues(t, []bool{false, false}, filtered)
- assert.EqualValues(t, false, stopped)
+ assert.ElementsMatch(t, []bool{false, false}, filtered)
+ assert.False(t, stopped)
log.Info("First")
filtered, stopped = lc.Check(100 * time.Millisecond)
- assert.EqualValues(t, []bool{true, false}, filtered)
- assert.EqualValues(t, false, stopped)
+ assert.ElementsMatch(t, []bool{true, false}, filtered)
+ assert.False(t, stopped)
log.Info("Second")
filtered, stopped = lc.Check(100 * time.Millisecond)
- assert.EqualValues(t, []bool{true, false}, filtered)
- assert.EqualValues(t, false, stopped)
+ assert.ElementsMatch(t, []bool{true, false}, filtered)
+ assert.False(t, stopped)
log.Info("Third")
filtered, stopped = lc.Check(100 * time.Millisecond)
- assert.EqualValues(t, []bool{true, true}, filtered)
- assert.EqualValues(t, false, stopped)
+ assert.ElementsMatch(t, []bool{true, true}, filtered)
+ assert.False(t, stopped)
log.Info("End")
filtered, stopped = lc.Check(100 * time.Millisecond)
- assert.EqualValues(t, []bool{true, true}, filtered)
- assert.EqualValues(t, true, stopped)
+ assert.ElementsMatch(t, []bool{true, true}, filtered)
+ assert.True(t, stopped)
}
diff --git a/modules/translation/i18n/i18n_test.go b/modules/translation/i18n/i18n_test.go
index 085d03811f..1d1be43318 100644
--- a/modules/translation/i18n/i18n_test.go
+++ b/modules/translation/i18n/i18n_test.go
@@ -51,8 +51,8 @@ sub = Changed Sub String
assert.Equal(t, `test value; <span style="color: red; background: none;">more text</span>`, result)
langs, descs := ls.ListLangNameDesc()
- assert.Equal(t, []string{"lang1", "lang2"}, langs)
- assert.Equal(t, []string{"Lang1", "Lang2"}, descs)
+ assert.ElementsMatch(t, []string{"lang1", "lang2"}, langs)
+ assert.ElementsMatch(t, []string{"Lang1", "Lang2"}, descs)
found := ls.Has("lang1", "no-such")
assert.False(t, found)
diff --git a/modules/util/slice_test.go b/modules/util/slice_test.go
index b0b771a79a..373c1a3b7b 100644
--- a/modules/util/slice_test.go
+++ b/modules/util/slice_test.go
@@ -74,15 +74,15 @@ func TestSliceEqual(t *testing.T) {
}
func TestSliceRemoveAll(t *testing.T) {
- assert.Equal(t, SliceRemoveAll([]int{2, 0, 2, 3}, 0), []int{2, 2, 3})
- assert.Equal(t, SliceRemoveAll([]int{2, 0, 2, 3}, 2), []int{0, 3})
- assert.Equal(t, SliceRemoveAll([]int{0, 0, 0, 0}, 0), []int{})
- assert.Equal(t, SliceRemoveAll([]int{2, 0, 2, 3}, 4), []int{2, 0, 2, 3})
- assert.Equal(t, SliceRemoveAll([]int{}, 0), []int{})
- assert.Equal(t, SliceRemoveAll([]int(nil), 0), []int(nil))
- assert.Equal(t, SliceRemoveAll([]int{}, 0), []int{})
-
- assert.Equal(t, SliceRemoveAll([]string{"2", "0", "2", "3"}, "0"), []string{"2", "2", "3"})
- assert.Equal(t, SliceRemoveAll([]float64{2, 0, 2, 3}, 0), []float64{2, 2, 3})
- assert.Equal(t, SliceRemoveAll([]bool{false, true, false}, true), []bool{false, false})
+ assert.ElementsMatch(t, []int{2, 2, 3}, SliceRemoveAll([]int{2, 0, 2, 3}, 0))
+ assert.ElementsMatch(t, []int{0, 3}, SliceRemoveAll([]int{2, 0, 2, 3}, 2))
+ assert.Empty(t, SliceRemoveAll([]int{0, 0, 0, 0}, 0))
+ assert.ElementsMatch(t, []int{2, 0, 2, 3}, SliceRemoveAll([]int{2, 0, 2, 3}, 4))
+ assert.Empty(t, SliceRemoveAll([]int{}, 0))
+ assert.ElementsMatch(t, []int(nil), SliceRemoveAll([]int(nil), 0))
+ assert.Empty(t, SliceRemoveAll([]int{}, 0))
+
+ assert.ElementsMatch(t, []string{"2", "2", "3"}, SliceRemoveAll([]string{"2", "0", "2", "3"}, "0"))
+ assert.ElementsMatch(t, []float64{2, 2, 3}, SliceRemoveAll([]float64{2, 0, 2, 3}, 0))
+ assert.ElementsMatch(t, []bool{false, false}, SliceRemoveAll([]bool{false, true, false}, true))
}
diff --git a/modules/util/truncate_test.go b/modules/util/truncate_test.go
index 05e2bc0301..dfe1230fd4 100644
--- a/modules/util/truncate_test.go
+++ b/modules/util/truncate_test.go
@@ -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):])
} else {
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, "")
}
}
}