mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-22 23:26:39 -08:00
feat(image): support tar.gz image (fanal#40)
This commit is contained in:
32
utils/utils_test.go
Normal file
32
utils/utils_test.go
Normal 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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user