MCPcopy
hub / github.com/openai/openai-go / TestSkillVersionContentGet

Function TestSkillVersionContentGet

skillversioncontent_test.go:18–55  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

16)
17
18func TestSkillVersionContentGet(t *testing.T) {
19 server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
20 w.WriteHeader(200)
21 w.Write([]byte("abc"))
22 }))
23 defer server.Close()
24 baseURL := server.URL
25 client := openai.NewClient(
26 option.WithBaseURL(baseURL),
27 option.WithAPIKey("My API Key"),
28 option.WithAdminAPIKey("My Admin API Key"),
29 )
30 resp, err := client.Skills.Versions.Content.Get(
31 context.TODO(),
32 "skill_123",
33 "version",
34 )
35 if err != nil {
36 var apierr *openai.Error
37 if errors.As(err, &apierr) {
38 t.Log(string(apierr.DumpRequest(true)))
39 }
40 t.Fatalf("err should be nil: %s", err.Error())
41 }
42 defer resp.Body.Close()
43
44 b, err := io.ReadAll(resp.Body)
45 if err != nil {
46 var apierr *openai.Error
47 if errors.As(err, &apierr) {
48 t.Log(string(apierr.DumpRequest(true)))
49 }
50 t.Fatalf("err should be nil: %s", err.Error())
51 }
52 if !bytes.Equal(b, []byte("abc")) {
53 t.Fatalf("return value not %s: %s", "abc", b)
54 }
55}

Callers

nothing calls this directly

Calls 7

DumpRequestMethod · 0.95
WithBaseURLFunction · 0.92
WithAPIKeyFunction · 0.92
WithAdminAPIKeyFunction · 0.92
CloseMethod · 0.65
GetMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…