From 32e36c90cee287b4d72287903443e0b7e564a4e7 Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Thu, 3 Feb 2022 19:01:36 +0100 Subject: [PATCH] :robot: Adapt to ginkgov2 restrictions --- api/client/client_suite_test.go | 15 +++++++++++++++ api/client/client_test.go | 11 ----------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/api/client/client_suite_test.go b/api/client/client_suite_test.go index 2d3f278b..c31b4168 100644 --- a/api/client/client_suite_test.go +++ b/api/client/client_suite_test.go @@ -19,11 +19,16 @@ import ( "fmt" "os" "testing" + "time" + + . "github.com/mudler/edgevpn/api/client" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) +var testInstance = os.Getenv("TEST_INSTANCE") + func TestClient(t *testing.T) { if testInstance == "" { fmt.Println("a testing instance has to be defined with TEST_INSTANCE") @@ -32,3 +37,13 @@ func TestClient(t *testing.T) { RegisterFailHandler(Fail) RunSpecs(t, "Client Suite") } + +var _ = BeforeSuite(func() { + // Start the test suite only if we have some machines connected + + Eventually(func() (int, error) { + c := NewClient(WithHost(testInstance)) + m, err := c.Machines() + return len(m), err + }, 100*time.Second, 1*time.Second).Should(BeNumerically(">=", 0)) +}) diff --git a/api/client/client_test.go b/api/client/client_test.go index 86d4868c..3788f018 100644 --- a/api/client/client_test.go +++ b/api/client/client_test.go @@ -17,7 +17,6 @@ package client_test import ( "math/rand" - "os" "time" . "github.com/onsi/ginkgo/v2" @@ -26,8 +25,6 @@ import ( . "github.com/mudler/edgevpn/api/client" ) -var testInstance = os.Getenv("TEST_INSTANCE") - const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" func randStringBytes(n int) string { @@ -41,14 +38,6 @@ func randStringBytes(n int) string { var _ = Describe("Client", func() { c := NewClient(WithHost(testInstance)) - // Start the test suite only if we have some machines connected - BeforeSuite(func() { - Eventually(func() (int, error) { - m, err := c.Machines() - return len(m), err - }, 100*time.Second, 1*time.Second).Should(BeNumerically(">=", 0)) - }) - Context("Operates blockchain", func() { var testBucket string