summaryrefslogtreecommitdiff
path: root/internal/pipeline/put_test.go
diff options
context:
space:
mode:
authorNick White <git@njw.name>2021-07-27 11:31:50 +0100
committerNick White <git@njw.name>2021-07-27 11:31:50 +0100
commit13b8605ba5f8554aedf658aacee5bc436887cbfa (patch)
tree92f30869ad7c6abdf6037bf8034c9924d22fd845 /internal/pipeline/put_test.go
parent09221d592216f8e7310ceb90432564fd866f469f (diff)
internal/pipeline: Add notreadable test to CheckImages
Diffstat (limited to 'internal/pipeline/put_test.go')
-rw-r--r--internal/pipeline/put_test.go17
1 files changed, 16 insertions, 1 deletions
diff --git a/internal/pipeline/put_test.go b/internal/pipeline/put_test.go
index 68dd173..9cc8b02 100644
--- a/internal/pipeline/put_test.go
+++ b/internal/pipeline/put_test.go
@@ -6,6 +6,7 @@ package pipeline
import (
"errors"
+ "os"
"testing"
)
@@ -16,11 +17,18 @@ func Test_CheckImages(t *testing.T) {
}{
{"testdata/good", nil},
{"testdata/bad", errors.New("Decoding image testdata/bad/bad.png failed: png: invalid format: invalid checksum")},
- {"testdata/nonexistent", nil},
+ {"testdata/notreadable", errors.New("Opening image testdata/notreadable/1.png failed: open testdata/notreadable/1.png: permission denied")},
}
for _, c := range cases {
t.Run(c.dir, func(t *testing.T) {
+ if c.dir == "testdata/notreadable" {
+ err := os.Chmod("testdata/notreadable/1.png", 0000)
+ if err != nil {
+ t.Fatalf("Error preparing test by setting file to be unreadable: %v", err)
+ }
+ }
+
err := CheckImages(c.dir)
if err == nil && c.err != nil {
t.Fatalf("Expected error '%v', got no error", c.err)
@@ -31,6 +39,13 @@ func Test_CheckImages(t *testing.T) {
if err != nil && c.err != nil && err.Error() != c.err.Error() {
t.Fatalf("Got an unexpected error, expected '%v', got '%v'", c.err, err)
}
+
+ if c.dir == "testdata/notreadable" {
+ err := os.Chmod("testdata/notreadable/1.png", 0644)
+ if err != nil {
+ t.Fatalf("Error resetting test by setting file to be readable: %v", err)
+ }
+ }
})
}
}