github.com/hashicorp/go-getter/v2@v2.2.2/decompress_txz_test.go (about) 1 package getter 2 3 import ( 4 "path/filepath" 5 "testing" 6 ) 7 8 func TestTarXzDecompressor(t *testing.T) { 9 10 multiplePaths := []string{"dir/", "dir/test2", "test1"} 11 orderingPaths := []string{"workers/", "workers/mq/", "workers/mq/__init__.py"} 12 13 cases := []TestDecompressCase{ 14 { 15 "empty.tar.xz", 16 false, 17 true, 18 nil, 19 "", 20 nil, 21 }, 22 23 { 24 "single.tar.xz", 25 false, 26 false, 27 nil, 28 "d3b07384d113edec49eaa6238ad5ff00", 29 nil, 30 }, 31 32 { 33 "single.tar.xz", 34 true, 35 false, 36 []string{"file"}, 37 "", 38 nil, 39 }, 40 41 { 42 "multiple.tar.xz", 43 true, 44 false, 45 []string{"file1", "file2"}, 46 "", 47 nil, 48 }, 49 50 { 51 "multiple.tar.xz", 52 false, 53 true, 54 nil, 55 "", 56 nil, 57 }, 58 59 { 60 "multiple_dir.tar.xz", 61 true, 62 false, 63 multiplePaths, 64 "", 65 nil, 66 }, 67 68 // Tests when the file is listed before the parent folder 69 { 70 "ordering.tar.xz", 71 true, 72 false, 73 orderingPaths, 74 "", 75 nil, 76 }, 77 } 78 79 for i, tc := range cases { 80 cases[i].Input = filepath.Join("./testdata", "decompress-txz", tc.Input) 81 } 82 83 TestDecompressor(t, new(TarXzDecompressor), cases) 84 }