diff --git a/pipeline/archive/tar/tar_test.go b/pipeline/archive/tar/tar_test.go new file mode 100644 index 000000000..cf7164e78 --- /dev/null +++ b/pipeline/archive/tar/tar_test.go @@ -0,0 +1,27 @@ +package tar + +import ( + "io/ioutil" + "os" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestTarGzFile(t *testing.T) { + var assert = assert.New(t) + + folder, err := ioutil.TempDir("", "targztest") + assert.NoError(err) + + file, err := os.Create(folder + "/folder.tar.gz") + assert.NoError(err) + + empty, err := os.Create(folder + "/empty.txt") + assert.NoError(err) + + archive := New(file) + assert.NoError(archive.Add("empty.txt", empty.Name())) + assert.Error(archive.Add("dont.txt", empty.Name()+"_nope")) + assert.NoError(archive.Close()) +} diff --git a/pipeline/archive/zip/zip_test.go b/pipeline/archive/zip/zip_test.go new file mode 100644 index 000000000..2084be2dc --- /dev/null +++ b/pipeline/archive/zip/zip_test.go @@ -0,0 +1,27 @@ +package zip + +import ( + "io/ioutil" + "os" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestZipFile(t *testing.T) { + var assert = assert.New(t) + + folder, err := ioutil.TempDir("", "ziptest") + assert.NoError(err) + + file, err := os.Create(folder + "/folder.zip") + assert.NoError(err) + + empty, err := os.Create(folder + "/empty.txt") + assert.NoError(err) + + archive := New(file) + assert.NoError(archive.Add("empty.txt", empty.Name())) + assert.Error(archive.Add("dont.txt", empty.Name()+"_nope")) + assert.NoError(archive.Close()) +}