1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-04-17 12:06:50 +02:00
goreleaser/internal/pipe/artifacts/artifacts_test.go
2021-12-31 15:05:28 -03:00

41 lines
887 B
Go

package artifacts
import (
"os"
"path/filepath"
"testing"
"github.com/goreleaser/goreleaser/internal/artifact"
"github.com/goreleaser/goreleaser/internal/golden"
"github.com/goreleaser/goreleaser/pkg/config"
"github.com/goreleaser/goreleaser/pkg/context"
"github.com/stretchr/testify/require"
)
func TestArtifacts(t *testing.T) {
tmp := t.TempDir()
ctx := context.New(config.Project{
Dist: tmp,
})
ctx.Artifacts.Add(&artifact.Artifact{
Name: "foo",
Path: "foo.txt",
Type: artifact.Binary,
Goos: "darwin",
Goarch: "amd64",
Goarm: "7",
Extra: map[string]interface{}{
"foo": "bar",
},
})
require.NoError(t, Pipe{}.Run(ctx))
path := filepath.Join(tmp, "artifacts.json")
golden.RequireEqualJSON(t, golden.RequireReadFile(t, path))
info, err := os.Stat(path)
require.NoError(t, err)
require.Equal(t, "-rw-r--r--", info.Mode().String())
}