test

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountByMethodAndURLRegexp

func CountByMethodAndURLRegexp(method string, urlRE *regexp.Regexp) int

CountByMethodAndURLRegexp adds up call counts for a given METHOD whose stored httpmock key's URL matches urlRE.

func DumpHttpmockCalls

func DumpHttpmockCalls(t testing.TB)

DumpHttpmockCalls logs all recorded httpmock keys and counts. Used for debugging while writing tests.

func EnvOwnerRepo

func EnvOwnerRepo(t testing.TB) (string, string)

EnvOwnerRepo returns config repo owner/name from env and fails the test if either is missing.

func GetRefGetCount

func GetRefGetCount(owner, repo, branch string) int

GetRefGetCount counts GET calls to /git/ref/(refs/)?heads/<branch> for the given owner/repo/branch.

func MakeChanged

func MakeChanged(status, path string) types.ChangedFile

MakeChanged is a shorthand to build ChangedFile entries.

func MockContentsEndpoint

func MockContentsEndpoint(owner, repo, path, contentB64 string)

MockContentsEndpoint mocks GET file contents for a given path/ref.

func MockCreateRef

func MockCreateRef(owner, repo string) string

MockCreateRef mocks POST to create a new temp branch ref. Returns the exact URL for call-count asserts.

func MockDeleteTempRef

func MockDeleteTempRef(owner, repo string)

MockDeleteTempRef mocks DELETE to remove a temporary branch ref.

func MockGetCommit

func MockGetCommit(owner, repo, commitSHA, baseTreeSHA string)

MockGetCommit mocks GET /repos/{owner}/{repo}/git/commits/{sha} for tree comparison. baseTreeSHA is the tree SHA of the base commit; use a value different from the new tree to allow commits, or the same value to simulate a no-op.

func MockGitHubAppInstallations

func MockGitHubAppInstallations(orgToInstallationID map[string]string)

MockGitHubAppInstallations mocks the GitHub App installations list endpoint.

func MockGitHubAppTokenEndpoint

func MockGitHubAppTokenEndpoint(installationID string)

MockGitHubAppTokenEndpoint mocks the GitHub App installation token endpoint with a fixed fake token.

func MockGitHubWriteEndpoints

func MockGitHubWriteEndpoints(owner, repo, branch string) (baseRefURL, commitsURL, updateRefURL string)

MockGitHubWriteEndpoints mocks the full direct-commit flow endpoints for a single branch. Returns the URLs for the base ref, commits, and update ref endpoints. The base commit's tree SHA is "oldTreeSha" (different from the new tree "newTreeSha"), so commits will proceed normally. Use MockGitHubWriteEndpointsNoOp to simulate no changes.

func MockGitHubWriteEndpointsNoOp

func MockGitHubWriteEndpointsNoOp(owner, repo, branch string) (baseRefURL, commitsURL, updateRefURL string)

MockGitHubWriteEndpointsNoOp is like MockGitHubWriteEndpoints but the new tree SHA equals the base commit's tree SHA, simulating a no-op (duplicate) commit.

func MockListOpenPRs

func MockListOpenPRs(owner, repo string, prs []map[string]any)

MockListOpenPRs mocks the "list open PRs" endpoint, returning the supplied PRs. Pass nil or empty to simulate no existing open PRs.

func MockPullsAndMerge

func MockPullsAndMerge(owner, repo string, number int)

MockPullsAndMerge mocks creating and merging a PR.

func NormalizeUpload

func NormalizeUpload(in map[types.UploadKey]types.UploadFileContent) map[types.UploadKey][]string

NormalizeUpload flattens a FilesToUpload map to UploadKey -> []names for simpler comparisons.

func SetupOrgToken

func SetupOrgToken(org, token string)

SetupOrgToken sets up a cached installation token for an organization. This bypasses the need to mock the installations and token endpoints.

func TestConfig

func TestConfig() *configs.Config

TestConfig returns a *configs.Config populated from the current environment variables. This mirrors the values set in TestMain for test suites.

func WithHTTPMock

func WithHTTPMock(t testing.TB) *http.Client

WithHTTPMock wraps a test in `httpmock` activation on a dedicated http.Client and routes the TokenManager's HTTP client through it.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL