Skip to content

Commit

Permalink
Add 'eastest' pkg with reusable test helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiante committed Dec 18, 2023
1 parent 4a1516c commit 0abfd79
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 11 deletions.
7 changes: 0 additions & 7 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"errors"
"fmt"
"os"
"testing"

"github.com/DEXPRO-Solutions-GmbH/easclient"
"github.com/joho/godotenv"
Expand Down Expand Up @@ -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")
}
}
2 changes: 2 additions & 0 deletions eastest/package.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package eastest contains test helpers for testing with the EAS.
package eastest
13 changes: 13 additions & 0 deletions eastest/skip.go
Original file line number Diff line number Diff line change
@@ -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")
}
}
3 changes: 2 additions & 1 deletion r_get_record_attachment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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("[email protected]")
Expand Down
3 changes: 2 additions & 1 deletion r_get_record_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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("[email protected]")
Expand Down
3 changes: 2 additions & 1 deletion r_get_store_status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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("[email protected]")
Expand Down
3 changes: 2 additions & 1 deletion r_put_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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("[email protected]")
Expand Down

0 comments on commit 0abfd79

Please sign in to comment.