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 73641c71ac
feat: file mappings in archives (#2347)
* refactor: archive files

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

* feat: better archives

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

* feat: better archives

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

* fix: test todos

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

* fix: go mod tidy et al

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

* fix: improve docs and remove typoe 'licence' from defaults

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

* test: fixes

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

* fix: error string

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

* test: remove some logs

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

* test: use utc

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
2021-07-21 22:09:02 -03:00

39 lines
965 B
Go

package archive
import (
"os"
"testing"
"github.com/goreleaser/goreleaser/pkg/config"
"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(config.File{
Source: empty.Name(),
Destination: "empty.txt",
}))
require.Error(t, archive.Add(config.File{
Source: empty.Name() + "_nope",
Destination: "dont.txt",
}))
})
}
}