pullrequest

package
v0.38.2 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

README

PullRequest Resource E2E Tests

This directory contains E2E tests for the Pull Request resource. The E2E test can run in a variety of modes, talking to both fake and real SCM providers.

Fake SCM

In the Fake SCM mode, all requests are redirected to a local HTTP server that intercepts the request and feeds back fake data. testdata/scm contains this data, which was derived from making actual requests to the GitHub API. This data should be kept as close as possible to the upstream API response.

The fake server can be configured to look for authentication tokens in the request. By default if a token is not provided via an environment variable, one will be set arbitrarily. Providing a valid token is not required for the Fake SCM mode.

In order for the fake SCM proxy to successfully intercept requests, URLs must use http.

Real SCM

$ go test . -proxy false

In the Real SCM mode, the E2E test will communicate with real SCM providers. In order to support uploads, a valid authentication token must be provided.

The test will first look for an SCM-specific auth code, or default back to the standard AUTH_TOKEN environment variable if one is not present. Currently the valid SCM-specific auth codes are:

  • GITHUB_TOKEN

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToDisk

func ToDisk(r *Resource, path string) error

ToDisk converts a PullRequest object to an on-disk representation at the specified path. When written, the underlying Manifests

Types

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler handles interactions with the GitHub API.

func NewHandler

func NewHandler(logger *zap.SugaredLogger, client *scm.Client, repo string, pr int) *Handler

NewHandler initializes a new handler for interacting with SCM resources.

func NewSCMHandler

func NewSCMHandler(logger *zap.SugaredLogger, raw, provider, token string, skipTLSVerify bool) (*Handler, error)

NewSCMHandler returns a new Handler for the given URL, provider and token

func (*Handler) Download

func (h *Handler) Download(ctx context.Context) (*Resource, error)

Download fetches and stores the desired pull request.

func (*Handler) Upload

func (h *Handler) Upload(ctx context.Context, r *Resource) error

Upload takes files stored on the filesystem and uploads new changes to GitHub.

type Manifest

type Manifest map[string]bool

Manifest is a list of sub-resources that exist within the PR resource to determine whether an item existed when the resource was initialized.

type Resource

type Resource struct {
	PR       *scm.PullRequest
	Statuses []*scm.Status
	Comments []*scm.Comment

	// Manifests contain data about the resource when it was written to disk.
	Manifests map[string]Manifest
}

Resource represents a complete SCM resource that should be recorded to disk.

func FromDisk

func FromDisk(path string, disableJSONComments bool) (*Resource, error)

FromDisk outputs a PullRequest object from an on-disk representation at the specified path.

Jump to

Keyboard shortcuts

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