MCPcopy
hub / github.com/spf13/pflag / TestS2SWithDefault

Function TestS2SWithDefault

string_to_string_test.go:112–137  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

110}
111
112func TestS2SWithDefault(t *testing.T) {
113 var s2s map[string]string
114 f := setUpS2SFlagSetWithDefault(&s2s)
115
116 vals := map[string]string{"a": "1", "b": "2", "e": "5,6"}
117 arg := fmt.Sprintf("--s2s=%s", createS2SFlag(vals))
118 err := f.Parse([]string{arg})
119 if err != nil {
120 t.Fatal("expected no error; got", err)
121 }
122 for k, v := range s2s {
123 if vals[k] != v {
124 t.Fatalf("expected s2s[%s] to be %s but got: %s", k, vals[k], v)
125 }
126 }
127
128 getS2S, err := f.GetStringToString("s2s")
129 if err != nil {
130 t.Fatal("got an error from GetStringToString():", err)
131 }
132 for k, v := range getS2S {
133 if vals[k] != v {
134 t.Fatalf("expected s2s[%s] to be %s from GetStringToString but got: %s", k, vals[k], v)
135 }
136 }
137}
138
139func TestS2SCalledTwice(t *testing.T) {
140 var s2s map[string]string

Callers

nothing calls this directly

Calls 4

createS2SFlagFunction · 0.85
GetStringToStringMethod · 0.80
ParseMethod · 0.65

Tested by

no test coverage detected