mirror of
https://github.com/sstent/go-garth.git
synced 2026-01-26 09:03:00 +00:00
porting - part 12 done
This commit is contained in:
40
garth/client/client_test.go
Normal file
40
garth/client/client_test.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package client_test
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"garmin-connect/garth/testutils"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"garmin-connect/garth/client"
|
||||
)
|
||||
|
||||
func TestClient_GetUserProfile(t *testing.T) {
|
||||
// Create mock server returning user profile
|
||||
server := testutils.MockJSONResponse(http.StatusOK, `{
|
||||
"userName": "testuser",
|
||||
"displayName": "Test User",
|
||||
"fullName": "Test User",
|
||||
"location": "Test Location"
|
||||
}`)
|
||||
defer server.Close()
|
||||
|
||||
// Create client with test configuration
|
||||
c := &client.Client{
|
||||
Domain: server.URL,
|
||||
HTTPClient: &http.Client{Timeout: 5 * time.Second},
|
||||
AuthToken: "Bearer testtoken",
|
||||
}
|
||||
|
||||
// Get user profile
|
||||
profile, err := c.GetUserProfile()
|
||||
|
||||
// Verify response
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "testuser", profile.UserName)
|
||||
assert.Equal(t, "Test User", profile.DisplayName)
|
||||
}
|
||||
Reference in New Issue
Block a user