go-emlid/reach/integration.go

32 lines
822 B
Go
Raw Normal View History

2024-07-30 14:28:39 +02:00
package reach
import (
"os"
"strconv"
"testing"
"github.com/pkg/errors"
)
const skipIntegrationTestsEnv = "SKIP_INTEGRATION_TESTS"
func AssertIntegrationTests(t *testing.T) {
rawSkipIntegrationTests := os.Getenv(skipIntegrationTestsEnv)
if rawSkipIntegrationTests == "" {
rawSkipIntegrationTests = "false"
}
skipIntegrationTests, err := strconv.ParseBool(rawSkipIntegrationTests)
if err != nil {
t.Logf("[WARN] could not parse environment variable '%s': %+v", skipIntegrationTestsEnv, errors.WithStack(err))
skipIntegrationTests = false
}
if !skipIntegrationTests {
t.Logf("Running integration tests. To disable, set environment variable %s=true", skipIntegrationTestsEnv)
2024-07-30 14:28:39 +02:00
return
}
t.Skipf("Integration tests skipped. To enable, set environment variable %s=false", skipIntegrationTestsEnv)
}