Skip to content

Commit

Permalink
clientTest: authenticated by default
Browse files Browse the repository at this point in the history
  • Loading branch information
aviau committed Sep 14, 2024
1 parent aeec6e8 commit cf0283e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions api_client_http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"net/http"
"net/http/httptest"
"testing"
"time"

"github.com/stretchr/testify/assert"
)
Expand All @@ -20,10 +21,14 @@ func newClientTest(
httpServer := httptest.NewServer(
handler,
)

apiClient := NewApiClient(
"test-api-key",
withBaseUrl(httpServer.URL),
)
apiClient.apiToken = "test-api-token"
apiClient.apiTokenExp = time.Now().Add(time.Minute * 45)

ct := &clientTest{
httpServer: httpServer,
apiClient: apiClient,
Expand All @@ -45,6 +50,9 @@ func TestGenerateToken(t *testing.T) {
)
defer ct.Close()

ct.apiClient.apiToken = ""
ct.apiClient.apiTokenExp = time.Time{}

assert.Equal(t, "", ct.apiClient.apiToken, "The initial api token should be empty")
assert.True(t, ct.apiClient.isApiTokenExpired(), "The initial api token exp should be before now")

Expand Down

0 comments on commit cf0283e

Please sign in to comment.