github.com/windmeup/goreleaser@v1.21.95/internal/testlib/path_test.go (about)

     1  package testlib
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/require"
     7  )
     8  
     9  func TestCheckPath(t *testing.T) {
    10  	requireSkipped := func(tb testing.TB, skipped bool) {
    11  		tb.Helper()
    12  		t.Cleanup(func() {
    13  			require.Equalf(tb, skipped, tb.Skipped(), "expected skipped to be %v", skipped)
    14  		})
    15  	}
    16  
    17  	t.Run("local", func(t *testing.T) {
    18  		t.Setenv("CI", "false")
    19  
    20  		t.Run("in path", func(t *testing.T) {
    21  			requireSkipped(t, false)
    22  			CheckPath(t, "echo")
    23  		})
    24  
    25  		t.Run("not in path", func(t *testing.T) {
    26  			requireSkipped(t, true)
    27  			CheckPath(t, "do-not-exist")
    28  		})
    29  	})
    30  
    31  	t.Run("CI", func(t *testing.T) {
    32  		t.Setenv("CI", "true")
    33  
    34  		t.Run("in path on CI", func(t *testing.T) {
    35  			requireSkipped(t, false)
    36  			CheckPath(t, "echo")
    37  		})
    38  
    39  		t.Run("not in path on CI", func(t *testing.T) {
    40  			requireSkipped(t, false)
    41  			CheckPath(t, "do-not-exist")
    42  		})
    43  	})
    44  }