-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #120 from gistella/decompress-root-dir
Create the root dir if not included in an archive
- Loading branch information
Showing
6 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package use | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
) | ||
|
||
func TestDecompression(t *testing.T) { | ||
want := "testdata/must-gather.sample" | ||
tests := map[string]func(string, string) (string, error){ | ||
"testdata/must-gather.zip": ExtractZip, | ||
"testdata/must-gather.tar": ExtractTar, | ||
"testdata/must-gather.tar.gz": ExtractTarGz, | ||
} | ||
|
||
for path, f := range tests { | ||
mgRootDir, err := f(path, "testdata") | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
defer clearTestFiles(t) | ||
|
||
if want != mgRootDir { | ||
t.Errorf("expected %q, got %q", want, mgRootDir) | ||
} | ||
clearTestFiles(t) | ||
} | ||
} | ||
|
||
func clearTestFiles(t *testing.T) { | ||
t.Helper() | ||
|
||
err := os.RemoveAll("testdata/must-gather.sample") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
must-gather.sample |
Binary file not shown.
Binary file not shown.
Binary file not shown.