Documentation ¶
Index ¶
- func ConfigDir() string
- func DataDir() string
- func HomeDirPath(subdir string) (string, error)
- func StateDir() string
- func StubWriteConfig(t *testing.T) func(io.Writer, io.Writer)
- type AliasConfig
- type Config
- type ConfigMock
- func (mock *ConfigMock) Aliases() *AliasConfig
- func (mock *ConfigMock) AliasesCalls() []struct{}
- func (mock *ConfigMock) AuthToken(s string) (string, string)
- func (mock *ConfigMock) AuthTokenCalls() []struct{ ... }
- func (mock *ConfigMock) DefaultHost() (string, string)
- func (mock *ConfigMock) DefaultHostCalls() []struct{}
- func (mock *ConfigMock) Get(s1 string, s2 string) (string, error)
- func (mock *ConfigMock) GetCalls() []struct{ ... }
- func (mock *ConfigMock) GetOrDefault(s1 string, s2 string) (string, error)
- func (mock *ConfigMock) GetOrDefaultCalls() []struct{ ... }
- func (mock *ConfigMock) Hosts() []string
- func (mock *ConfigMock) HostsCalls() []struct{}
- func (mock *ConfigMock) Set(s1 string, s2 string, s3 string)
- func (mock *ConfigMock) SetCalls() []struct{ ... }
- func (mock *ConfigMock) UnsetHost(s string)
- func (mock *ConfigMock) UnsetHostCalls() []struct{ ... }
- func (mock *ConfigMock) Write() error
- func (mock *ConfigMock) WriteCalls() []struct{}
- type ConfigOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HomeDirPath ¶
func StubWriteConfig ¶
StubWriteConfig stubs out the filesystem where config file are written. It then returns a function that will read in the config files into io.Writers. It automatically cleans up environment variables and written files.
Types ¶
type AliasConfig ¶
type AliasConfig struct {
// contains filtered or unexported fields
}
func (*AliasConfig) Add ¶
func (a *AliasConfig) Add(alias, expansion string)
func (*AliasConfig) All ¶
func (a *AliasConfig) All() map[string]string
func (*AliasConfig) Delete ¶
func (a *AliasConfig) Delete(alias string) error
type Config ¶
type Config interface { AuthToken(string) (string, string) Get(string, string) (string, error) GetOrDefault(string, string) (string, error) Set(string, string, string) UnsetHost(string) Hosts() []string DefaultHost() (string, string) Aliases() *AliasConfig Write() error }
This interface describes interacting with some persistent configuration for gh.
type ConfigMock ¶
type ConfigMock struct { // AliasesFunc mocks the Aliases method. AliasesFunc func() *AliasConfig // AuthTokenFunc mocks the AuthToken method. AuthTokenFunc func(s string) (string, string) // DefaultHostFunc mocks the DefaultHost method. DefaultHostFunc func() (string, string) // GetFunc mocks the Get method. GetFunc func(s1 string, s2 string) (string, error) // GetOrDefaultFunc mocks the GetOrDefault method. GetOrDefaultFunc func(s1 string, s2 string) (string, error) // HostsFunc mocks the Hosts method. HostsFunc func() []string // SetFunc mocks the Set method. SetFunc func(s1 string, s2 string, s3 string) // UnsetHostFunc mocks the UnsetHost method. UnsetHostFunc func(s string) // WriteFunc mocks the Write method. WriteFunc func() error // contains filtered or unexported fields }
ConfigMock is a mock implementation of Config.
func TestSomethingThatUsesConfig(t *testing.T) { // make and configure a mocked Config mockedConfig := &ConfigMock{ AliasesFunc: func() *AliasConfig { panic("mock out the Aliases method") }, AuthTokenFunc: func(s string) (string, string) { panic("mock out the AuthToken method") }, DefaultHostFunc: func() (string, string) { panic("mock out the DefaultHost method") }, GetFunc: func(s1 string, s2 string) (string, error) { panic("mock out the Get method") }, GetOrDefaultFunc: func(s1 string, s2 string) (string, error) { panic("mock out the GetOrDefault method") }, HostsFunc: func() []string { panic("mock out the Hosts method") }, SetFunc: func(s1 string, s2 string, s3 string) { panic("mock out the Set method") }, UnsetHostFunc: func(s string) { panic("mock out the UnsetHost method") }, WriteFunc: func() error { panic("mock out the Write method") }, } // use mockedConfig in code that requires Config // and then make assertions. }
func NewBlankConfig ¶
func NewBlankConfig() *ConfigMock
func NewFromString ¶
func NewFromString(cfgStr string) *ConfigMock
func (*ConfigMock) Aliases ¶
func (mock *ConfigMock) Aliases() *AliasConfig
Aliases calls AliasesFunc.
func (*ConfigMock) AliasesCalls ¶
func (mock *ConfigMock) AliasesCalls() []struct { }
AliasesCalls gets all the calls that were made to Aliases. Check the length with:
len(mockedConfig.AliasesCalls())
func (*ConfigMock) AuthToken ¶
func (mock *ConfigMock) AuthToken(s string) (string, string)
AuthToken calls AuthTokenFunc.
func (*ConfigMock) AuthTokenCalls ¶
func (mock *ConfigMock) AuthTokenCalls() []struct { S string }
AuthTokenCalls gets all the calls that were made to AuthToken. Check the length with:
len(mockedConfig.AuthTokenCalls())
func (*ConfigMock) DefaultHost ¶
func (mock *ConfigMock) DefaultHost() (string, string)
DefaultHost calls DefaultHostFunc.
func (*ConfigMock) DefaultHostCalls ¶
func (mock *ConfigMock) DefaultHostCalls() []struct { }
DefaultHostCalls gets all the calls that were made to DefaultHost. Check the length with:
len(mockedConfig.DefaultHostCalls())
func (*ConfigMock) Get ¶
func (mock *ConfigMock) Get(s1 string, s2 string) (string, error)
Get calls GetFunc.
func (*ConfigMock) GetCalls ¶
func (mock *ConfigMock) GetCalls() []struct { S1 string S2 string }
GetCalls gets all the calls that were made to Get. Check the length with:
len(mockedConfig.GetCalls())
func (*ConfigMock) GetOrDefault ¶
func (mock *ConfigMock) GetOrDefault(s1 string, s2 string) (string, error)
GetOrDefault calls GetOrDefaultFunc.
func (*ConfigMock) GetOrDefaultCalls ¶
func (mock *ConfigMock) GetOrDefaultCalls() []struct { S1 string S2 string }
GetOrDefaultCalls gets all the calls that were made to GetOrDefault. Check the length with:
len(mockedConfig.GetOrDefaultCalls())
func (*ConfigMock) HostsCalls ¶
func (mock *ConfigMock) HostsCalls() []struct { }
HostsCalls gets all the calls that were made to Hosts. Check the length with:
len(mockedConfig.HostsCalls())
func (*ConfigMock) Set ¶
func (mock *ConfigMock) Set(s1 string, s2 string, s3 string)
Set calls SetFunc.
func (*ConfigMock) SetCalls ¶
func (mock *ConfigMock) SetCalls() []struct { S1 string S2 string S3 string }
SetCalls gets all the calls that were made to Set. Check the length with:
len(mockedConfig.SetCalls())
func (*ConfigMock) UnsetHost ¶
func (mock *ConfigMock) UnsetHost(s string)
UnsetHost calls UnsetHostFunc.
func (*ConfigMock) UnsetHostCalls ¶
func (mock *ConfigMock) UnsetHostCalls() []struct { S string }
UnsetHostCalls gets all the calls that were made to UnsetHost. Check the length with:
len(mockedConfig.UnsetHostCalls())
func (*ConfigMock) WriteCalls ¶
func (mock *ConfigMock) WriteCalls() []struct { }
WriteCalls gets all the calls that were made to Write. Check the length with:
len(mockedConfig.WriteCalls())
type ConfigOption ¶
type ConfigOption struct { Key string Description string DefaultValue string AllowedValues []string }
func ConfigOptions ¶
func ConfigOptions() []ConfigOption