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