Adding DefaultAuthMethod, DefaultLoginName, DefaultPassword to exported testing test controller. (#258)
This commit is contained in:
1 parent
245c7fbb44
commit
012967e91b
1 file changed
+36
@@ -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 {
|
||||
|
||||
Reference in new issue
Block a user