Adding DefaultAuthMethod, DefaultLoginName, DefaultPassword to exported testing test controller. (#258)

pull/259/head
Todd Knight 6 years ago committed by GitHub
parent 245c7fbb44
commit 012967e91b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -29,6 +29,9 @@ type option struct {
setWithConfigText bool
setDisableDatabaseCreation bool
setDefaultOrgId bool
setDefaultAuthMethodId bool
setDefaultLoginName bool
setDefaultPassword bool
}
type Option func(*option) error
@ -92,6 +95,39 @@ func WithDefaultOrgId(id string) Option {
}
}
func WithDefaultAuthMethodId(id string) Option {
return func(c *option) error {
if c.setDefaultAuthMethodId {
return fmt.Errorf("WithDefaultAuthMethodId provided more than once.")
}
c.setDefaultAuthMethodId = true
c.tcOptions.DefaultAuthMethodId = id
return nil
}
}
func WithDefaultLoginName(ln string) Option {
return func(c *option) error {
if c.setDefaultLoginName {
return fmt.Errorf("WithDefaultLoginName provided more than once.")
}
c.setDefaultLoginName = true
c.tcOptions.DefaultLoginName = ln
return nil
}
}
func WithDefaultPassword(pw string) Option {
return func(c *option) error {
if c.setDefaultPassword {
return fmt.Errorf("WithDefaultPassword provided more than once.")
}
c.setDefaultPassword = true
c.tcOptions.DefaultPassword = pw
return nil
}
}
// NewTestController blocks until a new TestController is created, returns the url for the TestController and a function
// that can be called to tear down the controller after it has been used for testing.
func NewTestController(t *testing.T, opt ...Option) *TestController {

Loading…
Cancel
Save