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

Function TestS2S

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

Source from the content-addressed store, hash-verified

57}
58
59func TestS2S(t *testing.T) {
60 var s2s map[string]string
61 f := setUpS2SFlagSet(&s2s)
62
63 vals := map[string]string{"a": "1", "b": "2", "d": "4", "c": "3", "e": "5,6"}
64 arg := fmt.Sprintf("--s2s=%s", createS2SFlag(vals))
65 err := f.Parse([]string{arg})
66 if err != nil {
67 t.Fatal("expected no error; got", err)
68 }
69 for k, v := range s2s {
70 if vals[k] != v {
71 t.Fatalf("expected s2s[%s] to be %s but got: %s", k, vals[k], v)
72 }
73 }
74 getS2S, err := f.GetStringToString("s2s")
75 if err != nil {
76 t.Fatalf("got error: %v", err)
77 }
78 for k, v := range getS2S {
79 if vals[k] != v {
80 t.Fatalf("expected s2s[%s] to be %s but got: %s from GetStringToString", k, vals[k], v)
81 }
82 }
83}
84
85func TestS2SDefault(t *testing.T) {
86 var s2s map[string]string

Callers

nothing calls this directly

Calls 4

setUpS2SFlagSetFunction · 0.85
createS2SFlagFunction · 0.85
GetStringToStringMethod · 0.80
ParseMethod · 0.65

Tested by

no test coverage detected