Skip to content

Commit

Permalink
Add test init function
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiante committed Dec 8, 2023
1 parent 1b3060e commit f67db48
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.idea
.env
29 changes: 29 additions & 0 deletions store_client_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package easclient_test

import (
"errors"
"fmt"
"os"

"github.com/DEXPRO-Solutions-GmbH/easclient"
"github.com/joho/godotenv"
"gopkg.in/resty.v1"
)

var DefaultClient *easclient.StoreClient

// init is run before any tests are executed.
// it loads the environment variables from .env and creates
// a default client for all tests to use.
func init() {
err := godotenv.Load(".env")
if errors.Is(err, os.ErrNotExist) {
return
}

client := resty.New()
client.SetHostURL(fmt.Sprintf("http://%s/eas/archives/%s", os.Getenv("EAS_HOST"), os.Getenv("EAS_STORE")))
client.SetBasicAuth(os.Getenv("EAS_USER"), os.Getenv("EAS_PASSWORD"))

DefaultClient = easclient.NewStoreClient(client)
}

0 comments on commit f67db48

Please sign in to comment.