diff options
author | Nick White <git@njw.name> | 2021-07-27 11:14:05 +0100 |
---|---|---|
committer | Nick White <git@njw.name> | 2021-07-27 11:14:05 +0100 |
commit | 09221d592216f8e7310ceb90432564fd866f469f (patch) | |
tree | ab8e2ee7b8885e1ab919ea7376e3ddf3c12441be /internal | |
parent | 4773d6f74f9e31db4783dd99624a55947b21b58d (diff) |
internal/pipeline: Add a test for CheckImages
Diffstat (limited to 'internal')
-rw-r--r-- | internal/pipeline/put_test.go | 36 | ||||
-rw-r--r-- | internal/pipeline/testdata/bad/1.png | bin | 0 -> 9123 bytes | |||
-rw-r--r-- | internal/pipeline/testdata/bad/bad.png | bin | 0 -> 9114 bytes | |||
-rw-r--r-- | internal/pipeline/testdata/good/1.png | bin | 0 -> 9123 bytes | |||
-rw-r--r-- | internal/pipeline/testdata/good/2.png | bin | 0 -> 14823 bytes |
5 files changed, 36 insertions, 0 deletions
diff --git a/internal/pipeline/put_test.go b/internal/pipeline/put_test.go new file mode 100644 index 0000000..68dd173 --- /dev/null +++ b/internal/pipeline/put_test.go @@ -0,0 +1,36 @@ +// Copyright 2021 Nick White. +// Use of this source code is governed by the GPLv3 +// license that can be found in the LICENSE file. + +package pipeline + +import ( + "errors" + "testing" +) + +func Test_CheckImages(t *testing.T) { + cases := []struct { + dir string + err error + }{ + {"testdata/good", nil}, + {"testdata/bad", errors.New("Decoding image testdata/bad/bad.png failed: png: invalid format: invalid checksum")}, + {"testdata/nonexistent", nil}, + } + + for _, c := range cases { + t.Run(c.dir, func(t *testing.T) { + err := CheckImages(c.dir) + if err == nil && c.err != nil { + t.Fatalf("Expected error '%v', got no error", c.err) + } + if err != nil && c.err == nil { + t.Fatalf("Expected no error, got error '%v'", err) + } + if err != nil && c.err != nil && err.Error() != c.err.Error() { + t.Fatalf("Got an unexpected error, expected '%v', got '%v'", c.err, err) + } + }) + } +} diff --git a/internal/pipeline/testdata/bad/1.png b/internal/pipeline/testdata/bad/1.png Binary files differnew file mode 100644 index 0000000..8f90f19 --- /dev/null +++ b/internal/pipeline/testdata/bad/1.png diff --git a/internal/pipeline/testdata/bad/bad.png b/internal/pipeline/testdata/bad/bad.png Binary files differnew file mode 100644 index 0000000..77f2d14 --- /dev/null +++ b/internal/pipeline/testdata/bad/bad.png diff --git a/internal/pipeline/testdata/good/1.png b/internal/pipeline/testdata/good/1.png Binary files differnew file mode 100644 index 0000000..8f90f19 --- /dev/null +++ b/internal/pipeline/testdata/good/1.png diff --git a/internal/pipeline/testdata/good/2.png b/internal/pipeline/testdata/good/2.png Binary files differnew file mode 100644 index 0000000..a9ecd94 --- /dev/null +++ b/internal/pipeline/testdata/good/2.png |