diff options
-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 |