]> source.dussan.org Git - gitea.git/commitdiff
archiver: tests: simplify a bit further
authorKyle Evans <kevans@FreeBSD.org>
Wed, 6 May 2020 00:13:57 +0000 (19:13 -0500)
committerKyle Evans <kevans@FreeBSD.org>
Wed, 6 May 2020 00:13:57 +0000 (19:13 -0500)
We don't need to risk failure and use time.ParseDuration to get 2 *
time.Second.

else if isn't really necessary if the conditions are simple enough and lead
to the same result.

services/archiver/archiver_test.go

index ee5904ef0b0e29bef9ec7dcfa843d001644b13ed..5b38cb55e9ecb487d6897e99456865eca0e1ae35 100644 (file)
@@ -137,8 +137,7 @@ func TestArchive_Basic(t *testing.T) {
        ArchiveRepository(zipReq)
 
        // Sleep two seconds to make sure the queue doesn't change.
-       twoSeconds, _ := time.ParseDuration("2s")
-       time.Sleep(twoSeconds)
+       time.Sleep(2 * time.Second)
        assert.Equal(t, 3, len(archiveInProgress))
 
        // Release them all, they'll then stall at the archiveQueueReleaseCond while
@@ -150,9 +149,7 @@ func TestArchive_Basic(t *testing.T) {
        // 8 second timeout for them all to complete.
        timeout := time.Now().Add(8 * time.Second)
        for {
-               if allComplete(inFlight) {
-                       break
-               } else if time.Now().After(timeout) {
+               if allComplete(inFlight) || time.Now().After(timeout) {
                        break
                }
        }