Adding unit tests for cmd line

Этот коммит содержится в:
=Corey Hulen
2015-09-04 16:56:18 -07:00
родитель 58d0d9afd2
Коммит e54d0da392
8 изменённых файлов: 25 добавлений и 17 удалений

Просмотреть файл

@@ -925,7 +925,7 @@ func updateRoles(c *Context, w http.ResponseWriter, r *http.Request) {
}
new_roles := props["new_roles"]
if model.IsValidRoles(new_roles) {
if !model.IsValidRoles(new_roles) {
c.SetInvalidParam("updateRoles", "new_roles")
return
}

Просмотреть файл

@@ -257,6 +257,12 @@ func cmdResetPassword() {
os.Exit(1)
}
if len(flagPassword) < 5 {
fmt.Fprintln(os.Stderr, "flag invalid argument needs to be more than 4 characters: -password")
flag.Usage()
os.Exit(1)
}
c := &api.Context{}
c.RequestId = model.NewId()
c.IpAddress = "cmd_line"

Просмотреть файл

@@ -106,8 +106,8 @@ var tReservedDomains = []struct {
}{
{"test-hello", true},
{"test", true},
{"admin", true},
{"Admin-punch", true},
//{"admin", true},
//{"Admin-punch", true},
{"spin-punch-admin", false},
}

Просмотреть файл

@@ -199,6 +199,15 @@ func TestRoles(t *testing.T) {
t.Fatal()
}
//IsInRole
if IsValidRoles("junk") {
t.Fatal()
}
if IsInRole("system_admin junk", "admin") {
t.Fatal()
}
if !IsInRole("system_admin junk", "system_admin") {
t.Fatal()
}
}

Просмотреть файл

@@ -151,7 +151,7 @@ func IsValidEmail(email string) bool {
var reservedName = []string{
"www",
"web",
"admin",
//"admin",
"support",
"notify",
"test",

Просмотреть файл

@@ -35,10 +35,6 @@ func (s SqlTeamStore) CreateIndexesIfNotExists() {
}
func (s SqlTeamStore) Save(team *model.Team) StoreChannel {
return s.SaveWithValidate(team, true)
}
func (s SqlTeamStore) SaveWithValidate(team *model.Team, validate bool) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -54,12 +50,10 @@ func (s SqlTeamStore) SaveWithValidate(team *model.Team, validate bool) StoreCha
team.PreSave()
if validate {
if result.Err = team.IsValid(); result.Err != nil {
storeChannel <- result
close(storeChannel)
return
}
if result.Err = team.IsValid(); result.Err != nil {
storeChannel <- result
close(storeChannel)
return
}
if err := s.GetMaster().Insert(team); err != nil {

Просмотреть файл

@@ -39,7 +39,6 @@ type Store interface {
type TeamStore interface {
Save(team *model.Team) StoreChannel
SaveWithValidate(team *model.Team, validate bool) StoreChannel
Update(team *model.Team) StoreChannel
UpdateDisplayName(name string, teamId string) StoreChannel
Get(id string) StoreChannel

Просмотреть файл

@@ -2,7 +2,7 @@
// See License.txt for license information.
export function setupAdminConsolePage() {
console.log('setting up admin page');
}
global.window.setup_admin_console_page = setupAdminConsolePage;