mirror of
https://github.com/sstent/go-garth.git
synced 2026-01-25 16:42:28 +00:00
This commit implements the package structure refactoring as outlined in phase1.md (Task 1A.1). Key changes include: - Reorganized packages into `pkg/garmin` for public API and `internal/` for internal implementations. - Updated all import paths to reflect the new structure. - Consolidated types and client logic into their respective new packages. - Updated `cmd/garth/main.go` to use the new public API. - Fixed various compilation and test issues encountered during the refactoring process. - Converted `internal/api/client/auth_test.go` to a functional test. This establishes a solid foundation for future enhancements and improves maintainability.
37 lines
1.0 KiB
Go
37 lines
1.0 KiB
Go
package client_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"garmin-connect/internal/api/client"
|
|
"garmin-connect/internal/auth/credentials"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestClient_Login_Functional(t *testing.T) {
|
|
if testing.Short() {
|
|
t.Skip("Skipping functional test in short mode")
|
|
}
|
|
|
|
// Load credentials from .env file
|
|
email, password, domain, err := credentials.LoadEnvCredentials()
|
|
require.NoError(t, err, "Failed to load credentials from .env file. Please ensure GARMIN_EMAIL, GARMIN_PASSWORD, and GARMIN_DOMAIN are set.")
|
|
|
|
// Create client
|
|
c, err := client.NewClient(domain)
|
|
require.NoError(t, err, "Failed to create client")
|
|
|
|
// Perform login
|
|
err = c.Login(email, password)
|
|
require.NoError(t, err, "Login failed")
|
|
|
|
// Verify login
|
|
assert.NotEmpty(t, c.AuthToken, "AuthToken should not be empty after login")
|
|
assert.NotEmpty(t, c.Username, "Username should not be empty after login")
|
|
|
|
// Logout for cleanup
|
|
err = c.Logout()
|
|
assert.NoError(t, err, "Logout failed")
|
|
} |