|
@@ -101,6 +101,11 @@ func TestDecompressStreamGzip(t *testing.T) {
|
|
|
t.Fatalf("Fail to create an archive file for test : %s.", output)
|
|
|
}
|
|
|
archive, err := os.Open(tmp + "archive.gz")
|
|
|
+ if err != nil {
|
|
|
+ t.Fatalf("Fail to open file archive.gz")
|
|
|
+ }
|
|
|
+ defer archive.Close()
|
|
|
+
|
|
|
_, err = DecompressStream(archive)
|
|
|
if err != nil {
|
|
|
t.Fatalf("Failed to decompress a gzip file.")
|
|
@@ -114,6 +119,11 @@ func TestDecompressStreamBzip2(t *testing.T) {
|
|
|
t.Fatalf("Fail to create an archive file for test : %s.", output)
|
|
|
}
|
|
|
archive, err := os.Open(tmp + "archive.bz2")
|
|
|
+ if err != nil {
|
|
|
+ t.Fatalf("Fail to open file archive.bz2")
|
|
|
+ }
|
|
|
+ defer archive.Close()
|
|
|
+
|
|
|
_, err = DecompressStream(archive)
|
|
|
if err != nil {
|
|
|
t.Fatalf("Failed to decompress a bzip2 file.")
|
|
@@ -130,6 +140,10 @@ func TestDecompressStreamXz(t *testing.T) {
|
|
|
t.Fatalf("Fail to create an archive file for test : %s.", output)
|
|
|
}
|
|
|
archive, err := os.Open(tmp + "archive.xz")
|
|
|
+ if err != nil {
|
|
|
+ t.Fatalf("Fail to open file archive.xz")
|
|
|
+ }
|
|
|
+ defer archive.Close()
|
|
|
_, err = DecompressStream(archive)
|
|
|
if err != nil {
|
|
|
t.Fatalf("Failed to decompress an xz file.")
|
|
@@ -141,6 +155,8 @@ func TestCompressStreamXzUnsuported(t *testing.T) {
|
|
|
if err != nil {
|
|
|
t.Fatalf("Fail to create the destination file")
|
|
|
}
|
|
|
+ defer dest.Close()
|
|
|
+
|
|
|
_, err = CompressStream(dest, Xz)
|
|
|
if err == nil {
|
|
|
t.Fatalf("Should fail as xz is unsupported for compression format.")
|
|
@@ -152,6 +168,8 @@ func TestCompressStreamBzip2Unsupported(t *testing.T) {
|
|
|
if err != nil {
|
|
|
t.Fatalf("Fail to create the destination file")
|
|
|
}
|
|
|
+ defer dest.Close()
|
|
|
+
|
|
|
_, err = CompressStream(dest, Xz)
|
|
|
if err == nil {
|
|
|
t.Fatalf("Should fail as xz is unsupported for compression format.")
|
|
@@ -163,6 +181,8 @@ func TestCompressStreamInvalid(t *testing.T) {
|
|
|
if err != nil {
|
|
|
t.Fatalf("Fail to create the destination file")
|
|
|
}
|
|
|
+ defer dest.Close()
|
|
|
+
|
|
|
_, err = CompressStream(dest, -1)
|
|
|
if err == nil {
|
|
|
t.Fatalf("Should fail as xz is unsupported for compression format.")
|
|
@@ -795,6 +815,8 @@ func TestUntarUstarGnuConflict(t *testing.T) {
|
|
|
if err != nil {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
+ defer f.Close()
|
|
|
+
|
|
|
found := false
|
|
|
tr := tar.NewReader(f)
|
|
|
// Iterate through the files in the archive.
|