Skip to content

Commit be08f20

Browse files
committed
Skip production API test by default
1 parent d63df93 commit be08f20

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

api_test.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"log"
1010
"net/http"
1111
"net/http/httptest"
12+
"os"
1213
"strconv"
1314
"strings"
1415
"testing"
@@ -22,15 +23,13 @@ const (
2223
)
2324

2425
func TestAPI(t *testing.T) {
25-
if testing.Short() {
26-
t.Skip("skipping test in short mode")
27-
}
28-
tokenBytes, err := ioutil.ReadFile(".openai-token")
29-
if err != nil {
30-
t.Fatalf("Could not load auth token from .openai-token file")
26+
apiToken := os.Getenv("OPENAI_TOKEN")
27+
if apiToken == "" {
28+
t.Skip("Skipping testing against production OpenAI API. Set OPENAI_TOKEN environment variable to enable it.")
3129
}
3230

33-
c := NewClient(string(tokenBytes))
31+
var err error
32+
c := NewClient(apiToken)
3433
ctx := context.Background()
3534
_, err = c.ListEngines(ctx)
3635
if err != nil {

0 commit comments

Comments
 (0)