Automatically Skip integration tests if no REG_URL is set

This commit is contained in:
Samuel Lorch 2025-03-05 16:50:18 +01:00 committed by Nelson Isioma
parent c3c816d42c
commit e41aaa19ac
2 changed files with 11 additions and 0 deletions

View file

@ -6,6 +6,10 @@ import (
)
func TestResourceCreate(t *testing.T) {
// Skip integration tests if no client is available
if client == nil {
t.SkipNow()
}
id, err := CreateResource(context.TODO(), client, "", "name", "username", "https://url.lan", "password123", "a password description")
if err != nil {
t.Fatalf("Creating Resource %v", err)

View file

@ -15,6 +15,13 @@ var client *api.Client
func TestMain(m *testing.M) {
url := os.Getenv("REG_URL")
// If we don't have a URL for Creating a user, Skip all integration tests by not Providing a client
if url == "" {
fmt.Println("REG_URL Env Variable Empty, Skipping integration tests")
os.Exit(m.Run())
}
fmt.Printf("Registering with url: %v\n", url)
userID, token, err := ParseInviteUrl(url)
if err != nil {