testclient

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package testclient implements the used interfaces of github API client library and simulates the API answers for our tests

Index

Constants

This section is empty.

Variables

View Source
var ReturnValue = ReturnValueStr{} // nolint: gochecknoglobals

ReturnValue controls the error return values of API calls for testclient instances created by New

Functions

func New

func New(_ context.Context, _ string) *client.Client

New returns the configured simulated github API client

Types

type IssueService

type IssueService struct {
	Issues      []*github.Issue
	ReturnValue ReturnValueStr
}

IssueService simulates the github.IssuesService

func (*IssueService) ListByRepo

func (g *IssueService) ListByRepo(
	ctx context.Context,
	owner string, repo string,
	opt *github.IssueListByRepoOptions,
) ([]*github.Issue, *github.Response, error)

ListByRepo simulates the (github.IssuesService) ListByRepo call

type PullRequestsService

type PullRequestsService struct {
	PRs         []*github.PullRequest
	ReturnValue ReturnValueStr
}

PullRequestsService simulates the github.PullRequestsService

func (*PullRequestsService) List

List simulates the (github.PullRequestsService) ListByRepo call

type RepoService

type RepoService struct {
	RepositoryTags     []*github.RepositoryTag
	RepositoryCommits  map[string]*github.RepositoryCommit
	RepositoryReleases map[string]*github.RepositoryRelease
	ReturnValue        ReturnValueStr
}

RepoService simulates the github.RepositoriesService

func (*RepoService) Get

func (g *RepoService) Get(
	ctx context.Context,
	owner, repo string) (*github.Repository, *github.Response, error)

Get simulates the (github.RepositoriesService) Get call

func (*RepoService) GetCommit

func (g *RepoService) GetCommit(
	ctx context.Context,
	owner, repo, sha string,
) (*github.RepositoryCommit, *github.Response, error)

GetCommit simulates the (github.RepositoriesService) GetCommit call

func (*RepoService) GetReleaseByTag

func (g *RepoService) GetReleaseByTag(
	ctx context.Context,
	owner, repo, tag string,
) (*github.RepositoryRelease, *github.Response, error)

GetReleaseByTag simulates the (github.RepositoriesService) GetCommit call

func (*RepoService) ListTags

func (g *RepoService) ListTags(
	ctx context.Context,
	owner, repo string,
	opt *github.ListOptions,
) ([]*github.RepositoryTag, *github.Response, error)

ListTags simulates the (github.RepositoriesService) ListTags call

type ReturnValueStr

type ReturnValueStr struct {
	RepoServiceListTagsErr    bool
	RepoServiceGetCommitsErr  bool
	IssueServiceListByRepoErr bool
	PullRequestsListErr       bool
	RepoServiceGetErr         bool
	RepoServiceGetRespCode    int
}

ReturnValueStr represents the possible error controlling of API calls for testing if a field is set to true - return error, otherwise not

Jump to

Keyboard shortcuts

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