MCPcopy
hub / github.com/restic/restic / TestShellSplitterInvalid

Function TestShellSplitterInvalid

internal/backend/shell_split_test.go:66–105  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

64}
65
66func TestShellSplitterInvalid(t *testing.T) {
67 var tests = []struct {
68 data string
69 err string
70 }{
71 {
72 "foo'",
73 "single-quoted string not terminated",
74 },
75 {
76 `foo"`,
77 "double-quoted string not terminated",
78 },
79 {
80 "foo 'bar",
81 "single-quoted string not terminated",
82 },
83 {
84 `foo "bar`,
85 "double-quoted string not terminated",
86 },
87 }
88
89 for _, test := range tests {
90 t.Run("", func(t *testing.T) {
91 args, err := SplitShellStrings(test.data)
92 if err == nil {
93 t.Fatalf("expected error not found: %v", test.err)
94 }
95
96 if err.Error() != test.err {
97 t.Fatalf("expected error not found, want:\n %q\ngot:\n %q", test.err, err.Error())
98 }
99
100 if len(args) > 0 {
101 t.Fatalf("splitter returned fields from invalid data: %v", args)
102 }
103 })
104 }
105}

Callers

nothing calls this directly

Calls 4

SplitShellStringsFunction · 0.85
RunMethod · 0.80
FatalfMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected