diff --git a/client_test.go b/client_test.go index 042a819..8c4bd93 100644 --- a/client_test.go +++ b/client_test.go @@ -4,7 +4,6 @@ import ( "errors" "fmt" "os" - "testing" "github.com/DEXPRO-Solutions-GmbH/easclient" "github.com/joho/godotenv" @@ -35,9 +34,3 @@ func init() { serverClient.SetBasicAuth(os.Getenv("EAS_USER"), os.Getenv("EAS_PASSWORD")) DefaultServerClient = easclient.NewServerClient(serverClient) } - -func testPrelude(t *testing.T) { - if os.Getenv("GITHUB_ACTION") != "" { - t.Skip("Tests can't currently be run in the GitHub Action environment. We will first have to make it possible to run the EAS or a mocked variant in CI") - } -} diff --git a/eastest/package.go b/eastest/package.go new file mode 100644 index 0000000..f763b88 --- /dev/null +++ b/eastest/package.go @@ -0,0 +1,2 @@ +// Package eastest contains test helpers for testing with the EAS. +package eastest diff --git a/eastest/skip.go b/eastest/skip.go new file mode 100644 index 0000000..564f298 --- /dev/null +++ b/eastest/skip.go @@ -0,0 +1,13 @@ +package eastest + +import ( + "os" + "testing" +) + +// SkipInCI is used to skip tests if they can not be executed in the current environment. +func SkipInCI(t *testing.T) { + if os.Getenv("GITHUB_ACTION") != "" { + t.Skip("Tests can't currently be run in the GitHub Action environment. We will first have to make it possible to run the EAS or a mocked variant in CI") + } +} diff --git a/r_get_record_attachment_test.go b/r_get_record_attachment_test.go index 8dd40f1..2dcf090 100644 --- a/r_get_record_attachment_test.go +++ b/r_get_record_attachment_test.go @@ -6,12 +6,13 @@ import ( "testing" "github.com/DEXPRO-Solutions-GmbH/easclient" + "github.com/DEXPRO-Solutions-GmbH/easclient/eastest" "github.com/google/uuid" "github.com/stretchr/testify/require" ) func TestStoreClient_GetRecordAttachment(t *testing.T) { - testPrelude(t) + eastest.SkipInCI(t) ctx := context.Background() user := easclient.NewUserClaims("test@dexpro.de") diff --git a/r_get_record_test.go b/r_get_record_test.go index 5df4322..f4c4266 100644 --- a/r_get_record_test.go +++ b/r_get_record_test.go @@ -5,12 +5,13 @@ import ( "testing" "github.com/DEXPRO-Solutions-GmbH/easclient" + "github.com/DEXPRO-Solutions-GmbH/easclient/eastest" "github.com/google/uuid" "github.com/stretchr/testify/require" ) func TestStoreClient_GetRecord(t *testing.T) { - testPrelude(t) + eastest.SkipInCI(t) ctx := context.Background() user := easclient.NewUserClaims("test@dexpro.de") diff --git a/r_get_store_status_test.go b/r_get_store_status_test.go index 14c0494..219050c 100644 --- a/r_get_store_status_test.go +++ b/r_get_store_status_test.go @@ -5,11 +5,12 @@ import ( "testing" "github.com/DEXPRO-Solutions-GmbH/easclient" + "github.com/DEXPRO-Solutions-GmbH/easclient/eastest" "github.com/stretchr/testify/require" ) func TestStoreClient_GetStoreStatus(t *testing.T) { - testPrelude(t) + eastest.SkipInCI(t) ctx := context.Background() user := easclient.NewUserClaims("test@dexpro.de") diff --git a/r_put_store_test.go b/r_put_store_test.go index 299ef19..30c4f2b 100644 --- a/r_put_store_test.go +++ b/r_put_store_test.go @@ -5,11 +5,12 @@ import ( "testing" "github.com/DEXPRO-Solutions-GmbH/easclient" + "github.com/DEXPRO-Solutions-GmbH/easclient/eastest" "github.com/stretchr/testify/require" ) func TestStoreClient_PutStore(t *testing.T) { - testPrelude(t) + eastest.SkipInCI(t) ctx := context.Background() user := easclient.NewUserClaims("test@dexpro.de")