openai/openai-go

Public

mirrored from https://github.com/openai/openai-goAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v2.0.0

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

internal/testutil/testutil.go

27lines · modecode

1package testutil
2
3import (
4 "net/http"
5 "os"
6 "strconv"
7 "testing"
8)
9
10func CheckTestServer(t *testing.T, url string) bool {
11 if _, err := http.Get(url); err != nil {
12 const SKIP_MOCK_TESTS = "SKIP_MOCK_TESTS"
13 if str, ok := os.LookupEnv(SKIP_MOCK_TESTS); ok {
14 skip, err := strconv.ParseBool(str)
15 if err != nil {
16 t.Fatalf("strconv.ParseBool(os.LookupEnv(%s)) failed: %s", SKIP_MOCK_TESTS, err)
17 }
18 if skip {
19 t.Skip("The test will not run without a mock Prism server running against your OpenAPI spec")
20 return false
21 }
22 t.Errorf("The test will not run without a mock Prism server running against your OpenAPI spec. You can set the environment variable %s to true to skip running any tests that require the mock server", SKIP_MOCK_TESTS)
23 return false
24 }
25 }
26 return true
27}
28