Added test case for gzip that expands the data and compares to what we put in
This commit is contained in:
parent
801e5aaa30
commit
2d92fd8733
|
@ -1,7 +1,9 @@
|
||||||
package compress
|
package compress
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"compress/gzip"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -54,6 +56,8 @@ func TestDetectFilename(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const expectedFileContents = "Hello world!"
|
||||||
|
|
||||||
func TestSimpleCompress(t *testing.T) {
|
func TestSimpleCompress(t *testing.T) {
|
||||||
const config = `
|
const config = `
|
||||||
{
|
{
|
||||||
|
@ -137,10 +141,13 @@ func TestCompressOptions(t *testing.T) {
|
||||||
artifact := testArchive(t, config)
|
artifact := testArchive(t, config)
|
||||||
defer artifact.Destroy()
|
defer artifact.Destroy()
|
||||||
|
|
||||||
// Verify things look good
|
filename := "package.gz"
|
||||||
_, err := os.Stat("package.gz")
|
archive, _ := os.Open(filename)
|
||||||
if err != nil {
|
gzipReader, _ := gzip.NewReader(archive)
|
||||||
t.Errorf("Unable to read archive: %s", err)
|
data, _ := ioutil.ReadAll(gzipReader)
|
||||||
|
|
||||||
|
if string(data) != expectedFileContents {
|
||||||
|
t.Errorf("Expected:\n%s\nFound:\n%s\n", expectedFileContents, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue