From 8780dda26a819b4b93caba75a893fb082849406e Mon Sep 17 00:00:00 2001 From: Nick White Date: Tue, 27 Jul 2021 14:22:03 +0100 Subject: internal/pipeline: add tests for DetectQueueType --- internal/pipeline/put_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'internal/pipeline/put_test.go') diff --git a/internal/pipeline/put_test.go b/internal/pipeline/put_test.go index 9cc8b02..af18ab4 100644 --- a/internal/pipeline/put_test.go +++ b/internal/pipeline/put_test.go @@ -7,6 +7,7 @@ package pipeline import ( "errors" "os" + "rescribe.xyz/bookpipeline" "testing" ) @@ -49,3 +50,26 @@ func Test_CheckImages(t *testing.T) { }) } } + +func Test_DetectQueueType(t *testing.T) { + conn := &bookpipeline.LocalConn{} + + cases := []struct { + dir string + qid string + }{ + {"testdata/mostlypng", conn.WipeQueueId()}, + {"testdata/mostlyjpg", conn.PreQueueId()}, + {"testdata/equalpngandjpg", conn.PreQueueId()}, + {"testdata/nonexistent", conn.PreQueueId()}, + } + + for _, c := range cases { + t.Run(c.dir, func(t *testing.T) { + qid := DetectQueueType(c.dir, conn) + if qid != c.qid { + t.Fatalf("Error, expected qid %v, got qid %v", qid, c.qid) + } + }) + } +} -- cgit v1.2.1-24-ge1ad