From cdade0c27fd31029f837a625e67e5090184a053c Mon Sep 17 00:00:00 2001 From: Tomas Aparicio Date: Mon, 6 Apr 2015 14:59:59 +0200 Subject: [PATCH] feat(#13): metadata tests --- metadata.go | 2 +- metadata_test.go | 27 ++++++++++++++++++++------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/metadata.go b/metadata.go index 10c32e7..a3645a3 100644 --- a/metadata.go +++ b/metadata.go @@ -13,8 +13,8 @@ type ImageSize struct { type ImageMetadata struct { Orientation int - Alpha bool Channels int + Alpha bool Profile bool Type string Space string diff --git a/metadata_test.go b/metadata_test.go index 49c0b48..f5021ec 100644 --- a/metadata_test.go +++ b/metadata_test.go @@ -32,23 +32,36 @@ func TestSize(t *testing.T) { func TestMetadata(t *testing.T) { files := []struct { - name string - format string + name string + format string + orientation int + alpha bool + profile bool + space string }{ - {"test.jpg", "jpeg"}, - {"test.png", "png"}, - {"test.webp", "webp"}, + {"test.jpg", "jpeg", 0, false, false, "bicubic"}, + {"test.png", "png", 0, true, false, "bicubic"}, + {"test.webp", "webp", 0, false, false, "bicubic"}, } for _, file := range files { - size, err := Metadata(readFile(file.name)) + metadata, err := Metadata(readFile(file.name)) if err != nil { t.Fatalf("Cannot read the image: %#v", err) } - if size.Type != file.format { + if metadata.Type != file.format { t.Fatalf("Unexpected image format: %s", file.format) } + if metadata.Orientation != file.orientation { + t.Fatalf("Unexpected image orientation: %d != %d", metadata.Orientation, file.orientation) + } + if metadata.Alpha != file.alpha { + t.Fatalf("Unexpected image alpha: %s != ", metadata.Alpha, file.alpha) + } + if metadata.Profile != file.profile { + t.Fatalf("Unexpected image profile: %s != %s", metadata.Profile, file.profile) + } } }