zappr

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrZapprUnauthorized is used when we receive a 401 from Zappr
	ErrZapprUnauthorized = errors.New("you do not have permissions to use zappr api")

	// ErrZapprAlreadyEnabled is used when "Enable" is called for a repo that Zappr is already enabled for
	ErrZapprAlreadyEnabled = errors.New("zappr already enabled for the repo")

	// ErrZapprAlreadyNotEnabled is used when "Disable" is called for a repo that Zappr is already NOT enabled for
	ErrZapprAlreadyNotEnabled = errors.New("zappr is already not enabled for the repo")

	// ErrZapprServerError is used when we receive a code different than 200 from Zappr
	ErrZapprServerError = errors.New("unknown error from zappr")
)

Functions

This section is empty.

Types

type Client

type Client interface {
	Enable(repoID int) error
	Disable(repoID int) error
	ImpersonateGitHubApp() error // Retrieves the Github token representing Zappr and uses that for future requests
}

Client represents a zappr client

func New added in v0.0.15

func New(zapprURL string, githubToken string, httpClient *http.Client) Client

New creates a new Zappr client that uses Github Token to make calls to Zappr

func NewMockAndHandler

func NewMockAndHandler() (Client, *test.MockHandler, *test.Server)

NewMockAndHandler returns a Zappr Client that uses Github Token, Mockhandler, and Server. The client proxies requests to the server and handlers can be registered on the mux to handle requests. The caller must close the test server.

func NewMockAndHandlerNilResponse

func NewMockAndHandlerNilResponse() (Client, *test.MockHandler, *test.Server)

NewMockAndHandlerNilResponse returns a Zappr Client that uses Github Token, Mockhandler, and Server. The internal http client always returns a nil response object.

func NewMockAndHandlerWithGithubToken

func NewMockAndHandlerWithGithubToken(githubToken string) (Client, *test.MockHandler, *test.Server)

NewMockAndHandlerWithGithubToken returns a Zappr Client that uses Github Token, Mockhandler, and Server. The client proxies requests to the server and handlers can be registered on the mux to handle requests. The caller must close the test server.

type NilResponseTransport

type NilResponseTransport struct {
	Transport http.RoundTripper
}

NilResponseTransport always returns a nil response object

func (*NilResponseTransport) RoundTrip

func (t *NilResponseTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip rewrites the request scheme to http and calls through to the composed RoundTripper or if it is nil, to the http.DefaultTransport.

type RewriteTransport

type RewriteTransport struct {
	Transport http.RoundTripper
}

RewriteTransport rewrites https requests to http to avoid TLS cert issues during testing.

func (*RewriteTransport) RoundTrip

func (t *RewriteTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip rewrites the request scheme to http and calls through to the composed RoundTripper or if it is nil, to the http.DefaultTransport.

Jump to

Keyboard shortcuts

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