]> source.dussan.org Git - gitea.git/commitdiff
archiver: tests: hopefully final tweak
authorKyle Evans <kevans@FreeBSD.org>
Tue, 5 May 2020 23:04:20 +0000 (18:04 -0500)
committerKyle Evans <kevans@FreeBSD.org>
Tue, 5 May 2020 23:04:20 +0000 (18:04 -0500)
Things got shuffled around such that we carefully build up and release
requests from the queue, so we can validate the state of the queue at each
step. Fix some assertions that no longer hold true as fallout.

services/archiver/archiver_test.go

index 63ef36fb0fdf9fc91f5b92a961eb6b7310936262..ee5904ef0b0e29bef9ec7dcfa843d001644b13ed 100644 (file)
@@ -169,25 +169,19 @@ func TestArchive_Basic(t *testing.T) {
        assert.Equal(t, len(archiveInProgress), 3)
 
        zipReq2 := DeriveRequestFrom(ctx, firstCommit+".zip")
-       // After completion, zipReq should have dropped out of the queue.  Make sure
-       // we didn't get it handed back to us, but they should otherwise be
-       // equivalent requests.
+       // This zipReq should match what's sitting in the queue, as we haven't
+       // let it release yet.  From the consumer's point of view, this looks like
+       // a long-running archive task.
        assert.Equal(t, zipReq, zipReq2)
-       assert.False(t, zipReq == zipReq2)
 
        // We still have the other three stalled at completion, waiting to remove
        // from archiveInProgress.  Try to submit this new one before its
        // predecessor has cleared out of the queue.
        ArchiveRepository(zipReq2)
 
-       // Make sure we didn't enqueue anything from this new one, and that the
-       // queue hasn't changed.
+       // Make sure the queue hasn't grown any.
        assert.Equal(t, len(archiveInProgress), 3)
 
-       for _, req := range archiveInProgress {
-               assert.False(t, req == zipReq2)
-       }
-
        // Make sure the queue drains properly
        releaseOneEntry(t, inFlight)
        assert.Equal(t, len(archiveInProgress), 2)
@@ -196,6 +190,13 @@ func TestArchive_Basic(t *testing.T) {
        releaseOneEntry(t, inFlight)
        assert.Equal(t, len(archiveInProgress), 0)
 
+       zipReq2 = DeriveRequestFrom(ctx, firstCommit+".zip")
+       // Now, we're guaranteed to have released the original zipReq from the queue.
+       // Ensure that we don't get handed back the released entry somehow, but they
+       // should remain functionally equivalent in all fields.
+       assert.Equal(t, zipReq, zipReq2)
+       assert.False(t, zipReq == zipReq2)
+
        // Same commit, different compression formats should have different names.
        // Ideally, the extension would match what we originally requested.
        assert.NotEqual(t, zipReq.GetArchiveName(), tgzReq.GetArchiveName())