github.com/clerkinc/clerk-sdk-go@v1.49.1/tests/integration/clerk_test.go (about)

     1  //go:build integration
     2  // +build integration
     3  
     4  package integration
     5  
     6  import (
     7  	"net/http"
     8  	"os"
     9  	"time"
    10  
    11  	"github.com/clerkinc/clerk-sdk-go/clerk"
    12  )
    13  
    14  type key string
    15  
    16  const (
    17  	APIUrl = "CLERK_API_URL"
    18  	APIKey = "CLERK_API_KEY"
    19  )
    20  
    21  func createClient() clerk.Client {
    22  	apiUrl := getEnv(APIUrl)
    23  	apiKey := getEnv(APIKey)
    24  
    25  	httpClient := &http.Client{Timeout: time.Second * 20}
    26  	client, err := clerk.NewClient(apiKey, clerk.WithBaseURL(apiUrl), clerk.WithHTTPClient(httpClient))
    27  	if err != nil {
    28  		panic("Unable to create Clerk client")
    29  	}
    30  
    31  	return client
    32  }
    33  
    34  func getEnv(k string) string {
    35  	envValue := os.Getenv(k)
    36  	if envValue == "" {
    37  		panic("Missing env variable " + k)
    38  	}
    39  	return envValue
    40  }