MCPcopy Create free account
hub / github.com/docker/cli / TestMapOpts

Function TestMapOpts

opts/opts_test.go:84–113  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

82}
83
84func 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
115func TestListOptsWithoutValidator(t *testing.T) {
116 o := NewListOpts(nil)

Callers

nothing calls this directly

Calls 4

SetMethod · 0.95
StringMethod · 0.95
NewMapOptsFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…