github.com/anthropics/anthropic-sdk-go@v1.70.1/betaorganizationratelimit_test.go (about) 1 // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 3 package anthropic_test 4 5 import ( 6 "context" 7 "errors" 8 "os" 9 "testing" 10 11 "github.com/anthropics/anthropic-sdk-go" 12 "github.com/anthropics/anthropic-sdk-go/internal/testutil" 13 "github.com/anthropics/anthropic-sdk-go/option" 14 ) 15 16 func TestBetaOrganizationRateLimitListWithOptionalParams(t *testing.T) { 17 baseURL := "http://localhost:4010" 18 if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { 19 baseURL = envURL 20 } 21 if !testutil.CheckTestServer(t, baseURL) { 22 return 23 } 24 client := anthropic.NewClient( 25 option.WithBaseURL(baseURL), 26 option.WithAPIKey("my-anthropic-api-key"), 27 ) 28 _, err := client.Beta.Organization.RateLimits.List(context.TODO(), anthropic.BetaOrganizationRateLimitListParams{ 29 GroupType: anthropic.BetaOrganizationRateLimitListParamsGroupTypeBatch, 30 Limit: anthropic.Int(1), 31 Model: anthropic.String("model"), 32 Page: anthropic.String("page"), 33 }) 34 if err != nil { 35 var apierr *anthropic.Error 36 if errors.As(err, &apierr) { 37 t.Log(string(apierr.DumpRequest(true))) 38 } 39 t.Fatalf("err should be nil: %s", err.Error()) 40 } 41 }