(t *testing.T)
| 64 | } |
| 65 | |
| 66 | func 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 | } |
nothing calls this directly
no test coverage detected