testserver

package
v0.5.18 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: MPL-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PushEvent   GithubEvent = "push"
	PullRequest GithubEvent = "pull_request"

	WebhookCreated webhookAction = iota
	WebhookUpdated
	WebhookDeleted
)

Variables

This section is empty.

Functions

func SendEventRequest

func SendEventRequest(t *testing.T, event GithubEvent, url, secret string, payload []byte)

SendEventRequest sends a GitHub event via a http request to the url, signed with the secret,

Types

type GithubEvent

type GithubEvent string

The name of the event sent in the X-Github-Event header

type Hook

type Hook struct {
	*github.Hook
	// contains filtered or unexported fields
}

type TestServer

type TestServer struct {

	// webhook created/updated/deleted events channel
	WebhookEvents chan webhookEvent

	*httptest.Server
	// contains filtered or unexported fields
}

func NewTestServer

func NewTestServer(t *testing.T, opts ...TestServerOption) (*TestServer, *url.URL)

func (*TestServer) GetStatus

func (s *TestServer) GetStatus(t *testing.T, ctx context.Context) *github.StatusEvent

GetStatus retrieves a commit status event off the queue, timing out after 10 seconds if nothing is on the queue.

func (*TestServer) HasWebhook

func (s *TestServer) HasWebhook() bool

func (*TestServer) SendEvent

func (s *TestServer) SendEvent(t *testing.T, event GithubEvent, payload []byte)

SendEvent sends an event to the registered webhook.

type TestServerOption

type TestServerOption func(*TestServer)

func WithArchive

func WithArchive(tarball []byte) TestServerOption

func WithCommit

func WithCommit(commit string) TestServerOption

func WithDefaultBranch

func WithDefaultBranch(branch string) TestServerOption

func WithDisableTLS

func WithDisableTLS() TestServerOption

func WithHandler

func WithHandler(path string, h http.HandlerFunc) TestServerOption

func WithHook

func WithHook(hook Hook) TestServerOption

func WithPullRequest

func WithPullRequest(pullNumber string, changedPaths ...string) TestServerOption

func WithRefs

func WithRefs(refs ...string) TestServerOption

func WithRepo

func WithRepo(repo vcs.Repo) TestServerOption

func WithUsername

func WithUsername(username user.Username) TestServerOption

Jump to

Keyboard shortcuts

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