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 ¶
- func ParseSigned(t testing.TB, p provider.Provider, req *http.Request, secret string) *provider.NormalizedEvent
- func Run(t *testing.T, h Harness)
- func RunBranchProtectionsSuite(t *testing.T, h BranchProtectionsHarness)
- func RunBranchSuite(t *testing.T, h BranchHarness)
- func RunCRSuite(t *testing.T, h CRHarness)
- func RunCollaboratorsSuite(t *testing.T, h CollaboratorsHarness)
- func RunCommitSuite(t *testing.T, h CommitHarness)
- func RunDeployKeysSuite(t *testing.T, h DeployKeysHarness)
- func RunDeploymentsSuite(t *testing.T, h DeploymentsHarness)
- func RunDiffSuite(t *testing.T, h DiffHarness)
- func RunFileSuite(t *testing.T, h FileHarness)
- func RunForkSyncSuite(t *testing.T, h ForkSyncHarness)
- func RunGistsSuite(t *testing.T, h GistsHarness)
- func RunIssuesSuite(t *testing.T, h IssuesHarness)
- func RunLabelsSuite(t *testing.T, h LabelsHarness)
- func RunMigrationsSuite(t *testing.T, h MigrationsHarness)
- func RunMilestonesSuite(t *testing.T, h MilestonesHarness)
- func RunNotesSuite(t *testing.T, h NotesHarness)
- func RunNotificationsSuite(t *testing.T, h NotificationsHarness)
- func RunReactionsSuite(t *testing.T, h ReactionsHarness)
- func RunReleaseAssetsSuite(t *testing.T, h ReleaseAssetsHarness)
- func RunReleaseSuite(t *testing.T, h ReleaseHarness)
- func RunRepoStatsSuite(t *testing.T, h RepoStatsHarness)
- func RunReviewsSuite(t *testing.T, h ReviewsHarness)
- func RunSearchSuite(t *testing.T, h SearchHarness)
- func RunStarredSuite(t *testing.T, h StarredHarness)
- func RunTeamReviewsSuite(t *testing.T, h TeamReviewsHarness)
- func RunUsersSuite(t *testing.T, h UsersHarness)
- func RunWebhookConfigSuite(t *testing.T, h WebhookConfigHarness)
- func RunWebhookCorpus(t *testing.T, platform provider.Platform, parser WebhookParser, dir string)
- func VersionProxy(baseURL, versionBody string) *httptest.Server
- type BranchHarness
- type BranchHarnessConfig
- type BranchProtectionsHarness
- type BranchProtectionsHarnessConfig
- type CILogsHarnessConfig
- type CRHarness
- type CRHarnessConfig
- type ClearExpect
- type CollaboratorsHarness
- type CollaboratorsHarnessConfig
- type CommitHarness
- type CommitHarnessConfig
- type CommitStatusHarnessConfig
- type DeployKeysHarness
- type DeployKeysHarnessConfig
- type DeploymentsHarness
- type DeploymentsHarnessConfig
- type DiffHarness
- type DiffHarnessConfig
- type FileHarness
- type FileHarnessConfig
- type ForkSyncHarness
- type ForkSyncHarnessConfig
- type GistsHarness
- type GistsHarnessConfig
- type Harness
- type IssuesHarness
- type IssuesHarnessConfig
- type LabelsHarness
- type LabelsHarnessConfig
- type MigrationsHarness
- type MigrationsHarnessConfig
- type MilestonesHarness
- type MilestonesHarnessConfig
- type NotesHarness
- type NotesHarnessConfig
- type NotificationsHarness
- type NotificationsHarnessConfig
- type PageZeroFixture
- type ReactionsHarness
- type ReactionsHarnessConfig
- type ReleaseAssetsHarness
- type ReleaseAssetsHarnessConfig
- type ReleaseHarness
- type ReleasesHarnessConfig
- type RepoStatsHarness
- type RepoStatsHarnessConfig
- type RepoTemplatesHarnessConfig
- type ReviewsHarness
- type ReviewsHarnessConfig
- type SearchHarness
- type SearchHarnessConfig
- type StarredHarness
- type StarredHarnessConfig
- type TeamReviewsHarness
- type TeamReviewsHarnessConfig
- type UsersHarness
- type UsersHarnessConfig
- type WebhookConfigHarness
- type WebhookConfigHarnessConfig
- type WebhookParser
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseSigned ¶ added in v0.77.0
func ParseSigned(t testing.TB, p provider.Provider, req *http.Request, secret string) *provider.NormalizedEvent
ParseSigned signs req with the platform's registered webhook validator and secret, then parses the event through p.ParseWebhookEvent. Backend unit tests use it to exercise payload mapping without hand-rolling per-platform signature code — and since v0.77.0 an empty secret is rejected by every validator, so unsigned fixture requests no longer pass validation.
func RunBranchProtectionsSuite ¶
func RunBranchProtectionsSuite(t *testing.T, h BranchProtectionsHarness)
RunBranchProtectionsSuite tests branch-protection CRUD operations.
func RunBranchSuite ¶ added in v0.125.0
func RunBranchSuite(t *testing.T, h BranchHarness)
RunBranchSuite executes the branch contract suite: list parses, create mutates via a state-changing verb, delete issues a DELETE.
func RunCRSuite ¶ added in v0.125.0
RunCRSuite executes the change-request contract suite. The mock records every request; GETs ending at a CR collection return ListResponse on the first list call and an empty array on later ones (walk terminator), every other GET returns GetResponse, POST returns 201 + MutateResponse, PATCH/PUT return MutateResponse, DELETE returns 204.
func RunCollaboratorsSuite ¶
func RunCollaboratorsSuite(t *testing.T, h CollaboratorsHarness)
RunCollaboratorsSuite tests collaborator list operations.
func RunCommitSuite ¶ added in v0.125.0
func RunCommitSuite(t *testing.T, h CommitHarness)
RunCommitSuite executes the commit contract suite: get/list parse the unified CommitInfo, compare parses either commits or files.
func RunDeployKeysSuite ¶
func RunDeployKeysSuite(t *testing.T, h DeployKeysHarness)
RunDeployKeysSuite tests deploy-key CRUD operations.
func RunDeploymentsSuite ¶ added in v0.139.0
func RunDeploymentsSuite(t *testing.T, h DeploymentsHarness)
RunDeploymentsSuite tests the deployment-manager wire contract: the create POST carries ref/environment (plus the option fields) and parses, the list GET carries the environment filter + paging and parses with the page-item count convention, a legal status state POSTs its state, and an illegal state is rejected pre-wire with zero requests.
func RunDiffSuite ¶ added in v0.125.0
func RunDiffSuite(t *testing.T, h DiffHarness)
RunDiffSuite executes the diff contract suite — the #44 silent-truncation family: GetCRFiles and GetCRDiff must parse and normalize the changed-file set, and CreateNote must carry the note body.
func RunFileSuite ¶ added in v0.125.0
func RunFileSuite(t *testing.T, h FileHarness)
RunFileSuite executes the file contract suite: GetFileContent must decode the platform's content encoding into the raw bytes.
func RunForkSyncSuite ¶ added in v0.139.0
func RunForkSyncSuite(t *testing.T, h ForkSyncHarness)
RunForkSyncSuite tests the fork-sync manager wire contract: a normal SyncFork POSTs {branch} to the merge-upstream route, and an empty branch is rejected pre-wire with zero requests (never a merge-upstream call with an empty branch).
func RunGistsSuite ¶ added in v0.139.0
func RunGistsSuite(t *testing.T, h GistsHarness)
RunGistsSuite tests the gist-manager wire contract: GET /gists (the token user's own list, never the users/{login}/gists public route) parses into provider.Gist, and page/perPage land in the query after normalization.
func RunIssuesSuite ¶
func RunIssuesSuite(t *testing.T, h IssuesHarness)
RunIssuesSuite executes the issue-management contract suite. The mock routes by method and path shape so platform-specific paths don't matter: GET ending /issues/{alphanumeric} → GetResponse (issue numbers are not always numeric — Gitee's are alphanumeric); GET containing comments|notes → CommentsResponse; GET containing labels (not issues) → LabelsResponse; other GET → ListResponse; POST → 201 + MutateResponse (a POST to a labels path — adding labels to an issue — returns LabelsResponse, since GitHub-shaped APIs answer with the label array); PUT to a labels path — replacing an issue's labels — likewise returns LabelsResponse (an issue object there breaks the []*Label parse); PATCH/PUT → MutateResponse; DELETE → 204. Requests are recorded for wire assertions.
func RunLabelsSuite ¶
func RunLabelsSuite(t *testing.T, h LabelsHarness)
RunLabelsSuite executes the label-management contract suite. The mock server routes by HTTP method so platform-specific paths don't matter: GET returns ListResponse, POST returns 201 + MutateResponse, PATCH/PUT return 200 + MutateResponse, DELETE returns 204. The mock also records every request (method, path+query, decoded body) so the subtests can assert the wire behavior behind each operation: pagination parameters on list, the verb and body on create/update/delete, and that update does not clobber fields the caller left nil.
func RunMigrationsSuite ¶ added in v0.139.0
func RunMigrationsSuite(t *testing.T, h MigrationsHarness)
RunMigrationsSuite tests the migration-manager wire contract: org emptiness picks the Create route (user vs org), the org Get route carries the id, both calls send the GA Accept header, both Create routes share the lock/exclude request body, and responses parse into provider.MigrationInfo.
func RunMilestonesSuite ¶
func RunMilestonesSuite(t *testing.T, h MilestonesHarness)
RunMilestonesSuite executes the milestone-management contract suite. The mock server is dedicated to milestone paths (route by "milestones" in the path so platform-specific prefixes don't matter) and routes by HTTP method: GET → ListResponse (array); POST → 201 + MutateResponse; PATCH/PUT → MutateResponse (GitLab updates with PUT, the rest with PATCH); DELETE → 204. Requests are recorded for wire assertions.
func RunNotesSuite ¶ added in v0.99.8
func RunNotesSuite(t *testing.T, h NotesHarness)
RunNotesSuite tests CR-comment update and full listing. The mock routes by method only: GET serves the notes array (page-aware so AllPages walkers stop), PUT returns the mutated note — both platforms' note-edit verbs are PUT.
func RunNotificationsSuite ¶
func RunNotificationsSuite(t *testing.T, h NotificationsHarness)
RunNotificationsSuite executes the notification contract suite.
func RunReactionsSuite ¶
func RunReactionsSuite(t *testing.T, h ReactionsHarness)
RunReactionsSuite executes the reaction contract suite.
func RunReleaseAssetsSuite ¶ added in v0.139.0
func RunReleaseAssetsSuite(t *testing.T, h ReleaseAssetsHarness)
RunReleaseAssetsSuite tests the release-asset download contract: bytes reach w verbatim on both wire forms (direct 200 and 302 → token-less followClient hop), a zero-length body writes nothing, and a 404 lands in the provider NotFound chain with no bytes written.
func RunReleaseSuite ¶
func RunReleaseSuite(t *testing.T, h ReleaseHarness)
RunReleaseSuite executes the release-management contract suite. The mock routes by method and path shape so platform-specific paths don't matter: GET ending at a releases collection (…/releases) returns a one-element array wrapping ByTagResponse (list-shaped); every other GET returns the ByTagResponse object — this covers both the native by-tag fetches (…/releases/tags/{tag} on GitHub/Gitea/Forgejo/Gitee/GitCode, …/releases/{tag} on GitLab/TencentCode) and the tag→id resolution fetches ID-addressed platforms make before update/delete, which go through the same single-release endpoints; PATCH/PUT return UpdateResponse; DELETE returns 200 + ByTagResponse — GitLab's delete responds with the deleted release object and its SDK decodes it, while the body-agnostic platforms ignore it (the shared transport skips decoding for nil results). Requests are recorded for wire assertions.
func RunRepoStatsSuite ¶
func RunRepoStatsSuite(t *testing.T, h RepoStatsHarness)
RunRepoStatsSuite tests repo-stats read operations, one subtest per method with its own fixture. The outcome contract (issue #56) is exact, not skip-shaped:
- implemented: the fixture must decode into a non-empty result;
- stub: the error must wrap provider.ErrNotImplemented AND be locked by a matching DivergenceStub ledger entry (the pairing direction the DivergenceSuite cannot see — it only walks the ledger forward);
- anything else: a failure, not a skip (the old skipf swallowed every error, so the suite was green while asserting nothing).
func RunReviewsSuite ¶
func RunReviewsSuite(t *testing.T, h ReviewsHarness)
RunReviewsSuite executes the review-management contract suite. The mock routes by method and path shape so platform-specific paths don't matter: GET ending /reviews/{digits} or /notes/{digits} → GetResponse; other GET → ListResponse; POST → 201 + MutateResponse; PUT/PATCH → MutateResponse (GitHub's dismiss is a PUT to a .../dismissals sub-resource); DELETE → 204. Requests are recorded for wire assertions.
func RunSearchSuite ¶
func RunSearchSuite(t *testing.T, h SearchHarness)
RunSearchSuite executes the search contract suite. The mock server is dedicated to search requests and routes pragmatically, because the platforms disagree on both paths and encoding:
- GitLab sends every scope to the same path (/search) with a scope query param, so a scope param wins when present: projects -> repos, issues -> issues, users -> users.
- Otherwise the path is matched: "repositories" (GitHub/Gitee/GitCode /search/repositories) or "projects" -> repos; "issues" (including Gitea/Forgejo's /repos/issues/search) -> issues; "users" -> users.
- Anything else falls back to the repos fixture, which covers Gitea/Forgejo's bare /repos/search path.
Subtests: each search parses its fixture (repos by full_name, issues by title + string number, users by login) and the query keyword reaches the wire under some query parameter; the repo-scoped subtest additionally verifies SearchIssuesOptions.Repo takes a wire route that reflects the repo (path-embedded or query-carried, per platform).
func RunStarredSuite ¶ added in v0.139.0
func RunStarredSuite(t *testing.T, h StarredHarness)
RunStarredSuite tests the starred-manager wire contract: GET user/starred requests the star+json Accept header, carries normalized paging, and decodes both the wrapped ({repo:…}) and bare repository shapes into provider.PlatformRepo.
func RunTeamReviewsSuite ¶ added in v0.139.0
func RunTeamReviewsSuite(t *testing.T, h TeamReviewsHarness)
RunTeamReviewsSuite tests the team-review-manager wire contract (issue #79): a legal request posts every team slug to the requested_reviewers route (value assertion, platform-agnostic across the three declaring backends), and an invalid PR number is rejected pre-wire with zero requests.
func RunUsersSuite ¶
func RunUsersSuite(t *testing.T, h UsersHarness)
RunUsersSuite tests user lookup operations.
func RunWebhookConfigSuite ¶ added in v0.99.9
func RunWebhookConfigSuite(t *testing.T, h WebhookConfigHarness)
RunWebhookConfigSuite tests single-webhook get/update.
func RunWebhookCorpus ¶ added in v0.72.0
RunWebhookCorpus runs the golden-file webhook corpus under dir: every <event>.json fixture (raw POST body + required headers) is parsed by parser and the normalized event compared byte-for-byte against <event>.golden.json with the volatile fields (ID, Timestamp, RawPayload) cleared. The corpus is the cross-platform uniformity net: every backend must map its platform's wire events onto the same canonical vocabulary (cr./push/tag./branch./issue./comment.) with the same payload fields populated.
Fixture format:
{
"headers": {"X-Gitea-Event": "issues"}, // per-platform event headers
"body": { ...raw webhook payload... }
}
The driver signs requests with the platform's registered validator and corpusSecret, so signature validation runs end to end.
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 BranchHarness ¶ added in v0.125.0
type BranchHarness struct {
Name string
Platform provider.Platform
NewProvider newProviderFn
BranchHarnessConfig
}
type BranchHarnessConfig ¶ added in v0.125.0
BranchHarnessConfig carries the branch suite fixtures. ListResponse's first branch must be named "main"; MutateResponse is the create/delete response body in the platform's own shape.
type BranchProtectionsHarness ¶
type BranchProtectionsHarness struct {
Name string
Platform provider.Platform
NewProvider func(t *testing.T, cfg provider.Config) provider.Provider
ListResponse string
MutateResponse string
GetResponse string
ListUnsupported bool
GetUnsupported bool
}
BranchProtectionsHarness bundles inputs for the branch-protection suite.
type BranchProtectionsHarnessConfig ¶
type BranchProtectionsHarnessConfig struct {
ListResponse string
MutateResponse string
// GetResponse is the JSON object for a single-protection GET (same
// shape as MutateResponse). Empty = harness not wired yet: the Get
// subtest skips, the rest of the suite is affected by the
// List/GetUnsupported flags below.
GetResponse string
// ListUnsupported/GetUnsupported declare the platform's documented
// "no such endpoint" stubs (registered as DivergenceStub in the
// backend's divergence ledger): the corresponding subtests skip instead
// of failing on the nil,nil contract. Mirrors UpdateSendsDescriptionOnly.
ListUnsupported bool
GetUnsupported bool
}
BranchProtectionsHarnessConfig carries fixtures for the branch-protection suite. All fields are required.
type CILogsHarnessConfig ¶ added in v0.111.0
CILogsHarnessConfig mounts the CI failure-diagnostics suite. The suite drives ListFailedJobLogs against a recording server and asserts the response converts to []provider.JobLog with populated Name/Stage fields.
GreenResponse is the JSON body the mock returns for a commit with no failed CI jobs (the platform's "no runs" or "all green" shape). The suite asserts ListFailedJobLogs returns an empty slice on this shape.
FailedResponse is the JSON body for a commit with at least one failed job. It must decode into at least one failed-job entry under the backend's converter (conclusion "failure" or "timed_out"). The suite asserts the returned JobLog has non-empty Name and Stage.
type CRHarness ¶ added in v0.125.0
type CRHarness struct {
Name string
Platform provider.Platform
NewProvider func(t *testing.T, cfg provider.Config) provider.Provider
CRHarnessConfig
}
CRHarness is the full harness RunCRSuite consumes.
type CRHarnessConfig ¶ added in v0.125.0
type CRHarnessConfig struct {
// ListResponse is the JSON array for CR-list GETs. First item: the
// platform's addressing identifier rendering as "1", title "fix bug",
// open state, source branch "feature-x", target branch "main".
ListResponse string
// GetResponse is the JSON object for a single-CR GET (same shape as the
// first list item).
GetResponse string
// MutateResponse is the JSON object for create/update/merge
// POST/PATCH/PUT responses (same shape).
MutateResponse string
// PageZeroWalks declares that Page==0 walks every page (the registered
// caller-paged-family departure, currently Tencent Code — cross-checked
// against the ledger's ListCRs Page divergence, so a stale flag fails
// the run).
PageZeroWalks bool
// CreateDraftUnsupported declares that CreateCR(Draft=true) returns
// provider.ErrDraftNotSupported(#160:SDK/API 创建面无 draft 参数,
// gitlab/gitea/forgejo/tencentcode)——cross-checked against the
// ledger's CreateCR Field:"opts.Draft" entry, so a stale flag fails
// the run.
CreateDraftUnsupported bool
// CRClear 声明各字段清空请求的期望(键:description/assignees)。
// nil = 两字段全部必须可清空(全 A 级平台可不设)。
CRClear map[string]ClearExpect
}
CRHarnessConfig carries the fixtures a backend's main Harness needs to auto-mount the change-request suite via Harness.CRs (issue #63: the CR family had zero behavior assertions and hosted the highest-yield historical bugs — #44 silent truncation, #78 filter semantics).
ChangeRequestManager is a core interface composed into provider.Provider and implemented by every backend, so the config is mandatory for all seven platforms; individual fixture fields may be empty, which skips their subtest without failing the run.
type ClearExpect ¶ added in v0.135.0
type ClearExpect struct {
Unsupported bool
Method string // "" = PATCH 或 PUT
BodyField string // "" = 不断言 body(无 body 的侧端点,如 DELETE)
PathContains string // "" = 不断言路径
}
ClearExpect 声明某字段「清空请求」的期望形态(2A A/B 能力矩阵)。 Unsupported=true:B 级——必须返回 ErrClearNotSupported 且零新请求; 否则:请求必须发出,BodyField 在场为空值(""/[]/{}/null/0)、 PathContains 命中(侧端点定位)、Method 为 "" 时 PATCH/PUT 皆可。
type CollaboratorsHarness ¶
type CollaboratorsHarness struct {
Name string
Platform provider.Platform
NewProvider func(t *testing.T, cfg provider.Config) provider.Provider
ListResponse string
UserLookupResponse string
}
CollaboratorsHarness bundles inputs for the collaborator suite.
type CollaboratorsHarnessConfig ¶
type CollaboratorsHarnessConfig struct {
ListResponse string
// UserLookupResponse, when set, is served for the username→ID lookup
// GET (…/users/{username}) that platforms with ID-addressed member
// APIs (GitLab, TencentCode) perform before add/remove mutations.
// Empty means the platform addresses collaborators by username
// directly and makes no lookup.
UserLookupResponse string
}
CollaboratorsHarnessConfig carries fixtures for the collaborator suite.
type CommitHarness ¶ added in v0.125.0
type CommitHarness struct {
Name string
Platform provider.Platform
NewProvider newProviderFn
CommitHarnessConfig
}
type CommitHarnessConfig ¶ added in v0.125.0
type CommitHarnessConfig struct {
GetResponse string
ListResponse string
CompareResponse string // empty = the Compare subtest skips
}
CommitHarnessConfig carries the commit suite fixtures. GetResponse's commit must carry sha/id "abc123" and message "commit msg".
type CommitStatusHarnessConfig ¶
CommitStatusHarnessConfig mounts the commit-status suite. The suite is self-driving: it records requests, invokes CreateCommitStatus and ListCommitStatuses, and asserts exactly one status request per operation reached the wire.
ListResponse is the platform-shaped JSON fixture served for the ListCommitStatuses probe; it must decode into at least one status with a non-empty State under the backend's converter. It is required whenever the platform declares the CommitStatuses capability.
EmptyResponse is the platform-shaped JSON body served on page ≥ 2 to terminate the pagination walk. It defaults to Harness.EmptyListResponse; set it when the status endpoint's empty shape differs from the platform's usual empty-list shape (e.g. Gitee's wrapped check-run object).
type DeployKeysHarness ¶
type DeployKeysHarness struct {
Name string
Platform provider.Platform
NewProvider func(t *testing.T, cfg provider.Config) provider.Provider
ListResponse string
CreateResponse string
}
DeployKeysHarness bundles inputs for the deploy-key suite.
type DeployKeysHarnessConfig ¶
DeployKeysHarnessConfig carries fixtures for the deploy-key suite.
type DeploymentsHarness ¶ added in v0.139.0
type DeploymentsHarness struct {
Name string
Platform provider.Platform
NewProvider func(t *testing.T, cfg provider.Config) provider.Provider
CreateResponse string
ListResponse string
StatusResponse string
}
DeploymentsHarness bundles inputs for the deployment suite.
type DeploymentsHarnessConfig ¶ added in v0.139.0
type DeploymentsHarnessConfig struct {
// CreateResponse is the JSON POST /repos/{o}/{r}/deployments answers
// with. It must decode to a non-zero id with non-empty ref/environment:
// the suite compares the provider's parse against a canonical stdlib
// decode of this exact fixture (assertDeployment), so a wire-key
// mapping regression fails here.
CreateResponse string
// ListResponse is the JSON array GET /repos/{o}/{r}/deployments answers
// with — at least one element carrying a non-zero id (the parse check
// would pass vacuously against an empty or typo'd fixture otherwise).
ListResponse string
// StatusResponse is the JSON POST .../deployments/{id}/statuses answers
// with. The provider discards the body, but the SDK still decodes it,
// so it must be a valid status object.
StatusResponse string
}
DeploymentsHarnessConfig carries fixtures for the deployment suite.
type DiffHarness ¶ added in v0.125.0
type DiffHarness struct {
Name string
Platform provider.Platform
NewProvider newProviderFn
DiffHarnessConfig
}
type DiffHarnessConfig ¶ added in v0.125.0
type DiffHarnessConfig struct {
FilesResponse string
DiffRaw string
// ChangesResponse serves the wrapped-object shape of a changes endpoint
// (gongfeng's merge_request/{id}/changes returns {"files":[…]} instead
// of a bare array); it takes priority over FilesResponse when the path
// addresses changes.
ChangesResponse string
// FilesWithoutHunks declares that the platform's changed-file endpoint
// carries no hunk text (gitea family: filename/status/additions only),
// so the hunk assertion relaxes to additions/deletions.
FilesWithoutHunks bool
}
DiffHarnessConfig carries the diff suite fixtures. FilesResponse is the changed-file array served for both the files endpoint and the JSON diffs endpoint (every platform serves GetCRDiff and GetCRFiles from one endpoint); first file must be "a.txt" carrying "@@" in its diff. DiffRaw is the raw unified-diff text for platforms whose GetCRDiff reads a text endpoint (gitea family).
type FileHarness ¶ added in v0.125.0
type FileHarness struct {
Name string
Platform provider.Platform
NewProvider newProviderFn
FileHarnessConfig
}
type FileHarnessConfig ¶ added in v0.125.0
type FileHarnessConfig struct {
GetResponse string
// ContentIsRaw declares that the platform's content endpoint returns the
// raw bytes (gitea family) instead of an envelope carrying base64.
ContentIsRaw bool
}
FileHarnessConfig carries the file suite fixtures. GetResponse carries the base64 content of "hello world" under the platform's content/encoding keys (all seven platforms decode via provider.DecodeFileContent).
type ForkSyncHarness ¶ added in v0.139.0
type ForkSyncHarness struct {
Name string
Platform provider.Platform
NewProvider func(t *testing.T, cfg provider.Config) provider.Provider
MergeResponse string
}
ForkSyncHarness bundles inputs for the fork-sync suite.
type ForkSyncHarnessConfig ¶ added in v0.139.0
type ForkSyncHarnessConfig struct {
// MergeResponse is the JSON POST /repos/{o}/{r}/merge-upstream answers
// with (the RepoMergeUpstreamResult shape: message/merge_type/base_
// branch). SyncFork discards the body, but the SDK still decodes it, so
// it must be a valid object.
MergeResponse string
}
ForkSyncHarnessConfig carries fixtures for the fork-sync suite.
type GistsHarness ¶ added in v0.139.0
type GistsHarness struct {
Name string
Platform provider.Platform
NewProvider func(t *testing.T, cfg provider.Config) provider.Provider
ListResponse string
}
GistsHarness bundles inputs for the gist-list suite.
type GistsHarnessConfig ¶ added in v0.139.0
type GistsHarnessConfig struct {
// ListResponse is the JSON array the mock returns for GET /gists. Its
// first element must have a non-empty id and description — the suite
// asserts both parse into provider.Gist.
ListResponse string
}
GistsHarnessConfig carries fixtures for the gist-list suite.
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
// Labels, when non-nil, auto-mounts the label-management suite inside
// Run. Run enforces both directions: a platform declaring
// Capabilities().Labels must provide this config, and a config must not
// be provided by a platform that does not declare the capability.
Labels *LabelsHarnessConfig
// Issues, when non-nil, auto-mounts the issue-management suite inside
// Run, with the same bidirectional drift checks as Labels.
Issues *IssuesHarnessConfig
// Reviews, when non-nil, auto-mounts the review-management suite inside
// Run, with the same bidirectional drift checks as Labels and Issues.
Reviews *ReviewsHarnessConfig
// Milestones, when non-nil, auto-mounts the milestone-management suite
// inside Run, with the same bidirectional drift checks as Labels,
// Issues, and Reviews.
Milestones *MilestonesHarnessConfig
// Search, when non-nil, auto-mounts the search suite inside Run, with
// the same bidirectional drift checks as Labels, Issues, Reviews, and
// Milestones.
Search *SearchHarnessConfig
// CommitStatus, when non-nil, auto-mounts the commit-status suite inside
// Run, with the same bidirectional drift checks as Labels, Issues,
// Reviews, Milestones, and Search.
CommitStatus *CommitStatusHarnessConfig
// Notifications, when non-nil, auto-mounts the notification suite inside
// Run, with the same bidirectional drift checks.
Notifications *NotificationsHarnessConfig
// Reactions, when non-nil, auto-mounts the reaction suite inside
// Run, with the same bidirectional drift checks.
Reactions *ReactionsHarnessConfig
// BranchProtections, when non-nil, auto-mounts the branch-protection
// suite inside Run, with the same bidirectional drift checks.
BranchProtections *BranchProtectionsHarnessConfig
// Collaborators, when non-nil, auto-mounts the collaborator suite.
Collaborators *CollaboratorsHarnessConfig
// WebhookConfig, when non-nil, auto-mounts the single-webhook
// get/update suite (WebhookConfigManager — all seven backends).
WebhookConfig *WebhookConfigHarnessConfig
// Notes, when non-nil, auto-mounts the CR-note (merge-request note)
// read/edit suite — GitLab-family platforms where MR notes live in a
// separate iid namespace (GitHub-family: covered by IssueManager, no
// config expected).
Notes *NotesHarnessConfig
// DeployKeys, when non-nil, auto-mounts the deploy-key suite.
DeployKeys *DeployKeysHarnessConfig
// RepoStats, when non-nil, auto-mounts the repo-stats suite.
RepoStats *RepoStatsHarnessConfig
// Users, when non-nil, auto-mounts the user-manager suite.
Users *UsersHarnessConfig
// CILogs, when non-nil, auto-mounts the CI failure-diagnostics suite.
CILogs *CILogsHarnessConfig
// RepoTemplates, when non-nil, auto-mounts the template-repo suite.
RepoTemplates *RepoTemplatesHarnessConfig
// Gists, when non-nil, auto-mounts the gist-list suite inside Run, with
// the same bidirectional drift checks as Users.
Gists *GistsHarnessConfig
// Starred, when non-nil, auto-mounts the starred-repo list suite inside
// Run, with the same bidirectional drift checks as Users.
Starred *StarredHarnessConfig
// Migrations, when non-nil, auto-mounts the migration suite inside Run,
// with the same bidirectional drift checks as Users.
Migrations *MigrationsHarnessConfig
// ReleaseAssets, when non-nil, auto-mounts the release-asset download
// suite inside Run, with the same bidirectional drift checks as Users.
ReleaseAssets *ReleaseAssetsHarnessConfig
// Deployments, when non-nil, auto-mounts the deployment suite inside
// Run, with the same bidirectional drift checks as Users.
Deployments *DeploymentsHarnessConfig
// ForkSync, when non-nil, auto-mounts the fork-sync suite inside Run,
// with the same bidirectional drift checks as Users.
ForkSync *ForkSyncHarnessConfig
// TeamReviews, when non-nil, auto-mounts the team-review request suite
// inside Run, with the same bidirectional drift checks as the other
// optional-capability families (github/gitea/forgejo declare it).
TeamReviews *TeamReviewsHarnessConfig
// Releases auto-mounts the release-management suite inside Run. Unlike
// the fields above, ReleaseManager is a core interface composed into
// provider.Provider (every backend implements it), so there is no
// capability-declaration drift to check — the config is mandatory and
// the suite fails the run when it is missing.
Releases *ReleasesHarnessConfig
// CRs auto-mounts the change-request suite inside Run (issue #63).
// ChangeRequestManager is a core interface: the config is mandatory and
// the suite fails the run when it is missing.
CRs *CRHarnessConfig
// Branches / Commits / Diffs / Files auto-mount the remaining core
// manager suites (issue #63). Configs are mandatory; individual fixture
// fields may be empty (their subtest then skips with a named message).
Branches *BranchHarnessConfig
Commits *CommitHarnessConfig
Diffs *DiffHarnessConfig
Files *FileHarnessConfig
}
Harness bundles the inputs needed to run the contract suite against a backend.
type IssuesHarness ¶
type IssuesHarness struct {
Name string
Platform provider.Platform
NewProvider func(t *testing.T, cfg provider.Config) provider.Provider
IssuesHarnessConfig
}
IssuesHarness is the full harness RunIssuesSuite consumes; auto-mounting builds it from the enclosing Harness plus IssuesHarnessConfig.
type IssuesHarnessConfig ¶
type IssuesHarnessConfig struct {
// ListResponse is the JSON array for issue-list GETs. First item: number
// 1, title "bug", state "open", milestone {number:1, title:"v1"}.
ListResponse string
// GetResponse is the JSON object for single-issue GETs (number 1, title
// "bug", state "open", milestone {number:1, title:"v1"}).
GetResponse string
// MutateResponse is the JSON object for POST/PATCH/PUT (same shape as
// GetResponse).
MutateResponse string
// CommentsResponse is the JSON array for issue-comment GETs. First item:
// id 1, body "a comment".
CommentsResponse string
// LabelsResponse is the JSON array for repository-label GETs. First
// item: id 1, name "bug", color "#4cc917".
LabelsResponse string
// CreateIssueAssigneesByID declares that the backend resolves issue
// assignee usernames through a users lookup (GitLab's /users?username=
// exact-match filter, Tencent 工蜂's /users/{username} endpoint) and
// writes numeric assignee IDs. When set, the suite asserts the
// lookup-then-write wire shape on CreateIssue; when unset, the create
// subtest exercises the plain title-only wire (the default).
CreateIssueAssigneesByID bool
// UpdateCommentViaIssue declares that the backend addresses an issue
// comment edit through the issue (GitLab, Tencent 工蜂 note APIs): the
// suite additionally asserts the recorded edit request hits
// issues/1/notes/1, so a swap of the number and commentID plumbing
// fails instead of passing on the body assertion alone.
UpdateCommentViaIssue bool
// IssueClear 声明各字段清空请求的期望(键:body/assignees/labels/
// milestone)。nil = 四字段全部必须可清空(全 A 级平台可不设)。
IssueClear map[string]ClearExpect
}
IssuesHarnessConfig carries the fixtures a backend's main Harness needs to auto-mount the issue-management suite via Harness.Issues.
type LabelsHarness ¶
type LabelsHarness 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; the harness fills in BaseURL.
// It must construct the provider the same way the platform's main
// harness does (including any VersionProxy wrapping for Gitea/Forgejo).
NewProvider func(t *testing.T, cfg provider.Config) provider.Provider
// ListResponse is the JSON array the mock returns for GET requests
// (label listings and name→ID resolution lookups). Its first item must
// have name "bug" and color "#4cc917" so the suite can assert color
// normalization.
ListResponse string
// MutateResponse is the JSON object the mock returns for POST/PATCH
// requests. It must have name "bug" and color "#4cc917".
MutateResponse string
// IgnoresListPagination declares that the backend's list endpoint does
// not accept pagination parameters, so the suite skips its wire-level
// page/per-page assertion. Currently only GitCode sets this: its SDK's
// ListIssueLabels exposes no page/page-size parameters, so ListLabels
// silently drops ListLabelsOptions on the wire. That is a known contract
// gap, not something the other five backends share.
IgnoresListPagination bool
}
LabelsHarness bundles the inputs needed to run the label-management contract suite against a backend that implements provider.LabelManager.
type LabelsHarnessConfig ¶
type LabelsHarnessConfig struct {
// ListResponse is the JSON array the mock returns for GET requests. Its
// first item must have name "bug" and color "#4cc917".
ListResponse string
// MutateResponse is the JSON object the mock returns for POST/PATCH/PUT
// requests. It must have name "bug" and color "#4cc917".
MutateResponse string
// IgnoresListPagination opts the backend out of the wire-level
// pagination assertion (see LabelsHarness.IgnoresListPagination).
IgnoresListPagination bool
}
LabelsHarnessConfig carries the fixtures a backend's main Harness needs to auto-mount the label-management suite via Harness.Labels. Name, Platform, and NewProvider are reused from the enclosing Harness.
type MigrationsHarness ¶ added in v0.139.0
type MigrationsHarness struct {
Name string
Platform provider.Platform
NewProvider func(t *testing.T, cfg provider.Config) provider.Provider
CreateResponse string
GetResponse string
}
MigrationsHarness bundles inputs for the migration suite.
type MigrationsHarnessConfig ¶ added in v0.139.0
type MigrationsHarnessConfig struct {
// CreateResponse is the JSON both POST user/migrations and POST
// orgs/{org}/migrations answer with. It must decode to a non-zero id and
// a non-empty state: the suite compares the provider's parse against a
// canonical stdlib decode of this exact fixture (assertMigrationInfo),
// so a wire-key mapping regression fails here.
CreateResponse string
// GetResponse is the JSON GET .../migrations/{id} answers with. Include a
// non-empty archive_url so the exported-terminal field mapping is pinned
// as well.
GetResponse string
}
MigrationsHarnessConfig carries fixtures for the migration suite.
type MilestonesHarness ¶
type MilestonesHarness struct {
Name string
Platform provider.Platform
NewProvider func(t *testing.T, cfg provider.Config) provider.Provider
MilestonesHarnessConfig
}
MilestonesHarness is the full harness RunMilestonesSuite consumes; auto-mounting builds it from the enclosing Harness plus MilestonesHarnessConfig.
type MilestonesHarnessConfig ¶
type MilestonesHarnessConfig struct {
// ListResponse is the JSON array for milestone-list GETs. First item:
// the platform's addressing identifier ("number" on GitHub and Gitee,
// "id" on GitLab, Gitea, Forgejo, GitCode, and Tencent Code) rendering
// as the string "1", title "v1", state "open" (GitLab's wire state
// "active" is also accepted — the backend normalizes it).
ListResponse string
// GetResponse is the JSON object for a single-milestone GET (same shape
// as the first list item). Empty = the harness has not wired the single-
// get endpoint yet: the Get subtest skips, the rest of the suite is
// unaffected.
GetResponse string
// MutateResponse is the JSON object for POST/PATCH/PUT (same shape as
// the first list item).
MutateResponse string
}
MilestonesHarnessConfig carries the fixtures a backend's main Harness needs to auto-mount the milestone-management suite via Harness.Milestones.
type NotesHarness ¶ added in v0.99.8
type NotesHarness struct {
Name string
Platform provider.Platform
NewProvider func(t *testing.T, cfg provider.Config) provider.Provider
ListResponse string
MutateResponse string
}
NotesHarness bundles inputs for the CR-note suite.
type NotesHarnessConfig ¶ added in v0.99.8
type NotesHarnessConfig struct {
// ListResponse is the JSON array served for the notes-list GET (and
// the empty terminal page beyond page 1). Required shape: at least
// one note with id/body/author.username.
ListResponse string
// MutateResponse is the JSON object returned by the note-edit PUT.
MutateResponse string
}
NotesHarnessConfig carries the fixtures a backend needs to auto-mount the CR-note (merge-request note) read/edit suite via Harness.Notes.
NoteManager is an optional capability interface with GitLab-family semantics: MR notes live in their own iid namespace, so the IssueManager comment tools 404 for merge requests there. GitHub-family platforms (an issue IS the PR) are covered by IssueManager and are expected NOT to provide this config.
type NotificationsHarness ¶
type NotificationsHarness struct {
Name string
Platform provider.Platform
NewProvider func(t *testing.T, cfg provider.Config) provider.Provider
ListResponse string
GlobalUnsupported bool
}
NotificationsHarness bundles the inputs needed to run the notification contract suite against a backend that implements provider.NotificationManager.
type NotificationsHarnessConfig ¶
type NotificationsHarnessConfig struct {
// ListResponse is the JSON array the mock returns for notification list
// requests. It must contain at least one notification with unread=true.
ListResponse string
// GlobalUnsupported declares that the platform serves only the
// repo-scoped half of NotificationManager: the global methods
// (ListNotifications / MarkNotificationRead / MarkNotificationsRead)
// must then fail with ErrNotImplemented — the interface couples the
// global and repo halves, and some platforms (GitCode, live-verified
// 2026-11-03) have no global inbox. When set, the suite also asserts
// the repo-scoped methods stay functional.
GlobalUnsupported bool
}
NotificationsHarnessConfig carries the fixtures a backend's main Harness needs to auto-mount the notification suite via Harness.Notifications.
type PageZeroFixture ¶ added in v0.125.0
type PageZeroFixture struct {
// Platform is the provider.Platform constant the suite's Harness carries.
Platform provider.Platform
// ListBody is the fixture served on the first list GET.
ListBody string
// EmptyBody is the terminal empty page in the same top-level JSON shape
// as ListBody (array `[]` or wrapped object).
EmptyBody string
// PathFilter restricts which paths count as list requests (nil = all).
PathFilter func(*http.Request) bool
// ListZero issues the manager's list call with zero-valued options.
ListZero func(p provider.Provider) error
// ListPageOne issues the manager's list call with Page:1.
ListPageOne func(p provider.Provider) error
}
PageZeroFixture carries the manager-specific pieces the exhaustive-family suites hand to runPageZeroDualModeSuite.
type ReactionsHarness ¶
type ReactionsHarness struct {
Name string
Platform provider.Platform
NewProvider func(t *testing.T, cfg provider.Config) provider.Provider
ListResponse string
CreateResponse string
}
ReactionsHarness bundles the inputs needed to run the reaction contract suite against a backend that implements provider.ReactionManager.
type ReactionsHarnessConfig ¶
type ReactionsHarnessConfig struct {
// ListResponse is the JSON array the mock returns for reaction list
// requests. It must contain at least one reaction with content "+1".
ListResponse string
// CreateResponse is the JSON object the mock returns for reaction create
// requests.
CreateResponse string
}
ReactionsHarnessConfig carries the fixtures a backend's main Harness needs to auto-mount the reaction suite via Harness.Reactions.
type ReleaseAssetsHarness ¶ added in v0.139.0
type ReleaseAssetsHarness struct {
Name string
Platform provider.Platform
NewProvider func(t *testing.T, cfg provider.Config) provider.Provider
AssetBytes string
}
ReleaseAssetsHarness bundles inputs for the release-asset download suite.
type ReleaseAssetsHarnessConfig ¶ added in v0.139.0
type ReleaseAssetsHarnessConfig struct {
// AssetBytes is the exact byte string the mock serves for the asset
// endpoint — directly (200 form) and on the redirect target (302 form).
// The suite asserts DownloadReleaseAsset writes it to w verbatim; keep a
// value with multi-byte UTF-8 so a byte-vs-rune slicing regression shows
// up as a mismatch.
AssetBytes string
}
ReleaseAssetsHarnessConfig carries fixtures for the release-asset download suite.
type ReleaseHarness ¶
type ReleaseHarness struct {
Name string
Platform provider.Platform
NewProvider func(t *testing.T, cfg provider.Config) provider.Provider
ReleasesHarnessConfig
}
ReleaseHarness is the full harness RunReleaseSuite consumes; auto-mounting builds it from the enclosing Harness plus ReleasesHarnessConfig.
type ReleasesHarnessConfig ¶
type ReleasesHarnessConfig struct {
// ByTagResponse is the JSON object for single-release fetches. Required
// shape: id 1, tag_name "v1.0.0", name "v1.0.0", body "release notes"
// (the suite asserts the parsed TagName).
ByTagResponse string
// UpdateResponse is the JSON object for PATCH/PUT release updates (same
// shape as ByTagResponse).
UpdateResponse string
// UpdateSendsDescriptionOnly declares that the platform's update
// endpoint cannot carry a release name (TencentCode's update surface
// only accepts a description): the update wire subtest then asserts the
// "description" key instead of "name".
UpdateSendsDescriptionOnly bool
// TagsListResponse is the JSON array for the tags-list GET
// (provider.ReleaseManager.ListTags). Empty = the harness has not wired
// the tags endpoint yet: the ListTags subtest skips, the rest of the
// suite is unaffected.
TagsListResponse string
}
ReleasesHarnessConfig carries the fixtures a backend's main Harness needs to auto-mount the release-management suite via Harness.Releases.
Unlike Labels/Issues/Reviews, ReleaseManager is a core interface composed into provider.Provider and implemented by every backend, so there is no capability-declaration drift to enforce: the config is mandatory for all seven platforms and testReleaseSuite fails the run when it is missing.
type RepoStatsHarness ¶
type RepoStatsHarness struct {
Name string
Platform provider.Platform
NewProvider func(t *testing.T, cfg provider.Config) provider.Provider
ForksResponse string
StargazersResponse string
ContributorsResponse string
}
RepoStatsHarness bundles inputs for the repo-stats suite.
type RepoStatsHarnessConfig ¶
type RepoStatsHarnessConfig struct {
ForksResponse string
StargazersResponse string
ContributorsResponse string
}
RepoStatsHarnessConfig carries fixtures for the repo-stats suite.
type RepoTemplatesHarnessConfig ¶ added in v0.112.0
type RepoTemplatesHarnessConfig struct {
GenerateResponse string
}
RepoTemplatesHarnessConfig mounts the template-repo suite. The suite drives CreateRepoFromTemplate against a recording server and asserts the response converts to a PlatformRepo with a non-empty Name.
GenerateResponse is the platform-shaped JSON body served on the generate endpoint (POST /repos/{o}/{r}/generate). It must decode into a repository object with a non-empty Name under the backend's converter.
type ReviewsHarness ¶
type ReviewsHarness struct {
Name string
Platform provider.Platform
NewProvider func(t *testing.T, cfg provider.Config) provider.Provider
ReviewsHarnessConfig
// IgnoresRequestReviewers declares that the backend's RequestReviewers is
// a registered ignore: the platform's reviewer API needs inputs the SDK
// surface cannot supply (GitLab's reviewer_ids want user IDs, but the SDK
// addresses reviewers by username and exposes no Users API to resolve
// them), so the method documents the ignore and performs no request. The
// wire subtest then only asserts a silent, error-free no-op — anything
// reaching the network would mean the registration drifted.
IgnoresRequestReviewers bool
// IgnoresDismissal declares that the backend's DismissReview is a
// registered stub: the platform's review surface has no dismissal
// endpoint at all (Tencent 工蜂 review notes expose no dismiss verb), so
// the method documents the gap and returns a provider error wrapping
// provider.ErrNotImplemented without touching the wire. The subtest then
// asserts exactly that registration — a successful call or any recorded
// request would mean the stub drifted.
IgnoresDismissal bool
// ListStateIsCommented declares that the backend's review reads carry no
// verdict state: the SDK model behind ListReviews/GetReview has no state
// field (Tencent 工蜂 review notes — the verdict travels only on the
// create/update writes as reviewer_state and never comes back), so every
// read review normalizes to provider.ReviewStateCommented, a registered
// limitation. The List subtest then asserts that commented normalization
// instead of the default approved one.
ListStateIsCommented bool
}
ReviewsHarness is the full harness RunReviewsSuite consumes; auto-mounting builds it from the enclosing Harness plus ReviewsHarnessConfig.
type ReviewsHarnessConfig ¶
type ReviewsHarnessConfig struct {
// ListResponse is the JSON array for review-list GETs. First item: id 1,
// user login "dev", state "APPROVED" (the suite asserts normalization to
// provider.ReviewStateApproved).
ListResponse string
// GetResponse is the JSON object for single-review GETs (id 1, user
// "dev", state "APPROVED").
GetResponse string
// MutateResponse is the JSON object for POST/PUT/PATCH (same shape as
// GetResponse).
MutateResponse string
// CreateEvent is the wire value the platform's create must carry under
// the "event" key for the suite's APPROVE-verdict create. The suite
// calls CreateReview with Event "APPROVE": GitHub and GitCode forward
// the option verbatim ("APPROVE"), Gitea/Forgejo translate it to their
// SDK's review state ("APPROVED"). Empty means the platform's create
// carries no verdict on the wire (GitLab's note-based create) and the
// event-key assertion is skipped — the body assertion still runs.
CreateEvent string
// IgnoresRequestReviewers opts the backend out of the RequestReviewers
// wire assertion (see ReviewsHarness.IgnoresRequestReviewers).
IgnoresRequestReviewers bool
// RequestReviewersByID declares that the backend resolves reviewer
// usernames to numeric user IDs through a /users lookup before writing
// them (GitLab resolves usernames to IDs first): the wire subtest then
// asserts the lookup GET and an ID-carrying update body instead of the
// username-carrying create (see assertRequestReviewersByIDWire).
RequestReviewersByID bool
// IgnoresDismissal opts the backend out of the DismissReview verb
// assertion (see ReviewsHarness.IgnoresDismissal). It is for platforms
// whose ONLY dismissal gap is a registered stub: the platform exposes no
// dismiss surface at all, so DismissReview returns a wrapped
// provider.ErrNotImplemented and the subtest asserts that registration
// instead of a state-changing verb.
IgnoresDismissal bool
// ListStateIsCommented declares that the platform's review reads cannot
// carry a verdict state (see ReviewsHarness.ListStateIsCommented).
ListStateIsCommented bool
}
ReviewsHarnessConfig carries the fixtures a backend's main Harness needs to auto-mount the review-management suite via Harness.Reviews.
type SearchHarness ¶
type SearchHarness struct {
Name string
Platform provider.Platform
NewProvider func(t *testing.T, cfg provider.Config) provider.Provider
SearchHarnessConfig
}
SearchHarness is the full harness RunSearchSuite consumes; auto-mounting builds it from the enclosing Harness plus SearchHarnessConfig.
type SearchHarnessConfig ¶
type SearchHarnessConfig struct {
// ReposResponse is the JSON body for repository-search GETs, in the
// platform's wire shape (GitHub wraps items in {"total_count":..,
// "items":[..]}, Gitea/Forgejo in {"data":[..]}, the rest are bare
// arrays).
ReposResponse string
// ReposTotalCount is the server-side total the repos fixture reports
// (GitHub's envelope carries total_count; the suite then asserts
// SearchRepos returns exactly this total). Zero means the platform
// reports no server-side total — the backend returns nil for total and
// the suite keeps the weaker total == nil || *total >= len(results)
// assertion.
ReposTotalCount int
// IssuesResponse is the JSON body for issue-search GETs, same per-
// platform wrapping rules as ReposResponse.
IssuesResponse string
// UsersResponse is the JSON body for user-search GETs, same per-
// platform wrapping rules as ReposResponse.
UsersResponse string
}
SearchHarnessConfig carries the fixtures a backend's main Harness needs to auto-mount the search suite via Harness.Search. Every fixture's first item must render as: repos — full_name "owner/repo"; issues — number "1" (the platform's wire encoding of the identifier, parsed to the string "1"), title "found"; users — login "dev".
type StarredHarness ¶ added in v0.139.0
type StarredHarness struct {
Name string
Platform provider.Platform
NewProvider func(t *testing.T, cfg provider.Config) provider.Provider
WrappedResponse string
BareResponse string
}
StarredHarness bundles inputs for the starred-repo list suite.
type StarredHarnessConfig ¶ added in v0.139.0
type StarredHarnessConfig struct {
// WrappedResponse is the star+json envelope shape
// ([{"starred_at":…,"repo":{…}}]) GitHub serves when the request carries
// Accept: application/vnd.github.star+json — the shape ListStarred asks
// for. Its first element must map to a repo with non-empty full_name,
// owner, and description, and a non-zero stargazers_count.
WrappedResponse string
// BareResponse is the bare repository array shape ([{…}]) a server
// returns when it ignores the Accept header (proxy rewrites, GHES
// drift). ListStarred must fall back to it per element via
// decodeStarredEntry; same first-element requirements as
// WrappedResponse.
BareResponse string
}
StarredHarnessConfig carries fixtures for the starred-repo list suite.
type TeamReviewsHarness ¶ added in v0.139.0
type TeamReviewsHarness struct {
Name string
Platform provider.Platform
NewProvider func(t *testing.T, cfg provider.Config) provider.Provider
Teams []string
}
TeamReviewsHarness bundles inputs for the team-review suite.
type TeamReviewsHarnessConfig ¶ added in v0.139.0
type TeamReviewsHarnessConfig struct {
// Teams is the team-slug list the suite requests on the legal path; the
// wire body must carry every value. Key spelling differs per platform
// (site-verified 2C T4: go-github ReviewersRequest.TeamReviewers is
// `team_reviewers` with omitempty; gitea.dev/sdk and forgejo-sdk
// PullReviewRequestOptions always send BOTH `reviewers` and
// `team_reviewers`), so the suite's body assertion is a
// platform-agnostic value check — some JSON array in the body must carry
// every fixture team as an element — never a key-name pin.
Teams []string
}
TeamReviewsHarnessConfig carries fixtures for the team-review suite.
type UsersHarness ¶
type UsersHarness struct {
Name string
Platform provider.Platform
NewProvider func(t *testing.T, cfg provider.Config) provider.Provider
GetUserResponse string
}
UsersHarness bundles inputs for the user-manager suite.
type UsersHarnessConfig ¶
type UsersHarnessConfig struct {
// GetUserResponse is the JSON the mock returns for user lookup.
GetUserResponse string
}
UsersHarnessConfig carries fixtures for the user-manager suite.
type WebhookConfigHarness ¶ added in v0.99.9
type WebhookConfigHarness struct {
Name string
Platform provider.Platform
NewProvider func(t *testing.T, cfg provider.Config) provider.Provider
GetResponse string
}
WebhookConfigHarness bundles inputs for the webhook-config suite.
type WebhookConfigHarnessConfig ¶ added in v0.99.9
type WebhookConfigHarnessConfig struct {
// GetResponse is one webhook in the platform's native wire shape. It is
// served for both the GET (get + family read-back) and the update call,
// so converters must be able to decode it — e.g. GitHub/GitCode
// `{"id":42,"url":"…","events":["push"]}`, GitLab/Gitee/TencentCode
// boolean-flag bodies, Gitea-family `{"id":42,"config":{"url":"…"}, …}`.
GetResponse string
}
WebhookConfigHarnessConfig carries fixtures for the webhook-config suite (single-webhook get/update on top of the core WebhookManager).
type WebhookParser ¶ added in v0.72.0
type WebhookParser interface {
ParseWebhookEvent(r *http.Request, secret string) (*provider.NormalizedEvent, error)
}
WebhookParser is the surface RunWebhookCorpus exercises. Every backend's Provider implements it via WebhookManager; the narrow interface keeps the driver usable with zero-value backend structs (the parse path only needs Platform()).
Source Files
¶
- branch_protections.go
- capabilities.go
- cilogs.go
- collaborators.go
- commitstatus.go
- contracttest.go
- crs.go
- deploy_keys.go
- deployments.go
- divergence.go
- ensureissue.go
- errorclass.go
- families_contract.go
- forksync.go
- gists.go
- issues.go
- labels.go
- migrations.go
- milestones.go
- notes.go
- notifications.go
- operation.go
- pagination_contract.go
- reactions.go
- releaseassets.go
- releases.go
- repo_stats.go
- repo_templates.go
- reviews.go
- search.go
- starred.go
- teamreviews.go
- tokensource.go
- users.go
- webhookconfig.go
- webhookcorpus.go