diff options
Diffstat (limited to 'vendor/github.com/hashicorp/go-getter/decompress_testing.go')
-rw-r--r-- | vendor/github.com/hashicorp/go-getter/decompress_testing.go | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/vendor/github.com/hashicorp/go-getter/decompress_testing.go b/vendor/github.com/hashicorp/go-getter/decompress_testing.go index 91cf33d..b2f662a 100644 --- a/vendor/github.com/hashicorp/go-getter/decompress_testing.go +++ b/vendor/github.com/hashicorp/go-getter/decompress_testing.go | |||
@@ -18,16 +18,18 @@ import ( | |||
18 | 18 | ||
19 | // TestDecompressCase is a single test case for testing decompressors | 19 | // TestDecompressCase is a single test case for testing decompressors |
20 | type TestDecompressCase struct { | 20 | type TestDecompressCase struct { |
21 | Input string // Input is the complete path to the input file | 21 | Input string // Input is the complete path to the input file |
22 | Dir bool // Dir is whether or not we're testing directory mode | 22 | Dir bool // Dir is whether or not we're testing directory mode |
23 | Err bool // Err is whether we expect an error or not | 23 | Err bool // Err is whether we expect an error or not |
24 | DirList []string // DirList is the list of files for Dir mode | 24 | DirList []string // DirList is the list of files for Dir mode |
25 | FileMD5 string // FileMD5 is the expected MD5 for a single file | 25 | FileMD5 string // FileMD5 is the expected MD5 for a single file |
26 | Mtime *time.Time // Mtime is the optionally expected mtime for a single file (or all files if in Dir mode) | 26 | Mtime *time.Time // Mtime is the optionally expected mtime for a single file (or all files if in Dir mode) |
27 | } | 27 | } |
28 | 28 | ||
29 | // TestDecompressor is a helper function for testing generic decompressors. | 29 | // TestDecompressor is a helper function for testing generic decompressors. |
30 | func TestDecompressor(t testing.T, d Decompressor, cases []TestDecompressCase) { | 30 | func TestDecompressor(t testing.T, d Decompressor, cases []TestDecompressCase) { |
31 | t.Helper() | ||
32 | |||
31 | for _, tc := range cases { | 33 | for _, tc := range cases { |
32 | t.Logf("Testing: %s", tc.Input) | 34 | t.Logf("Testing: %s", tc.Input) |
33 | 35 | ||
@@ -72,9 +74,13 @@ func TestDecompressor(t testing.T, d Decompressor, cases []TestDecompressCase) { | |||
72 | 74 | ||
73 | if tc.Mtime != nil { | 75 | if tc.Mtime != nil { |
74 | actual := fi.ModTime() | 76 | actual := fi.ModTime() |
75 | expected := *tc.Mtime | 77 | if tc.Mtime.Unix() > 0 { |
76 | if actual != expected { | 78 | expected := *tc.Mtime |
77 | t.Fatalf("err %s: expected mtime '%s' for %s, got '%s'", tc.Input, expected.String(), dst, actual.String()) | 79 | if actual != expected { |
80 | t.Fatalf("err %s: expected mtime '%s' for %s, got '%s'", tc.Input, expected.String(), dst, actual.String()) | ||
81 | } | ||
82 | } else if actual.Unix() <= 0 { | ||
83 | t.Fatalf("err %s: expected mtime to be > 0, got '%s'", actual.String()) | ||
78 | } | 84 | } |
79 | } | 85 | } |
80 | 86 | ||
@@ -103,10 +109,15 @@ func TestDecompressor(t testing.T, d Decompressor, cases []TestDecompressCase) { | |||
103 | t.Fatalf("err: %s", err) | 109 | t.Fatalf("err: %s", err) |
104 | } | 110 | } |
105 | actual := fi.ModTime() | 111 | actual := fi.ModTime() |
106 | expected := *tc.Mtime | 112 | if tc.Mtime.Unix() > 0 { |
107 | if actual != expected { | 113 | expected := *tc.Mtime |
108 | t.Fatalf("err %s: expected mtime '%s' for %s, got '%s'", tc.Input, expected.String(), path, actual.String()) | 114 | if actual != expected { |
115 | t.Fatalf("err %s: expected mtime '%s' for %s, got '%s'", tc.Input, expected.String(), path, actual.String()) | ||
116 | } | ||
117 | } else if actual.Unix() < 0 { | ||
118 | t.Fatalf("err %s: expected mtime to be > 0, got '%s'", actual.String()) | ||
109 | } | 119 | } |
120 | |||
110 | } | 121 | } |
111 | } | 122 | } |
112 | }() | 123 | }() |