github

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package github is a generated GoMock package.

Package github is a generated GoMock package.

Index

Constants

View Source
const (

	// ValidFilePathRegex validates the file path of the files stored/retrieved to/from github.
	// We only allow markdown files with or without parent directories.
	ValidFilePathRegex = `(?m)^([a-zA-Z0-9-]([/][a-zA-Z0-9-])?[^\S\r\n]?[a-zA-Z0-9-]?)+(\.md)$`
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientBuilder

type ClientBuilder interface {
	Build(ctx context.Context, token *oauth2.Token) *github.Client
	GetOAuth2Config() *oauth2.Config
}

ClientBuilder represents an oauth2 github client builder. It provides methods to build the github oauth2 client.

func NewClientBuilder

func NewClientBuilder(oauth2Config *oauth2.Config) ClientBuilder

NewClientBuilder creates and returns a new oauth2 client builder containing oauth2 config.

type GitFile

type GitFile struct {
	SHA     string // this is a blob sha (not commit sha)
	Path    string
	Content string
	Size    int
	IsDir   bool
}

GitFile used to provide response to file request

type GitFileProps

type GitFileProps struct {
	SHA         string // this is a blob sha (not commit sha)
	Path        string
	Content     string
	AuthorName  string
	AuthorEmail string
	RepoDetails GitRepoProps
}

GitFileProps used to provide request details to github client

type GitRepo

type GitRepo struct {
	Name          string
	Visibility    string
	DefaultBranch string
}

GitRepo used to provide response to repos request

type GitRepoProps

type GitRepoProps struct {
	Repository    string
	DefaultBranch string
	Owner         string
}

GitRepoProps used to provide repo details to github client

type MockClientBuilder

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

MockClientBuilder is a mock of ClientBuilder interface.

func NewMockClientBuilder

func NewMockClientBuilder(ctrl *gomock.Controller) *MockClientBuilder

NewMockClientBuilder creates a new mock instance.

func (*MockClientBuilder) Build

func (m *MockClientBuilder) Build(ctx context.Context, token *oauth2.Token) *github.Client

Build mocks base method.

func (*MockClientBuilder) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockClientBuilder) GetOAuth2Config

func (m *MockClientBuilder) GetOAuth2Config() *oauth2.Config

GetOAuth2Config mocks base method.

type MockClientBuilderMockRecorder

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

MockClientBuilderMockRecorder is the mock recorder for MockClientBuilder.

func (*MockClientBuilderMockRecorder) Build

func (mr *MockClientBuilderMockRecorder) Build(ctx, token interface{}) *gomock.Call

Build indicates an expected call of Build.

func (*MockClientBuilderMockRecorder) GetOAuth2Config

func (mr *MockClientBuilderMockRecorder) GetOAuth2Config() *gomock.Call

GetOAuth2Config indicates an expected call of GetOAuth2Config.

type MockService

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

MockService is a mock of Service interface.

func NewMockService

func NewMockService(ctrl *gomock.Controller) *MockService

NewMockService creates a new mock instance.

func (*MockService) CreateRepo

func (m *MockService) CreateRepo(ctx context.Context, ghToken oauth2.Token, repoName string) (GitRepo, error)

CreateRepo mocks base method.

func (*MockService) DeleteFile

func (m *MockService) DeleteFile(ctx context.Context, ghToken oauth2.Token, fileProps GitFileProps) error

DeleteFile mocks base method.

func (*MockService) EXPECT

func (m *MockService) EXPECT() *MockServiceMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockService) GetAllFiles

func (m *MockService) GetAllFiles(ctx context.Context, ghToken oauth2.Token, fileProps GitFileProps) ([]GitFile, error)

GetAllFiles mocks base method.

func (*MockService) GetAuthCodeURL

func (m *MockService) GetAuthCodeURL(state string) string

GetAuthCodeURL mocks base method.

func (*MockService) GetFile

func (m *MockService) GetFile(ctx context.Context, ghToken oauth2.Token, fileProps GitFileProps) (GitFile, error)

GetFile mocks base method.

func (*MockService) GetRepos

func (m *MockService) GetRepos(ctx context.Context, ghToken oauth2.Token) ([]GitRepo, error)

GetRepos mocks base method.

func (*MockService) GetToken

func (m *MockService) GetToken(ctx context.Context, code string) (oauth2.Token, error)

GetToken mocks base method.

func (*MockService) GetTree

func (m *MockService) GetTree(ctx context.Context, ghToken oauth2.Token, fileProps GitFileProps) ([]GitFile, error)

GetTree mocks base method.

func (*MockService) GetUser

func (m *MockService) GetUser(ctx context.Context, ghToken oauth2.Token) (github.User, error)

GetUser mocks base method.

func (*MockService) SaveFile

func (m *MockService) SaveFile(ctx context.Context, ghToken oauth2.Token, fileProps GitFileProps) (GitFile, error)

SaveFile mocks base method.

func (*MockService) SearchFiles

func (m *MockService) SearchFiles(ctx context.Context, ghToken oauth2.Token, fileProps GitFileProps, query string, pageNo int) ([]GitFile, int, error)

SearchFiles mocks base method.

type MockServiceMockRecorder

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

MockServiceMockRecorder is the mock recorder for MockService.

func (*MockServiceMockRecorder) CreateRepo

func (mr *MockServiceMockRecorder) CreateRepo(ctx, ghToken, repoName interface{}) *gomock.Call

CreateRepo indicates an expected call of CreateRepo.

func (*MockServiceMockRecorder) DeleteFile

func (mr *MockServiceMockRecorder) DeleteFile(ctx, ghToken, fileProps interface{}) *gomock.Call

DeleteFile indicates an expected call of DeleteFile.

func (*MockServiceMockRecorder) GetAllFiles

func (mr *MockServiceMockRecorder) GetAllFiles(ctx, ghToken, fileProps interface{}) *gomock.Call

GetAllFiles indicates an expected call of GetAllFiles.

func (*MockServiceMockRecorder) GetAuthCodeURL

func (mr *MockServiceMockRecorder) GetAuthCodeURL(state interface{}) *gomock.Call

GetAuthCodeURL indicates an expected call of GetAuthCodeURL.

func (*MockServiceMockRecorder) GetFile

func (mr *MockServiceMockRecorder) GetFile(ctx, ghToken, fileProps interface{}) *gomock.Call

GetFile indicates an expected call of GetFile.

func (*MockServiceMockRecorder) GetRepos

func (mr *MockServiceMockRecorder) GetRepos(ctx, ghToken interface{}) *gomock.Call

GetRepos indicates an expected call of GetRepos.

func (*MockServiceMockRecorder) GetToken

func (mr *MockServiceMockRecorder) GetToken(ctx, code interface{}) *gomock.Call

GetToken indicates an expected call of GetToken.

func (*MockServiceMockRecorder) GetTree

func (mr *MockServiceMockRecorder) GetTree(ctx, ghToken, fileProps interface{}) *gomock.Call

GetTree indicates an expected call of GetTree.

func (*MockServiceMockRecorder) GetUser

func (mr *MockServiceMockRecorder) GetUser(ctx, ghToken interface{}) *gomock.Call

GetUser indicates an expected call of GetUser.

func (*MockServiceMockRecorder) SaveFile

func (mr *MockServiceMockRecorder) SaveFile(ctx, ghToken, fileProps interface{}) *gomock.Call

SaveFile indicates an expected call of SaveFile.

func (*MockServiceMockRecorder) SearchFiles

func (mr *MockServiceMockRecorder) SearchFiles(ctx, ghToken, fileProps, query, pageNo interface{}) *gomock.Call

SearchFiles indicates an expected call of SearchFiles.

type Service

type Service interface {
	GetAuthCodeURL(state string) string
	GetToken(ctx context.Context, code string) (oauth2.Token, error)
	GetUser(ctx context.Context, ghToken oauth2.Token) (github.User, error)

	GetRepos(ctx context.Context, ghToken oauth2.Token) ([]GitRepo, error)
	CreateRepo(ctx context.Context, ghToken oauth2.Token, repoName string) (GitRepo, error)
	SearchFiles(ctx context.Context, ghToken oauth2.Token, fileProps GitFileProps, query string, pageNo int) ([]GitFile, int, error)
	GetTree(ctx context.Context, ghToken oauth2.Token, fileProps GitFileProps) ([]GitFile, error)
	GetAllFiles(ctx context.Context, ghToken oauth2.Token, fileProps GitFileProps) ([]GitFile, error)
	GetFile(ctx context.Context, ghToken oauth2.Token, fileProps GitFileProps) (GitFile, error)
	SaveFile(ctx context.Context, ghToken oauth2.Token, fileProps GitFileProps) (GitFile, error)
	DeleteFile(ctx context.Context, ghToken oauth2.Token, fileProps GitFileProps) error
}

Service represents a github service. It provides methods to manage github resources using oauth2 api.

func NewService

func NewService(clientBuilder ClientBuilder) Service

NewService creates and returns new github service with client builder.

Jump to

Keyboard shortcuts

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