1
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-01-03 14:57:55 -05:00

archiver: tests: hopefully final tweak

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.
This commit is contained in:
Kyle Evans 2020-05-05 18:04:20 -05:00
parent be77f9ed59
commit 67d491ba7c

View File

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