mirror of
https://github.com/goreleaser/goreleaser.git
synced 2024-12-29 01:44:39 +02:00
0f48a6dd40
The PR refactors code by replacing usage of `golang.org/exp/slices`/`golang.org/exp/maps` package with the standard `slices`/`maps`. Additionally, replace the function `keys(someMap)` with `slices.Compact(maps.Keys(someMap))` Co-authored-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
42 lines
1.0 KiB
Go
42 lines
1.0 KiB
Go
package skips_test
|
|
|
|
import (
|
|
"maps"
|
|
"slices"
|
|
"testing"
|
|
|
|
"github.com/goreleaser/goreleaser/v2/internal/skips"
|
|
"github.com/goreleaser/goreleaser/v2/internal/testctx"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
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"}, slices.Collect(maps.Keys(ctx.Skips)))
|
|
}
|