From ad2a4473eeba547b44cfe264f888db62998d32f8 Mon Sep 17 00:00:00 2001 From: Max Pajari Date: Sun, 14 Apr 2024 13:04:27 -0700 Subject: [PATCH] Small corrections --- README.md | 2 +- together.go | 5 +++-- together_test.go | 3 +++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2d6c1e2..be5f06c 100644 --- a/README.md +++ b/README.md @@ -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) } diff --git a/together.go b/together.go index 95f4621..7bc633a 100644 --- a/together.go +++ b/together.go @@ -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 { @@ -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 diff --git a/together_test.go b/together_test.go index 2d6438f..63ad32c 100644 --- a/together_test.go +++ b/together_test.go @@ -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" { @@ -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") @@ -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