Documentation
¶
Overview ¶
Package contracttest provides a reusable test harness for verifying that platform backends satisfy the behavioral contracts defined by the provider.Provider interface.
Each backend's test suite imports this package and calls Run with a backend-specific Harness. This ensures that list/pagination, error classification, retry behavior, webhook validation, and context cancellation are consistent across every platform the SDK supports.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func VersionProxy ¶
VersionProxy returns a test server that responds to /api/v1/version with versionBody and reverse-proxies every other path to baseURL. Gitea/Forgejo SDKs require the version endpoint at client init; this wrapper lets the contract suite target those backends with a plain mock server.
Types ¶
type Harness ¶
type Harness struct {
// Name is the human-readable platform identifier (e.g. "GitHub").
Name string
// Platform is the provider.Platform constant for this backend.
Platform provider.Platform
// NewProvider builds a provider.Provider from the given config. The harness
// fills in BaseURL (and, for the retry subtest, RetryConfig) before calling,
// so the function should forward any supplied RetryConfig/Hooks rather than
// discarding them.
NewProvider func(t *testing.T, cfg provider.Config) provider.Provider
// EmptyListResponse is the JSON body the mock returns for empty lists.
EmptyListResponse string
// NonEmptyListResponse is the JSON body the mock returns for a non-empty
// list, with at least one item that maps to a valid repo.
NonEmptyListResponse string
}
Harness bundles the inputs needed to run the contract suite against a backend.