1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-10 03:47:03 +02:00
goreleaser/pkg/archive/archive_test.go
Carlos Alexandro Becker d2fa6d5821
feat: support gzip format (#959)
* feat: support gzip format

* fix: wrong .gz detection

* docs: gz + multiple build
2019-02-07 12:12:20 -02:00

35 lines
868 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", "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)
}