1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-22 04:08:49 +02:00
goreleaser/pkg/archive/archive_test.go
J Taylor 081430bcc7
feat: xz compression (#1422)
* feat: xz compression

* remove .xz feature

* fix: format code with gofmt

* use larger dict for better compression

* Update pkg/archive/tarxz/tarxz.go

Co-authored-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
2020-04-13 12:53:03 +00:00

35 lines
878 B
Go

package archive
import (
"io/ioutil"
"os"
"testing"
"github.com/stretchr/testify/assert"
)
func TestArchive(t *testing.T) {
var assert = assert.New(t)
folder, err := ioutil.TempDir("", "archivetest")
assert.NoError(err)
empty, err := os.Create(folder + "/empty.txt")
assert.NoError(err)
assert.NoError(os.Mkdir(folder+"/folder-inside", 0755))
for _, format := range []string{"tar.gz", "zip", "gz", "tar.xz", "willbeatargzanyway"} {
format := format
t.Run(format, func(t *testing.T) {
var archive = newArchive(folder, format, t)
assert.NoError(archive.Add("empty.txt", empty.Name()))
assert.Error(archive.Add("dont.txt", empty.Name()+"_nope"))
assert.NoError(archive.Close())
})
}
}
func newArchive(folder, format string, t *testing.T) Archive {
file, err := os.Create(folder + "/folder." + format)
assert.NoError(t, err)
return New(file)
}