forked from cihub/seelog
-
Notifications
You must be signed in to change notification settings - Fork 0
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 cihub#113 from mlallaouret/feature/add_gzip_compre…
…ssion_format Add gzip compression format
- Loading branch information
Showing
7 changed files
with
341 additions
and
67 deletions.
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
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,59 @@ | ||
package seelog | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
func TestGzip(t *testing.T) { | ||
defer cleanupWriterTest(t) | ||
|
||
files := make(map[string][]byte) | ||
files["file1"] = []byte("I am a log") | ||
err := createGzip("./gzip.gz", files["file1"]) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
decompressedFile, err := unGzip("./gzip.gz") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
equal := reflect.DeepEqual(files["file1"], decompressedFile) | ||
if !equal { | ||
t.Fatal("gzip(ungzip(file)) should be equal to file") | ||
} | ||
} | ||
|
||
func TestTar(t *testing.T) { | ||
defer cleanupWriterTest(t) | ||
files := make(map[string][]byte) | ||
files["file1"] = []byte("I am a log") | ||
files["file2"] = []byte("I am another log") | ||
tar, err := createTar(files) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
resultFiles, err := unTar(tar) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
equal := reflect.DeepEqual(files, resultFiles) | ||
if !equal { | ||
t.Fatal("untar(tar(files)) should be equal to files") | ||
} | ||
} | ||
|
||
func TestIsTar(t *testing.T) { | ||
defer cleanupWriterTest(t) | ||
files := make(map[string][]byte) | ||
files["file1"] = []byte("I am a log") | ||
files["file2"] = []byte("I am another log") | ||
tar, _ := createTar(files) | ||
|
||
if !isTar(tar) { | ||
t.Fatal("tar(files) should be recognized as a tar file") | ||
} | ||
} |
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
Oops, something went wrong.