forked from hashicorp/go-getter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
decompress_test.go
50 lines (38 loc) · 1.7 KB
/
decompress_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package getter
import (
"testing"
)
func TestLimitedDecompressors(t *testing.T) {
const (
maxFiles = 111
maxSize = 222
)
checkFileSizeLimit := func(limit int64) {
if limit != maxSize {
t.Fatalf("expected FileSizeLimit of %d, got %d", maxSize, limit)
}
}
checkFilesLimit := func(limit int) {
if limit != maxFiles {
t.Fatalf("expected FilesLimit of %d, got %d", maxFiles, limit)
}
}
decompressors := LimitedDecompressors(maxFiles, maxSize)
checkFilesLimit(decompressors["tar"].(*TarDecompressor).FilesLimit)
checkFileSizeLimit(decompressors["tar"].(*TarDecompressor).FileSizeLimit)
checkFilesLimit(decompressors["tar.bz2"].(*TarBzip2Decompressor).FilesLimit)
checkFileSizeLimit(decompressors["tar.bz2"].(*TarBzip2Decompressor).FileSizeLimit)
checkFilesLimit(decompressors["tar.gz"].(*TarGzipDecompressor).FilesLimit)
checkFileSizeLimit(decompressors["tar.gz"].(*TarGzipDecompressor).FileSizeLimit)
checkFilesLimit(decompressors["tar.xz"].(*TarXzDecompressor).FilesLimit)
checkFileSizeLimit(decompressors["tar.xz"].(*TarXzDecompressor).FileSizeLimit)
checkFilesLimit(decompressors["tar.zst"].(*TarZstdDecompressor).FilesLimit)
checkFileSizeLimit(decompressors["tar.zst"].(*TarZstdDecompressor).FileSizeLimit)
checkFilesLimit(decompressors["zip"].(*ZipDecompressor).FilesLimit)
checkFileSizeLimit(decompressors["zip"].(*ZipDecompressor).FileSizeLimit)
// ones with file size limit only
checkFileSizeLimit(decompressors["bz2"].(*Bzip2Decompressor).FileSizeLimit)
checkFileSizeLimit(decompressors["gz"].(*GzipDecompressor).FileSizeLimit)
checkFileSizeLimit(decompressors["xz"].(*XzDecompressor).FileSizeLimit)
checkFileSizeLimit(decompressors["zst"].(*ZstdDecompressor).FileSizeLimit)
}