2021-10-20 21:56:27 -03:00
|
|
|
package testlib
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestCheckPath(t *testing.T) {
|
|
|
|
requireSkipped := func(tb testing.TB, skipped bool) {
|
|
|
|
tb.Helper()
|
|
|
|
t.Cleanup(func() {
|
|
|
|
require.Equalf(tb, skipped, tb.Skipped(), "expected skipped to be %v", skipped)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Run("local", func(t *testing.T) {
|
2023-06-25 20:54:10 +08:00
|
|
|
t.Setenv("CI", "false")
|
2021-10-20 21:56:27 -03:00
|
|
|
|
|
|
|
t.Run("in path", func(t *testing.T) {
|
|
|
|
requireSkipped(t, false)
|
|
|
|
CheckPath(t, "echo")
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("not in path", func(t *testing.T) {
|
|
|
|
requireSkipped(t, true)
|
|
|
|
CheckPath(t, "do-not-exist")
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("CI", func(t *testing.T) {
|
2023-06-25 20:54:10 +08:00
|
|
|
t.Setenv("CI", "true")
|
2021-10-20 21:56:27 -03:00
|
|
|
|
|
|
|
t.Run("in path on CI", func(t *testing.T) {
|
|
|
|
requireSkipped(t, false)
|
|
|
|
CheckPath(t, "echo")
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("not in path on CI", func(t *testing.T) {
|
|
|
|
requireSkipped(t, false)
|
|
|
|
CheckPath(t, "do-not-exist")
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|