diff options
author | Nick White <git@njw.name> | 2021-08-02 10:45:53 +0100 |
---|---|---|
committer | Nick White <git@njw.name> | 2021-08-02 10:45:53 +0100 |
commit | 4b7a4bd1b87d1dbba283e577aa03ce7e390d85d8 (patch) | |
tree | e5e7e55763cfbfd74e651a4ba5bea5b7394a93a9 /internal/pipeline/put_test.go | |
parent | 5310a5e77e945debdc7bd6f149ba87fab13902db (diff) |
internal/pipeline: Add test (incomplete but working) for UploadImages
Diffstat (limited to 'internal/pipeline/put_test.go')
-rw-r--r-- | internal/pipeline/put_test.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/internal/pipeline/put_test.go b/internal/pipeline/put_test.go index af18ab4..912a4ef 100644 --- a/internal/pipeline/put_test.go +++ b/internal/pipeline/put_test.go @@ -6,6 +6,7 @@ package pipeline import ( "errors" + "log" "os" "rescribe.xyz/bookpipeline" "testing" @@ -73,3 +74,38 @@ func Test_DetectQueueType(t *testing.T) { }) } } + +func Test_UploadImages(t *testing.T) { + var slog StrLog + vlog := log.New(&slog, "", 0) + var conns []connection + + conns = append(conns, connection{name: "local", c: &bookpipeline.LocalConn{Logger: vlog}}) + + if !testing.Short() { + conns = append(conns, connection{name: "aws", c: &bookpipeline.AwsConn{Logger: vlog}}) + } + + for _, conn := range conns { + t.Run(conn.name, func(t *testing.T) { + err := conn.c.Init() + if err != nil { + t.Fatalf("Could not initialise %s connection: %v\nLog: %s", conn.name, err, slog.log) + } + err = conn.c.TestInit() + if err != nil { + t.Fatalf("Failed in test initialisalisation for %s: %v\nLog: %s", conn.name, err, slog.log) + } + slog.log = "" + + err = UploadImages("testdata/good", "good", conn.c, conn.c.TestStorageId()) + if err != nil { + t.Fatalf("Error in UploadImages for %s: %v\nLog: %s", conn.name, err, slog.log) + } + + // TODO: decide on whether to use TestStorageId or just the WIPStorageId as with other tests, and align other tests to this if needed + // TODO: download all files and test that they match + // TODO: remove test files from conn storage + }) + } +} |