From be08f204f03a60f00363d199398dbefcb7b5ac3e Mon Sep 17 00:00:00 2001 From: Alexander Baranov Date: Thu, 11 Aug 2022 15:41:37 +0600 Subject: [PATCH] Skip production API test by default --- api_test.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/api_test.go b/api_test.go index d9ac5e8..c5401f2 100644 --- a/api_test.go +++ b/api_test.go @@ -9,6 +9,7 @@ import ( "log" "net/http" "net/http/httptest" + "os" "strconv" "strings" "testing" @@ -22,15 +23,13 @@ const ( ) func TestAPI(t *testing.T) { - if testing.Short() { - t.Skip("skipping test in short mode") - } - tokenBytes, err := ioutil.ReadFile(".openai-token") - if err != nil { - t.Fatalf("Could not load auth token from .openai-token file") + apiToken := os.Getenv("OPENAI_TOKEN") + if apiToken == "" { + t.Skip("Skipping testing against production OpenAI API. Set OPENAI_TOKEN environment variable to enable it.") } - c := NewClient(string(tokenBytes)) + var err error + c := NewClient(apiToken) ctx := context.Background() _, err = c.ListEngines(ctx) if err != nil {