36 lines
1010 B
Go
36 lines
1010 B
Go
package mysql
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestBootstrapConsoleAdministratorRequiresUsernameAndPassword(t *testing.T) {
|
|
base := BootstrapInput{Application: "app", Namespace: "default", Environment: "test", Queue: "queue"}
|
|
for name, in := range map[string]BootstrapInput{
|
|
"username without password": func() BootstrapInput {
|
|
in := base
|
|
in.ConsoleUsername = "admin"
|
|
return in
|
|
}(),
|
|
"password without username": func() BootstrapInput {
|
|
in := base
|
|
in.ConsolePassword = "a sufficiently long password"
|
|
return in
|
|
}(),
|
|
"display name without account": func() BootstrapInput {
|
|
in := base
|
|
in.ConsoleDisplayName = "Orbit 管理员"
|
|
return in
|
|
}(),
|
|
} {
|
|
t.Run(name, func(t *testing.T) {
|
|
err := Bootstrap(context.Background(), nil, in, func(BootstrapResult) error { return nil })
|
|
if err == nil || !strings.Contains(err.Error(), "console username and password") {
|
|
t.Fatalf("expected console administrator validation error, got %v", err)
|
|
}
|
|
})
|
|
}
|
|
}
|