github.com/windmeup/goreleaser@v1.21.95/internal/skips/skips_test.go (about)

     1  package skips_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/require"
     7  	"github.com/windmeup/goreleaser/internal/skips"
     8  	"github.com/windmeup/goreleaser/internal/testctx"
     9  	"golang.org/x/exp/maps"
    10  )
    11  
    12  func TestString(t *testing.T) {
    13  	for expect, keys := range map[string][]skips.Key{
    14  		"":                    nil,
    15  		"ko and sbom":         {skips.SBOM, skips.Ko},
    16  		"before, ko and sbom": {skips.SBOM, skips.Ko, skips.Before},
    17  	} {
    18  		t.Run(expect, func(t *testing.T) {
    19  			ctx := testctx.New(testctx.Skip(keys...))
    20  			require.Equal(t, expect, skips.String(ctx))
    21  		})
    22  	}
    23  }
    24  
    25  func TestAny(t *testing.T) {
    26  	t.Run("false", func(t *testing.T) {
    27  		ctx := testctx.New()
    28  		require.False(t, skips.Any(ctx, skips.Release...))
    29  	})
    30  	t.Run("true", func(t *testing.T) {
    31  		ctx := testctx.New(testctx.Skip(skips.Publish))
    32  		require.True(t, skips.Any(ctx, skips.Release...))
    33  	})
    34  }
    35  
    36  func TestSet(t *testing.T) {
    37  	ctx := testctx.New()
    38  	skips.Set(ctx, skips.Publish, skips.Announce)
    39  	require.ElementsMatch(t, []string{"publish", "announce"}, maps.Keys(ctx.Skips))
    40  }