fixed error message (#14922)

* fixed error message

* Improved error messages

* Typo fix
This commit is contained in:
Jasmin Gacic 2017-06-01 12:37:20 +02:00 committed by Paul Stack
parent 1d70729444
commit ea48d71c0f
1 changed files with 25 additions and 17 deletions

View File

@ -36,67 +36,75 @@ func TestIngnitionUser(t *testing.T) {
}
`, func(c *types.Config) error {
if len(c.Passwd.Users) != 2 {
return fmt.Errorf("users, found %d", len(c.Passwd.Users))
return fmt.Errorf("Lenght of field Users didn't match. Expected: %d, Given: %d", 2, len(c.Passwd.Users))
}
u := c.Passwd.Users[0]
if u.Name != "foo" {
return fmt.Errorf("name, found %q", u.Name)
return fmt.Errorf("Field Name didn't match. Expected: %s, Given: %s", "foo", u.Name)
}
if u.PasswordHash != "password" {
return fmt.Errorf("password_hash, found %q", u.PasswordHash)
return fmt.Errorf("Field PasswordHash didn't match. Expected: %s, Given: %s", "password", u.PasswordHash)
}
if len(u.SSHAuthorizedKeys) != 1 || u.SSHAuthorizedKeys[0] != "keys" {
return fmt.Errorf("ssh_authorized_keys, found %q", u.SSHAuthorizedKeys)
if len(u.SSHAuthorizedKeys) != 1 {
return fmt.Errorf("Lenght of field SSHAuthorizedKeys didn't match. Expected: %d, Given: %d", 1, len(u.SSHAuthorizedKeys))
}
if u.SSHAuthorizedKeys[0] != "keys" {
return fmt.Errorf("Field SSHAuthorizedKeys didn't match. Expected: %s, Given: %s", "keys", u.SSHAuthorizedKeys[0])
}
if *u.Create.Uid != uint(42) {
return fmt.Errorf("uid, found %q", *u.Create.Uid)
return fmt.Errorf("Field Uid didn't match. Expected: %d, Given: %d", uint(42), u.Create.Uid)
}
if u.Create.GECOS != "gecos" {
return fmt.Errorf("gecos, found %q", u.Create.GECOS)
return fmt.Errorf("Field GECOS didn't match. Expected: %s, Given: %s", "gecos", u.Create.GECOS)
}
if u.Create.Homedir != "home" {
return fmt.Errorf("home_dir, found %q", u.Create.Homedir)
return fmt.Errorf("Field Homedir didn't match. Expected: %s, Given: %s", "home", u.Create.Homedir)
}
if u.Create.NoCreateHome != true {
return fmt.Errorf("no_create_home, found %t", u.Create.NoCreateHome)
return fmt.Errorf("Field NoCreateHome didn't match. Expected: %t, Given: %t", true, u.Create.NoCreateHome)
}
if u.Create.PrimaryGroup != "primary_group" {
return fmt.Errorf("primary_group, found %q", u.Create.PrimaryGroup)
return fmt.Errorf("Field PrimaryGroup didn't match. Expected: %s, Given: %s", "primary_group", u.Create.PrimaryGroup)
}
if len(u.Create.Groups) != 1 || u.Create.Groups[0] != "group" {
return fmt.Errorf("groups, found %q", u.Create.Groups)
if len(u.Create.Groups) != 1 {
return fmt.Errorf("Lenght of field Groups didn't match. Expected: %d, Given: %d", 1, len(u.Create.Groups))
}
if u.Create.Groups[0] != "group" {
return fmt.Errorf("Field Groups didn't match. Expected: %s, Given: %s", "group", u.Create.Groups[0])
}
if u.Create.NoUserGroup != true {
return fmt.Errorf("no_create_home, found %t", u.Create.NoCreateHome)
return fmt.Errorf("Field NoUserGroup didn't match. Expected: %t, Given: %t", true, u.Create.NoUserGroup)
}
if u.Create.NoLogInit != true {
return fmt.Errorf("no_log_init, found %t", u.Create.NoLogInit)
return fmt.Errorf("Field NoLogInit didn't match. Expected: %t, Given: %t", true, u.Create.NoLogInit)
}
if u.Create.Shell != "shell" {
return fmt.Errorf("shell, found %q", u.Create.Shell)
return fmt.Errorf("Field Shell didn't match. Expected: %s, Given: %s", "shell", u.Create.Shell)
}
u = c.Passwd.Users[1]
if u.Name != "qux" {
return fmt.Errorf("name, found %q", u.Name)
return fmt.Errorf("Field Name didn't match. Expected: %s, Given: %s", "qux", u.Name)
}
if u.Create != nil {
return fmt.Errorf("create struct found")
return fmt.Errorf("Field Create didn't match. Expected: %v, Given: %v", nil, u.Create)
}
return nil