feat(image): support tar.gz image (fanal#40)

This commit is contained in:
Teppei Fukuda
2019-10-15 11:48:52 +03:00
committed by GitHub
parent 83f0e2b08b
commit 9e8f0bb4f0
9 changed files with 57 additions and 2 deletions

32
utils/utils_test.go Normal file
View File

@@ -0,0 +1,32 @@
package utils
import (
"os"
"testing"
)
func TestIsGzip(t *testing.T) {
var tests = []struct {
in string
want bool
}{
{"testdata/test.txt.gz", true},
{"testdata/test.tar.gz", true},
{"testdata/test.txt", false},
{"testdata/test.txt.zst", false},
{"testdata/aqua.png", false},
}
for _, tt := range tests {
t.Run(tt.in, func(t *testing.T) {
f, err := os.Open(tt.in)
if err != nil {
t.Fatalf("unknown error: %s", err)
}
got := IsGzip(f)
if got != tt.want {
t.Errorf("got %t, want %t", got, tt.want)
}
})
}
}