Documentation
¶
Overview ¶
Package testutil provides httptest-based API mocking utilities for testing commands that interact with the Google Play Android Publisher API.
Index ¶
- func EditFixture() map[string]interface{}
- func ErrorFixture403() map[string]interface{}
- func ErrorFixture404() map[string]interface{}
- func ErrorFixture409() map[string]interface{}
- func HandleError(statusCode int, message string) http.HandlerFunc
- func HandleJSON(statusCode int, body interface{}) http.HandlerFunc
- func IsolateConfig(t *testing.T) string
- func ListingFixture() map[string]interface{}
- func ListingsListFixture() map[string]interface{}
- func MockServiceAccount(t *testing.T) string
- func RequireEnv(t *testing.T, key string) string
- func ReviewFixture() map[string]interface{}
- func ReviewsListFixture() map[string]interface{}
- func SkipUnlessIntegration(t *testing.T)
- func TrackFixture() map[string]interface{}
- func TracksListFixture() map[string]interface{}
- type MockAPI
- type RequestEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EditFixture ¶
func EditFixture() map[string]interface{}
EditFixture returns a sample Edits.insert / Edits.get response.
func ErrorFixture403 ¶
func ErrorFixture403() map[string]interface{}
ErrorFixture403 returns a Google-style 403 error response body.
func ErrorFixture404 ¶
func ErrorFixture404() map[string]interface{}
ErrorFixture404 returns a Google-style 404 error response body.
func ErrorFixture409 ¶
func ErrorFixture409() map[string]interface{}
ErrorFixture409 returns a Google-style 409 error response body.
func HandleError ¶
func HandleError(statusCode int, message string) http.HandlerFunc
HandleError returns an http.HandlerFunc that responds with a Google-style JSON error body.
func HandleJSON ¶
func HandleJSON(statusCode int, body interface{}) http.HandlerFunc
HandleJSON returns an http.HandlerFunc that responds with the given status code and JSON-encodes body into the response.
func IsolateConfig ¶
IsolateConfig sets GPLAY_CONFIG_PATH to a fresh temp directory and registers cleanup.
func ListingFixture ¶
func ListingFixture() map[string]interface{}
ListingFixture returns a sample Listings.get response.
func ListingsListFixture ¶
func ListingsListFixture() map[string]interface{}
ListingsListFixture returns a sample Listings.list response.
func MockServiceAccount ¶
MockServiceAccount creates a fake but structurally valid service account JSON file.
func RequireEnv ¶
RequireEnv skips the test if the named env var is not set, otherwise returns its value.
func ReviewFixture ¶
func ReviewFixture() map[string]interface{}
ReviewFixture returns a sample Reviews.get response.
func ReviewsListFixture ¶
func ReviewsListFixture() map[string]interface{}
ReviewsListFixture returns a sample Reviews.list response.
func SkipUnlessIntegration ¶
SkipUnlessIntegration skips the test unless GPLAY_INTEGRATION_TEST is set to "1" or "true".
func TrackFixture ¶
func TrackFixture() map[string]interface{}
TrackFixture returns a sample Tracks.get response with a single release.
func TracksListFixture ¶
func TracksListFixture() map[string]interface{}
TracksListFixture returns a sample Tracks.list response.
Types ¶
type MockAPI ¶
MockAPI wraps an httptest.Server with request logging and convenience helpers.
func NewMockAPI ¶
NewMockAPI creates a new test server routing requests through the given handler map. Keys are "METHOD /path" (e.g. "GET /edits"). Unmatched requests receive a 404 response. Every request is recorded in the log. The server is automatically closed via t.Cleanup.
func (*MockAPI) BaseURL ¶
BaseURL returns the test server's URL (e.g. "http://127.0.0.1:PORT").
func (*MockAPI) RequestLog ¶
func (m *MockAPI) RequestLog() []RequestEntry
RequestLog returns a copy of all recorded requests.
type RequestEntry ¶
RequestEntry records a single HTTP request received by the mock server.