mirror of
https://github.com/github/gh-stack.git
synced 2026-09-14 20:26:28 +08:00
c2ddf60fb1
Introduce Ops interface and MockOps for git operations, and ClientOps interface with MockClient for GitHub API operations. This enables command-level tests to inject mocks without changing production code. - git.Ops interface wraps all 34 public git functions - Package-level functions now delegate through a swappable ops variable - SetOps()/CurrentOps() allow tests to inject MockOps - github.ClientOps interface covers all Client methods - MockClient provides configurable function-field test doubles - All defaults return zero values; no-op for error returns Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
17 lines
597 B
Go
17 lines
597 B
Go
package github
|
|
|
|
// ClientOps defines the interface for GitHub API operations.
|
|
// The concrete Client type satisfies this interface.
|
|
// Tests can substitute a MockClient.
|
|
type ClientOps interface {
|
|
FindPRForBranch(branch string) (*PullRequest, error)
|
|
FindAnyPRForBranch(branch string) (*PullRequest, error)
|
|
FindPRDetailsForBranch(branch string) (*PRDetails, error)
|
|
CreatePR(base, head, title, body string, draft bool) (*PullRequest, error)
|
|
UpdatePRBase(prID, newBase string) error
|
|
DeleteStack() error
|
|
}
|
|
|
|
// Compile-time check that Client satisfies ClientOps.
|
|
var _ ClientOps = (*Client)(nil)
|