github.com/anthropics/anthropic-sdk-go@v1.70.1/betaorganization_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 TestBetaOrganizationGet(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.Get(context.TODO())
    29  	if err != nil {
    30  		var apierr *anthropic.Error
    31  		if errors.As(err, &apierr) {
    32  			t.Log(string(apierr.DumpRequest(true)))
    33  		}
    34  		t.Fatalf("err should be nil: %s", err.Error())
    35  	}
    36  }