2023-09-29 08:38:06 +00:00
|
|
|
package testutil
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Cloud int
|
|
|
|
|
|
|
|
const (
|
|
|
|
AWS Cloud = iota
|
|
|
|
Azure
|
|
|
|
GCP
|
|
|
|
)
|
|
|
|
|
|
|
|
// Implement [Requirement].
|
|
|
|
func (c Cloud) Verify(t *testing.T) {
|
|
|
|
if c != GetCloud(t) {
|
|
|
|
t.Skipf("Skipping %s-specific test", c)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c Cloud) String() string {
|
|
|
|
switch c {
|
|
|
|
case AWS:
|
|
|
|
return "AWS"
|
|
|
|
case Azure:
|
|
|
|
return "Azure"
|
|
|
|
case GCP:
|
|
|
|
return "GCP"
|
|
|
|
default:
|
|
|
|
return "unknown"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetCloud(t *testing.T) Cloud {
|
|
|
|
env := GetEnvOrSkipTest(t, "CLOUD_ENV")
|
|
|
|
switch env {
|
|
|
|
case "aws":
|
|
|
|
return AWS
|
|
|
|
case "azure":
|
|
|
|
return Azure
|
|
|
|
case "gcp":
|
|
|
|
return GCP
|
2024-02-21 13:06:03 +00:00
|
|
|
// CLOUD_ENV is set to "ucws" in the "aws-prod-ucws" test environment
|
|
|
|
case "ucws":
|
|
|
|
return AWS
|
2023-09-29 08:38:06 +00:00
|
|
|
default:
|
|
|
|
t.Fatalf("Unknown cloud environment: %s", env)
|
|
|
|
}
|
|
|
|
return -1
|
|
|
|
}
|
2024-09-23 10:42:34 +00:00
|
|
|
|
|
|
|
func IsAWSCloud(t *testing.T) bool {
|
|
|
|
return GetCloud(t) == AWS
|
|
|
|
}
|