(t *testing.T)
| 82 | } |
| 83 | |
| 84 | func TestMapOpts(t *testing.T) { |
| 85 | tmpMap := make(map[string]string) |
| 86 | o := NewMapOpts(tmpMap, sampleValidator) |
| 87 | err := o.Set("valid-option=1") |
| 88 | if err != nil { |
| 89 | t.Error(err) |
| 90 | } |
| 91 | if o.String() != "map[valid-option:1]" { |
| 92 | t.Errorf("%s != [map[valid-option:1]", o.String()) |
| 93 | } |
| 94 | |
| 95 | err = o.Set("valid-option2=2") |
| 96 | if err != nil { |
| 97 | t.Error(err) |
| 98 | } |
| 99 | if len(tmpMap) != 2 { |
| 100 | t.Errorf("map length %d != 2", len(tmpMap)) |
| 101 | } |
| 102 | |
| 103 | if tmpMap["valid-option"] != "1" { |
| 104 | t.Errorf("valid-option = %s != 1", tmpMap["valid-option"]) |
| 105 | } |
| 106 | if tmpMap["valid-option2"] != "2" { |
| 107 | t.Errorf("valid-option2 = %s != 2", tmpMap["valid-option2"]) |
| 108 | } |
| 109 | |
| 110 | if o.Set("dummy-val=3") == nil { |
| 111 | t.Error("validator is not being called") |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | func TestListOptsWithoutValidator(t *testing.T) { |
| 116 | o := NewListOpts(nil) |
nothing calls this directly
no test coverage detected
searching dependent graphs…