Skip to content

Commit

Permalink
require on integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
WillMatthews committed Sep 3, 2024
1 parent ea3f090 commit d77c1b0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
7 changes: 4 additions & 3 deletions integrationtest/complete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import (
"testing"

"github.com/liushuangls/go-anthropic/v2"
"github.com/stretchr/testify/require"
)

func TestIntegrationComplete(t *testing.T) {
testAPIKey(t)
is := require.New(t)

t.Run("CreateComplete on real API", func(t *testing.T) {
client := anthropic.NewClient(APIKey)
Expand All @@ -21,9 +23,8 @@ func TestIntegrationComplete(t *testing.T) {
}

resp, err := client.CreateComplete(ctx, request)
if err != nil {
t.Fatalf("CreateComplete error: %s", err)
}
is.NoError(err)

t.Logf("CreateComplete resp: %+v", resp)

// RateLimitHeaders are not present on the Completions endpoint
Expand Down
23 changes: 11 additions & 12 deletions integrationtest/messages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ import (
"testing"

"github.com/liushuangls/go-anthropic/v2"
"github.com/stretchr/testify/require"
)

func TestIntegrationMessages(t *testing.T) {
testAPIKey(t)
is := require.New(t)

client := anthropic.NewClient(APIKey)
ctx := context.Background()

Expand All @@ -28,16 +31,14 @@ func TestIntegrationMessages(t *testing.T) {
newClient := anthropic.NewClient(APIKey, betaOpts)

resp, err := newClient.CreateMessages(ctx, request)
if err != nil {
t.Fatalf("CreateMessages error: %s", err)
}
is.NoError(err)

t.Logf("CreateMessages resp: %+v", resp)

t.Run("RateLimitHeaders are present", func(t *testing.T) {
rateLimHeader, err := resp.GetRateLimitHeaders()
if err != nil {
t.Fatalf("GetRateLimitHeaders error: %s", err)
}
is.NoError(err)

t.Logf("RateLimitHeaders: %+v", rateLimHeader)
})
})
Expand All @@ -47,16 +48,14 @@ func TestIntegrationMessages(t *testing.T) {
MessagesRequest: request,
}
resp, err := client.CreateMessagesStream(ctx, streamRequest)
if err != nil {
t.Fatalf("CreateMessagesStream error: %s", err)
}
is.NoError(err)

t.Logf("CreateMessagesStream resp: %+v", resp)

t.Run("RateLimitHeaders are present", func(t *testing.T) {
rateLimHeader, err := resp.GetRateLimitHeaders()
if err != nil {
t.Fatalf("GetRateLimitHeaders error: %s", err)
}
is.NoError(err)

t.Logf("RateLimitHeaders: %+v", rateLimHeader)
})
})
Expand Down

0 comments on commit d77c1b0

Please sign in to comment.