Skip production API test by default
This commit is contained in:
13
api_test.go
13
api_test.go
@@ -9,6 +9,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -22,15 +23,13 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestAPI(t *testing.T) {
|
func TestAPI(t *testing.T) {
|
||||||
if testing.Short() {
|
apiToken := os.Getenv("OPENAI_TOKEN")
|
||||||
t.Skip("skipping test in short mode")
|
if apiToken == "" {
|
||||||
}
|
t.Skip("Skipping testing against production OpenAI API. Set OPENAI_TOKEN environment variable to enable it.")
|
||||||
tokenBytes, err := ioutil.ReadFile(".openai-token")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("Could not load auth token from .openai-token file")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
c := NewClient(string(tokenBytes))
|
var err error
|
||||||
|
c := NewClient(apiToken)
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
_, err = c.ListEngines(ctx)
|
_, err = c.ListEngines(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user