github.phpd.cn/goreleaser/goreleaser@v0.92.0/internal/pipe/before/before_test.go (about)

     1  package before
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/goreleaser/goreleaser/pkg/config"
     7  	"github.com/goreleaser/goreleaser/pkg/context"
     8  	"github.com/stretchr/testify/assert"
     9  )
    10  
    11  func TestDescription(t *testing.T) {
    12  	assert.NotEmpty(t, Pipe{}.String())
    13  }
    14  
    15  func TestRunPipe(t *testing.T) {
    16  	for _, tc := range [][]string{
    17  		nil,
    18  		{},
    19  		{"go version"},
    20  		{"go version", "go list"},
    21  	} {
    22  		ctx := context.New(
    23  			config.Project{
    24  				Before: config.Before{
    25  					Hooks: tc,
    26  				},
    27  			},
    28  		)
    29  		assert.NoError(t, Pipe{}.Run(ctx))
    30  	}
    31  }
    32  
    33  func TestRunPipeFail(t *testing.T) {
    34  	for _, tc := range [][]string{
    35  		{"go tool foobar"},
    36  	} {
    37  		ctx := context.New(
    38  			config.Project{
    39  				Before: config.Before{
    40  					Hooks: tc,
    41  				},
    42  			},
    43  		)
    44  		assert.Error(t, Pipe{}.Run(ctx))
    45  	}
    46  }