From e41aaa19ac74ccdbf08d00d5abd69e694d09e604 Mon Sep 17 00:00:00 2001 From: Samuel Lorch Date: Wed, 5 Mar 2025 16:50:18 +0100 Subject: [PATCH] Automatically Skip integration tests if no REG_URL is set --- helper/resource_test.go | 4 ++++ helper/setup_test.go | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/helper/resource_test.go b/helper/resource_test.go index 10a9619..b25903d 100644 --- a/helper/resource_test.go +++ b/helper/resource_test.go @@ -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) diff --git a/helper/setup_test.go b/helper/setup_test.go index 1d99e2f..4b5285c 100644 --- a/helper/setup_test.go +++ b/helper/setup_test.go @@ -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 {