1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-26 04:22:05 +02:00
goreleaser/pkg/archive/archive_test.go
Carlos Alexandro Becker 860b4a8f81
chore: gofumpt & lint (#2190)
Signed-off-by: Carlos Becker <caarlos0@gmail.com>
2021-04-25 14:20:49 -03:00

32 lines
810 B
Go

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