| 1 |
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 |
|
| 3 |
package anthropic_test |
| 4 |
|
| 5 |
import ( |
| 6 |
"bytes" |
| 7 |
"context" |
| 8 |
"errors" |
| 9 |
"io" |
| 10 |
"os" |
| 11 |
"testing" |
| 12 |
|
| 13 |
"github.com/anthropics/anthropic-sdk-go" |
| 14 |
"github.com/anthropics/anthropic-sdk-go/internal/testutil" |
| 15 |
"github.com/anthropics/anthropic-sdk-go/option" |
| 16 |
) |
| 17 |
|
| 18 |
func TestBetaSkillVersionNewWithOptionalParams(t *testing.T) { |
| 19 |
baseURL := "http://localhost:4010" |
| 20 |
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { |
| 21 |
baseURL = envURL |
| 22 |
} |
| 23 |
if !testutil.CheckTestServer(t, baseURL) { |
| 24 |
return |
| 25 |
} |
| 26 |
client := anthropic.NewClient( |
| 27 |
option.WithBaseURL(baseURL), |
| 28 |
option.WithAPIKey("my-anthropic-api-key"), |
| 29 |
) |
| 30 |
_, err := client.Beta.Skills.Versions.New( |
| 31 |
context.TODO(), |
| 32 |
"skill_id", |
| 33 |
anthropic.BetaSkillVersionNewParams{ |
| 34 |
Files: []io.Reader{io.Reader(bytes.NewBuffer([]byte("Example data")))}, |
| 35 |
Betas: []anthropic.AnthropicBeta{anthropic.AnthropicBetaMessageBatches2024_09_24}, |
| 36 |
}, |
| 37 |
) |
| 38 |
if err != nil { |
| 39 |
var apierr *anthropic.Error |
| 40 |
if errors.As(err, &apierr) { |
| 41 |
t.Log(string(apierr.DumpRequest(true))) |
| 42 |
} |
| 43 |
t.Fatalf("err should be nil: %s", err.Error()) |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
func TestBetaSkillVersionGetWithOptionalParams(t *testing.T) { |
| 48 |
baseURL := "http://localhost:4010" |
| 49 |
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { |
| 50 |
baseURL = envURL |
| 51 |
} |
| 52 |
if !testutil.CheckTestServer(t, baseURL) { |
| 53 |
return |
| 54 |
} |
| 55 |
client := anthropic.NewClient( |
| 56 |
option.WithBaseURL(baseURL), |
| 57 |
option.WithAPIKey("my-anthropic-api-key"), |
| 58 |
) |
| 59 |
_, err := client.Beta.Skills.Versions.Get( |
| 60 |
context.TODO(), |
| 61 |
"version", |
| 62 |
anthropic.BetaSkillVersionGetParams{ |
| 63 |
SkillID: "skill_id", |
| 64 |
Betas: []anthropic.AnthropicBeta{anthropic.AnthropicBetaMessageBatches2024_09_24}, |
| 65 |
}, |
| 66 |
) |
| 67 |
if err != nil { |
| 68 |
var apierr *anthropic.Error |
| 69 |
if errors.As(err, &apierr) { |
| 70 |
t.Log(string(apierr.DumpRequest(true))) |
| 71 |
} |
| 72 |
t.Fatalf("err should be nil: %s", err.Error()) |
| 73 |
} |
| 74 |
} |
| 75 |
|
| 76 |
func TestBetaSkillVersionListWithOptionalParams(t *testing.T) { |
| 77 |
baseURL := "http://localhost:4010" |
| 78 |
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { |
| 79 |
baseURL = envURL |
| 80 |
} |
| 81 |
if !testutil.CheckTestServer(t, baseURL) { |
| 82 |
return |
| 83 |
} |
| 84 |
client := anthropic.NewClient( |
| 85 |
option.WithBaseURL(baseURL), |
| 86 |
option.WithAPIKey("my-anthropic-api-key"), |
| 87 |
) |
| 88 |
_, err := client.Beta.Skills.Versions.List( |
| 89 |
context.TODO(), |
| 90 |
"skill_id", |
| 91 |
anthropic.BetaSkillVersionListParams{ |
| 92 |
Limit: anthropic.Int(0), |
| 93 |
Page: anthropic.String("page"), |
| 94 |
Betas: []anthropic.AnthropicBeta{anthropic.AnthropicBetaMessageBatches2024_09_24}, |
| 95 |
}, |
| 96 |
) |
| 97 |
if err != nil { |
| 98 |
var apierr *anthropic.Error |
| 99 |
if errors.As(err, &apierr) { |
| 100 |
t.Log(string(apierr.DumpRequest(true))) |
| 101 |
} |
| 102 |
t.Fatalf("err should be nil: %s", err.Error()) |
| 103 |
} |
| 104 |
} |
| 105 |
|
| 106 |
func TestBetaSkillVersionDeleteWithOptionalParams(t *testing.T) { |
| 107 |
baseURL := "http://localhost:4010" |
| 108 |
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { |
| 109 |
baseURL = envURL |
| 110 |
} |
| 111 |
if !testutil.CheckTestServer(t, baseURL) { |
| 112 |
return |
| 113 |
} |
| 114 |
client := anthropic.NewClient( |
| 115 |
option.WithBaseURL(baseURL), |
| 116 |
option.WithAPIKey("my-anthropic-api-key"), |
| 117 |
) |
| 118 |
_, err := client.Beta.Skills.Versions.Delete( |
| 119 |
context.TODO(), |
| 120 |
"version", |
| 121 |
anthropic.BetaSkillVersionDeleteParams{ |
| 122 |
SkillID: "skill_id", |
| 123 |
Betas: []anthropic.AnthropicBeta{anthropic.AnthropicBetaMessageBatches2024_09_24}, |
| 124 |
}, |
| 125 |
) |
| 126 |
if err != nil { |
| 127 |
var apierr *anthropic.Error |
| 128 |
if errors.As(err, &apierr) { |
| 129 |
t.Log(string(apierr.DumpRequest(true))) |
| 130 |
} |
| 131 |
t.Fatalf("err should be nil: %s", err.Error()) |
| 132 |
} |
| 133 |
} |