summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2021-06-07 07:27:09 +0200
committerGitHub <noreply@github.com>2021-06-07 07:27:09 +0200
commit3607f79d7869046d919fed05a21b55b6e61df1fa (patch)
tree9a176a4d5b67ac3a81ae210e9164d81959221ce0 /services
parent51775f65bc933843199320b040186703a2bb9f51 (diff)
downloadgitea-3607f79d7869046d919fed05a21b55b6e61df1fa.tar.gz
gitea-3607f79d7869046d919fed05a21b55b6e61df1fa.zip
Fixed assert statements. (#16089)
Diffstat (limited to 'services')
-rw-r--r--services/archiver/archiver_test.go22
-rw-r--r--services/gitdiff/csv_test.go6
-rw-r--r--services/issue/assignee_test.go2
-rw-r--r--services/release/release_test.go6
4 files changed, 18 insertions, 18 deletions
diff --git a/services/archiver/archiver_test.go b/services/archiver/archiver_test.go
index 84bab14818..6dcd942bf5 100644
--- a/services/archiver/archiver_test.go
+++ b/services/archiver/archiver_test.go
@@ -35,7 +35,7 @@ func waitForCount(t *testing.T, num int) {
}
}
- assert.Equal(t, num, len(archiveInProgress))
+ assert.Len(t, archiveInProgress, num)
}
func releaseOneEntry(t *testing.T, inFlight []*ArchiveRequest) {
@@ -128,7 +128,7 @@ func TestArchive_Basic(t *testing.T) {
// Sleep two seconds to make sure the queue doesn't change.
time.Sleep(2 * time.Second)
- assert.Equal(t, 3, len(archiveInProgress))
+ assert.Len(t, archiveInProgress, 3)
// Release them all, they'll then stall at the archiveQueueReleaseCond while
// we examine the queue state.
@@ -160,7 +160,7 @@ func TestArchive_Basic(t *testing.T) {
// Queues should not have drained yet, because we haven't released them.
// Do so now.
- assert.Equal(t, 3, len(archiveInProgress))
+ assert.Len(t, archiveInProgress, 3)
zipReq2 := DeriveRequestFrom(ctx, firstCommit+".zip")
// This zipReq should match what's sitting in the queue, as we haven't
@@ -174,15 +174,15 @@ func TestArchive_Basic(t *testing.T) {
ArchiveRepository(zipReq2)
// Make sure the queue hasn't grown any.
- assert.Equal(t, 3, len(archiveInProgress))
+ assert.Len(t, archiveInProgress, 3)
// Make sure the queue drains properly
releaseOneEntry(t, inFlight)
- assert.Equal(t, 2, len(archiveInProgress))
+ assert.Len(t, archiveInProgress, 2)
releaseOneEntry(t, inFlight)
- assert.Equal(t, 1, len(archiveInProgress))
+ assert.Len(t, archiveInProgress, 1)
releaseOneEntry(t, inFlight)
- assert.Equal(t, 0, len(archiveInProgress))
+ assert.Empty(t, archiveInProgress)
// Now we'll submit a request and TimedWaitForCompletion twice, before and
// after we release it. We should trigger both the timeout and non-timeout
@@ -194,8 +194,8 @@ func TestArchive_Basic(t *testing.T) {
// Guaranteed to timeout; we haven't signalled the request to start..
completed, timedout = timedReq.TimedWaitForCompletion(ctx, 2*time.Second)
- assert.Equal(t, false, completed)
- assert.Equal(t, true, timedout)
+ assert.False(t, completed)
+ assert.True(t, timedout)
queueMutex.Lock()
archiveQueueStartCond.Broadcast()
@@ -203,8 +203,8 @@ func TestArchive_Basic(t *testing.T) {
// Shouldn't timeout, we've now signalled it and it's a small request.
completed, timedout = timedReq.TimedWaitForCompletion(ctx, 15*time.Second)
- assert.Equal(t, true, completed)
- assert.Equal(t, false, timedout)
+ assert.True(t, completed)
+ assert.False(t, timedout)
zipReq2 = DeriveRequestFrom(ctx, firstCommit+".zip")
// Now, we're guaranteed to have released the original zipReq from the queue.
diff --git a/services/gitdiff/csv_test.go b/services/gitdiff/csv_test.go
index f3dc0c2a2c..fb84d6ed06 100644
--- a/services/gitdiff/csv_test.go
+++ b/services/gitdiff/csv_test.go
@@ -110,13 +110,13 @@ func TestCSVDiff(t *testing.T) {
result, err := CreateCsvDiff(diff.Files[0], baseReader, headReader)
assert.NoError(t, err)
- assert.Equal(t, 1, len(result), "case %d: should be one section", n)
+ assert.Len(t, result, 1, "case %d: should be one section", n)
section := result[0]
- assert.Equal(t, len(c.cells), len(section.Rows), "case %d: should be %d rows", n, len(c.cells))
+ assert.Len(t, section.Rows, len(c.cells), "case %d: should be %d rows", n, len(c.cells))
for i, row := range section.Rows {
- assert.Equal(t, 2, len(row.Cells), "case %d: row %d should have two cells", n, i)
+ assert.Len(t, row.Cells, 2, "case %d: row %d should have two cells", n, i)
for j, cell := range row.Cells {
assert.Equal(t, c.cells[i][j], cell.Type, "case %d: row %d cell %d should be equal", n, i, j)
}
diff --git a/services/issue/assignee_test.go b/services/issue/assignee_test.go
index bdd2009bf0..2d96368ec7 100644
--- a/services/issue/assignee_test.go
+++ b/services/issue/assignee_test.go
@@ -33,5 +33,5 @@ func TestDeleteNotPassedAssignee(t *testing.T) {
// Check they're gone
assignees, err := models.GetAssigneesByIssue(issue)
assert.NoError(t, err)
- assert.Equal(t, 0, len(assignees))
+ assert.Empty(t, assignees)
}
diff --git a/services/release/release_test.go b/services/release/release_test.go
index 102e3d7e0c..085be55cb4 100644
--- a/services/release/release_test.go
+++ b/services/release/release_test.go
@@ -221,7 +221,7 @@ func TestRelease_Update(t *testing.T) {
assert.NoError(t, UpdateRelease(user, gitRepo, release, []string{attach.UUID}, nil, nil))
assert.NoError(t, models.GetReleaseAttachments(release))
- assert.EqualValues(t, 1, len(release.Attachments))
+ assert.Len(t, release.Attachments, 1)
assert.EqualValues(t, attach.UUID, release.Attachments[0].UUID)
assert.EqualValues(t, release.ID, release.Attachments[0].ReleaseID)
assert.EqualValues(t, attach.Name, release.Attachments[0].Name)
@@ -232,7 +232,7 @@ func TestRelease_Update(t *testing.T) {
}))
release.Attachments = nil
assert.NoError(t, models.GetReleaseAttachments(release))
- assert.EqualValues(t, 1, len(release.Attachments))
+ assert.Len(t, release.Attachments, 1)
assert.EqualValues(t, attach.UUID, release.Attachments[0].UUID)
assert.EqualValues(t, release.ID, release.Attachments[0].ReleaseID)
assert.EqualValues(t, "test2.txt", release.Attachments[0].Name)
@@ -241,7 +241,7 @@ func TestRelease_Update(t *testing.T) {
assert.NoError(t, UpdateRelease(user, gitRepo, release, nil, []string{attach.UUID}, nil))
release.Attachments = nil
assert.NoError(t, models.GetReleaseAttachments(release))
- assert.EqualValues(t, 0, len(release.Attachments))
+ assert.Empty(t, release.Attachments)
}
func TestRelease_createTag(t *testing.T) {