1
0
Fork 0
mirror of https://github.com/Luzifer/ansible-role-version.git synced 2024-12-23 19:11:20 +00:00
ansible-role-version/vendor/github.com/kevinburke/ssh_config/validators_test.go
Knut Ahlers 209b813c5b
Update dependencies
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2018-03-19 18:16:10 +01:00

44 lines
1.2 KiB
Go

package ssh_config
import (
"testing"
)
var validateTests = []struct {
key string
val string
err string
}{
{"IdentitiesOnly", "yes", ""},
{"IdentitiesOnly", "Yes", `ssh_config: value for key "IdentitiesOnly" must be 'yes' or 'no', got "Yes"`},
{"Port", "22", ``},
{"Port", "yes", `ssh_config: strconv.ParseUint: parsing "yes": invalid syntax`},
}
func TestValidate(t *testing.T) {
for _, tt := range validateTests {
err := validate(tt.key, tt.val)
if tt.err == "" && err != nil {
t.Errorf("validate(%q, %q): got %v, want nil", tt.key, tt.val, err)
}
if tt.err != "" {
if err == nil {
t.Errorf("validate(%q, %q): got nil error, want %v", tt.key, tt.val, tt.err)
} else if err.Error() != tt.err {
t.Errorf("validate(%q, %q): got err %v, want %v", tt.key, tt.val, err, tt.err)
}
}
}
}
func TestDefault(t *testing.T) {
if v := Default("VisualHostKey"); v != "no" {
t.Errorf("Default(%q): got %v, want 'no'", "VisualHostKey", v)
}
if v := Default("visualhostkey"); v != "no" {
t.Errorf("Default(%q): got %v, want 'no'", "visualhostkey", v)
}
if v := Default("notfound"); v != "" {
t.Errorf("Default(%q): got %v, want ''", "notfound", v)
}
}