1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-20 03:59:26 +02:00
goreleaser/pkg/archive/archive_test.go
Carlos Alexandro Becker 979f8632b7
refactor: use require on all tests (#1839)
* refactor: use require on all tests

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* refactor: use require on all tests

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-10-06 12:48:04 +00:00

34 lines
876 B
Go

package archive
import (
"io/ioutil"
"os"
"testing"
"github.com/stretchr/testify/require"
)
func TestArchive(t *testing.T) {
folder, err := ioutil.TempDir("", "archivetest")
require.NoError(t, err)
empty, err := os.Create(folder + "/empty.txt")
require.NoError(t, err)
require.NoError(t, 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)
require.NoError(t, archive.Add("empty.txt", empty.Name()))
require.Error(t, archive.Add("dont.txt", empty.Name()+"_nope"))
require.NoError(t, archive.Close())
})
}
}
func newArchive(folder, format string, t *testing.T) Archive {
file, err := os.Create(folder + "/folder." + format)
require.NoError(t, err)
return New(file)
}