mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-18 03:56:52 +02:00
ec2db4a727
<!-- Hi, thanks for contributing! Please make sure you read our CONTRIBUTING guide. Also, add tests and the respective documentation changes as well. --> <!-- If applied, this commit will... --> ... <!-- Why is this change being made? --> ... <!-- # Provide links to any relevant tickets, URLs or other resources --> ... --------- Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
41 lines
1.0 KiB
Go
41 lines
1.0 KiB
Go
package skips_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/goreleaser/goreleaser/v2/internal/skips"
|
|
"github.com/goreleaser/goreleaser/v2/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))
|
|
}
|