mirror of
https://github.com/gesellix/Bose-SoundTouch.git
synced 2026-08-19 09:06:14 +00:00
Mirror the Spotify equivalents: pkg/testutils/amazon/handlers.go provides HandleToken and HandleProfile for use in unit tests; tests/integration/mocks/amazon.go wraps them in an AmazonMock with TokenURL() and ProfileURL() accessors. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
40 lines
897 B
Go
40 lines
897 B
Go
package mocks
|
|
|
|
import (
|
|
"net/http/httptest"
|
|
|
|
"github.com/gesellix/bose-soundtouch/pkg/testutils/amazon"
|
|
)
|
|
|
|
// AmazonMock simulates Amazon LWA API responses for OAuth and profile interactions.
|
|
type AmazonMock struct {
|
|
server *httptest.Server
|
|
}
|
|
|
|
// NewAmazonMock creates and starts a new Amazon LWA mock server.
|
|
func NewAmazonMock() *AmazonMock {
|
|
return &AmazonMock{
|
|
server: httptest.NewServer(amazon.NewAmazonHandler()),
|
|
}
|
|
}
|
|
|
|
// URL returns the base URL of the mock server.
|
|
func (m *AmazonMock) URL() string {
|
|
return m.server.URL
|
|
}
|
|
|
|
// TokenURL returns the LWA token endpoint URL.
|
|
func (m *AmazonMock) TokenURL() string {
|
|
return m.server.URL + "/auth/o2/token"
|
|
}
|
|
|
|
// ProfileURL returns the LWA user profile endpoint URL.
|
|
func (m *AmazonMock) ProfileURL() string {
|
|
return m.server.URL + "/user/profile"
|
|
}
|
|
|
|
// Close stops the mock server.
|
|
func (m *AmazonMock) Close() {
|
|
m.server.Close()
|
|
}
|