1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-04 03:11:55 +02:00
goreleaser/internal/skips/skips_test.go
Carlos Alexandro Becker d4540f884f
test: fix unstable test
2023-10-30 15:50:30 +00:00

41 lines
1.0 KiB
Go

package skips_test
import (
"testing"
"github.com/goreleaser/goreleaser/internal/skips"
"github.com/goreleaser/goreleaser/internal/testctx"
"github.com/stretchr/testify/require"
"golang.org/x/exp/maps"
)
func TestString(t *testing.T) {
for expect, keys := range map[string][]skips.Key{
"": nil,
"ko and sbom": {skips.SBOM, skips.Ko},
"before, ko and sbom": {skips.SBOM, skips.Ko, skips.Before},
} {
t.Run(expect, func(t *testing.T) {
ctx := testctx.New(testctx.Skip(keys...))
require.Equal(t, expect, skips.String(ctx))
})
}
}
func TestAny(t *testing.T) {
t.Run("false", func(t *testing.T) {
ctx := testctx.New()
require.False(t, skips.Any(ctx, skips.Release...))
})
t.Run("true", func(t *testing.T) {
ctx := testctx.New(testctx.Skip(skips.Publish))
require.True(t, skips.Any(ctx, skips.Release...))
})
}
func TestSet(t *testing.T) {
ctx := testctx.New()
skips.Set(ctx, skips.Publish, skips.Announce)
require.ElementsMatch(t, []string{"publish", "announce"}, maps.Keys(ctx.Skips))
}