1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-10 03:47:03 +02:00
goreleaser/internal/extrafiles/extra_files_test.go

69 lines
1.4 KiB
Go
Raw Normal View History

package extrafiles
import (
"testing"
"github.com/goreleaser/goreleaser/pkg/config"
"github.com/stretchr/testify/assert"
)
func TestShouldGetAllFiles(t *testing.T) {
assert := assert.New(t)
globs := []config.ExtraFile{
{Glob: "./testdata/file1.golden"},
}
files, err := Find(globs)
assert.NoError(err)
assert.Equal(1, len(files))
path, ok := files["file1.golden"]
assert.True(ok)
assert.Equal(path, "./testdata/file1.golden")
}
func TestShouldGetAllFilesWithGoldenExtension(t *testing.T) {
assert := assert.New(t)
globs := []config.ExtraFile{
{Glob: "./testdata/*.golden"},
}
files, err := Find(globs)
assert.NoError(err)
assert.Equal(2, len(files))
path, ok := files["file1.golden"]
assert.True(ok)
assert.Equal(path, "testdata/file1.golden")
path, ok = files["file2.golden"]
assert.True(ok)
assert.Equal(path, "testdata/file2.golden")
}
func TestShouldGetAllFilesInsideTestdata(t *testing.T) {
assert := assert.New(t)
globs := []config.ExtraFile{
{Glob: "./testdata/*"},
}
files, err := Find(globs)
assert.NoError(err)
assert.Equal(3, len(files))
path, ok := files["file1.golden"]
assert.True(ok)
assert.Equal(path, "testdata/file1.golden")
path, ok = files["file2.golden"]
assert.True(ok)
assert.Equal(path, "testdata/file2.golden")
path, ok = files["file3.gold"]
assert.True(ok)
assert.Equal(path, "testdata/file3.gold")
}