Skip to content

Commit

Permalink
Small corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnystrom committed Apr 14, 2024
1 parent c60d6e1 commit ad2a447
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func main() {
ctx := context.Background()

// List running instances
r, err := api.ListRunningInstances(context)
r, err := api.ListRunningInstances(ctx)
if err != nil {
log.Fatal(err)
}
Expand Down
5 changes: 3 additions & 2 deletions together.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ const (
defaultScheme = "https"
defaultHostname = "api.together.xyz"
defaultBasePath = "/"
defaultRetries = 5
userAgent = "together-go"

errEmptyAPIToken = "invalid credentials: API Token must not be empty" //nolint:gosec,unused
)

var (
Version string = "v1"
Version string = "v1" // This corresponds to the version of the API and is used in the URL path
)

type API struct {
Expand All @@ -43,7 +44,7 @@ func New(key string) (*API, error) {
api := &API{}
api.BaseURL = fmt.Sprintf("%s://%s", defaultScheme, defaultHostname)
api.Client = retryablehttp.NewClient()
api.Client.RetryMax = 5
api.Client.RetryMax = defaultRetries
api.Debug = false
api.APIKey = key
api.UserAgent = userAgent + "/" + Version
Expand Down
3 changes: 3 additions & 0 deletions together_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"testing"
)

// Test creating a new API object/client with a valid API key.
func TestNew(t *testing.T) {
result, _ := New("hunter2")
if result.APIKey != "hunter2" {
Expand All @@ -24,6 +25,7 @@ func TestNew(t *testing.T) {

}

// Test copying headers from one header map to another.
func TestCopyHeader(t *testing.T) {
a := make(http.Header)
a.Set("test", "test")
Expand All @@ -40,6 +42,7 @@ func TestCopyHeader(t *testing.T) {
}
}

// Test making a HTTP request.
func TestRequest(t *testing.T) {
req, _ := New("hunter2")
req.Client.RetryMax = 1
Expand Down

0 comments on commit ad2a447

Please sign in to comment.