Documentation
¶
Index ¶
- Variables
- type Account
- type AccountType
- type Client
- type ClientMock
- func (mock *ClientMock) CreateRepo(owner string, name string, access Visibility) (*Repository, error)
- func (mock *ClientMock) CreateRepoCalls() []struct{ ... }
- func (mock *ClientMock) CurrentRemote() (*Repository, error)
- func (mock *ClientMock) CurrentRemoteCalls() []struct{}
- func (mock *ClientMock) CurrentUser() (*User, error)
- func (mock *ClientMock) CurrentUserCalls() []struct{}
- func (mock *ClientMock) GetAccount(name string) (*Account, error)
- func (mock *ClientMock) GetAccountCalls() []struct{ ... }
- func (mock *ClientMock) GetRepo(name string) (*Repository, error)
- func (mock *ClientMock) GetRepoCalls() []struct{ ... }
- type ExecFunc
- type Protocol
- type RESTClient
- type RESTClientMock
- func (mock *RESTClientMock) Delete(path string, response interface{}) error
- func (mock *RESTClientMock) DeleteCalls() []struct{ ... }
- func (mock *RESTClientMock) Get(path string, response interface{}) error
- func (mock *RESTClientMock) GetCalls() []struct{ ... }
- func (mock *RESTClientMock) Patch(path string, body io.Reader, response interface{}) error
- func (mock *RESTClientMock) PatchCalls() []struct{ ... }
- func (mock *RESTClientMock) Post(path string, body io.Reader, response interface{}) error
- func (mock *RESTClientMock) PostCalls() []struct{ ... }
- func (mock *RESTClientMock) Put(path string, body io.Reader, response interface{}) error
- func (mock *RESTClientMock) PutCalls() []struct{ ... }
- type Repository
- type RepositoryRequest
- type SystemClient
- func (c *SystemClient) CreateRepo(owner string, name string, vis Visibility) (*Repository, error)
- func (c *SystemClient) CurrentRemote() (*Repository, error)
- func (c *SystemClient) CurrentUser() (*User, error)
- func (c *SystemClient) GetAccount(name string) (*Account, error)
- func (c *SystemClient) GetRepo(name string) (*Repository, error)
- type User
- type Visibility
Constants ¶
This section is empty.
Variables ¶
var (
ErrInvalidVisibility = errors.New("invalid visibility")
)
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { // Account id ID int // Account handle (some_user). Login string // Account name (Some User). Name string // Account type (Organization or User). Type AccountType }
Account is a GitHub account.
type AccountType ¶
type AccountType string
const ( AccountTypeOrg AccountType = "Organization" AccountTypeUser AccountType = "User" )
type Client ¶
type Client interface { CurrentUser() (*User, error) CurrentRemote() (*Repository, error) CreateRepo(owner string, name string, access Visibility) (*Repository, error) GetAccount(name string) (*Account, error) GetRepo(name string) (*Repository, error) }
type ClientMock ¶
type ClientMock struct { // CreateRepoFunc mocks the CreateRepo method. CreateRepoFunc func(owner string, name string, access Visibility) (*Repository, error) // CurrentRemoteFunc mocks the CurrentRemote method. CurrentRemoteFunc func() (*Repository, error) // CurrentUserFunc mocks the CurrentUser method. CurrentUserFunc func() (*User, error) // GetAccountFunc mocks the GetAccount method. GetAccountFunc func(name string) (*Account, error) // GetRepoFunc mocks the GetRepo method. GetRepoFunc func(name string) (*Repository, error) // contains filtered or unexported fields }
ClientMock is a mock implementation of Client.
func TestSomethingThatUsesClient(t *testing.T) { // make and configure a mocked Client mockedClient := &ClientMock{ CreateRepoFunc: func(owner string, name string, access Visibility) (*Repository, error) { panic("mock out the CreateRepo method") }, CurrentRemoteFunc: func() (*Repository, error) { panic("mock out the CurrentRemote method") }, CurrentUserFunc: func() (*User, error) { panic("mock out the CurrentUser method") }, GetAccountFunc: func(name string) (*Account, error) { panic("mock out the GetAccount method") }, GetRepoFunc: func(name string) (*Repository, error) { panic("mock out the GetRepo method") }, } // use mockedClient in code that requires Client // and then make assertions. }
func (*ClientMock) CreateRepo ¶
func (mock *ClientMock) CreateRepo(owner string, name string, access Visibility) (*Repository, error)
CreateRepo calls CreateRepoFunc.
func (*ClientMock) CreateRepoCalls ¶
func (mock *ClientMock) CreateRepoCalls() []struct { Owner string Name string Access Visibility }
CreateRepoCalls gets all the calls that were made to CreateRepo. Check the length with:
len(mockedClient.CreateRepoCalls())
func (*ClientMock) CurrentRemote ¶
func (mock *ClientMock) CurrentRemote() (*Repository, error)
CurrentRemote calls CurrentRemoteFunc.
func (*ClientMock) CurrentRemoteCalls ¶
func (mock *ClientMock) CurrentRemoteCalls() []struct { }
CurrentRemoteCalls gets all the calls that were made to CurrentRemote. Check the length with:
len(mockedClient.CurrentRemoteCalls())
func (*ClientMock) CurrentUser ¶
func (mock *ClientMock) CurrentUser() (*User, error)
CurrentUser calls CurrentUserFunc.
func (*ClientMock) CurrentUserCalls ¶
func (mock *ClientMock) CurrentUserCalls() []struct { }
CurrentUserCalls gets all the calls that were made to CurrentUser. Check the length with:
len(mockedClient.CurrentUserCalls())
func (*ClientMock) GetAccount ¶
func (mock *ClientMock) GetAccount(name string) (*Account, error)
GetAccount calls GetAccountFunc.
func (*ClientMock) GetAccountCalls ¶
func (mock *ClientMock) GetAccountCalls() []struct { Name string }
GetAccountCalls gets all the calls that were made to GetAccount. Check the length with:
len(mockedClient.GetAccountCalls())
func (*ClientMock) GetRepo ¶
func (mock *ClientMock) GetRepo(name string) (*Repository, error)
GetRepo calls GetRepoFunc.
func (*ClientMock) GetRepoCalls ¶
func (mock *ClientMock) GetRepoCalls() []struct { Name string }
GetRepoCalls gets all the calls that were made to GetRepo. Check the length with:
len(mockedClient.GetRepoCalls())
type RESTClient ¶
type RESTClient interface { Delete(path string, response interface{}) error Get(path string, response interface{}) error Patch(path string, body io.Reader, response interface{}) error Post(path string, body io.Reader, response interface{}) error Put(path string, body io.Reader, response interface{}) error }
func NewRESTClient ¶
func NewRESTClient() (RESTClient, error)
type RESTClientMock ¶
type RESTClientMock struct { // DeleteFunc mocks the Delete method. DeleteFunc func(path string, response interface{}) error // GetFunc mocks the Get method. GetFunc func(path string, response interface{}) error // PatchFunc mocks the Patch method. PatchFunc func(path string, body io.Reader, response interface{}) error // PostFunc mocks the Post method. PostFunc func(path string, body io.Reader, response interface{}) error // PutFunc mocks the Put method. PutFunc func(path string, body io.Reader, response interface{}) error // contains filtered or unexported fields }
RESTClientMock is a mock implementation of RESTClient.
func TestSomethingThatUsesRESTClient(t *testing.T) { // make and configure a mocked RESTClient mockedRESTClient := &RESTClientMock{ DeleteFunc: func(path string, response interface{}) error { panic("mock out the Delete method") }, GetFunc: func(path string, response interface{}) error { panic("mock out the Get method") }, PatchFunc: func(path string, body io.Reader, response interface{}) error { panic("mock out the Patch method") }, PostFunc: func(path string, body io.Reader, response interface{}) error { panic("mock out the Post method") }, PutFunc: func(path string, body io.Reader, response interface{}) error { panic("mock out the Put method") }, } // use mockedRESTClient in code that requires RESTClient // and then make assertions. }
func (*RESTClientMock) Delete ¶
func (mock *RESTClientMock) Delete(path string, response interface{}) error
Delete calls DeleteFunc.
func (*RESTClientMock) DeleteCalls ¶
func (mock *RESTClientMock) DeleteCalls() []struct { Path string Response interface{} }
DeleteCalls gets all the calls that were made to Delete. Check the length with:
len(mockedRESTClient.DeleteCalls())
func (*RESTClientMock) Get ¶
func (mock *RESTClientMock) Get(path string, response interface{}) error
Get calls GetFunc.
func (*RESTClientMock) GetCalls ¶
func (mock *RESTClientMock) GetCalls() []struct { Path string Response interface{} }
GetCalls gets all the calls that were made to Get. Check the length with:
len(mockedRESTClient.GetCalls())
func (*RESTClientMock) Patch ¶
func (mock *RESTClientMock) Patch(path string, body io.Reader, response interface{}) error
Patch calls PatchFunc.
func (*RESTClientMock) PatchCalls ¶
func (mock *RESTClientMock) PatchCalls() []struct { Path string Body io.Reader Response interface{} }
PatchCalls gets all the calls that were made to Patch. Check the length with:
len(mockedRESTClient.PatchCalls())
func (*RESTClientMock) Post ¶
func (mock *RESTClientMock) Post(path string, body io.Reader, response interface{}) error
Post calls PostFunc.
func (*RESTClientMock) PostCalls ¶
func (mock *RESTClientMock) PostCalls() []struct { Path string Body io.Reader Response interface{} }
PostCalls gets all the calls that were made to Post. Check the length with:
len(mockedRESTClient.PostCalls())
type Repository ¶
type Repository struct { Name string `json:"name"` FullName string `json:"full_name"` Owner *Account `json:"owner"` Visibility Visibility `json:"visibility"` URL string `json:"html_url"` CloneURL string `json:"clone_url"` SSHURL string `json:"ssh_url"` GitURL string `json:"git_url"` }
Repository is a GitHub repo.
func (*Repository) RemoteURL ¶
func (r *Repository) RemoteURL(protocol Protocol) string
RemoteURL returns the URL for the given protocol.
type RepositoryRequest ¶
type RepositoryRequest struct { Name string `json:"name"` Private bool `json:"private"` Visibility Visibility `json:"visibility"` }
type SystemClient ¶
type SystemClient struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(restClient RESTClient, exec ExecFunc) *SystemClient
func (*SystemClient) CreateRepo ¶
func (c *SystemClient) CreateRepo(owner string, name string, vis Visibility) (*Repository, error)
func (*SystemClient) CurrentRemote ¶
func (c *SystemClient) CurrentRemote() (*Repository, error)
func (*SystemClient) CurrentUser ¶
func (c *SystemClient) CurrentUser() (*User, error)
func (*SystemClient) GetAccount ¶
func (c *SystemClient) GetAccount(name string) (*Account, error)
func (*SystemClient) GetRepo ¶
func (c *SystemClient) GetRepo(name string) (*Repository, error)
type User ¶
type User struct { // User id ID int // User login (some_user). Login string // User name (Some User). Name string // The orgs the user is a member of. Orgs []*Account // The users' preferred git protocol. GitProtocol Protocol }
User is a GitHub user.
type Visibility ¶
type Visibility string
Visibility is an enum representing a repo' visibility.
const ( VisibilityPublic Visibility = "PUBLIC" VisibilityPrivate Visibility = "PRIVATE" VisibilityInternal Visibility = "INTERNAL" )
func (Visibility) Validate ¶
func (v Visibility) Validate() error