diff options
author | Michael Muré <batolettre@gmail.com> | 2022-05-01 12:30:55 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2022-05-01 12:31:50 +0200 |
commit | b9991d84b913577a17635b4ca8863d60cda79c42 (patch) | |
tree | d9cb340d571b685c7458c2f3e1fc2f8b1b0664f5 /commands/ls_test.go | |
parent | edc8b7589dcf1daad65b0e57488a3b3f86711926 (diff) | |
download | git-bug-b9991d84b913577a17635b4ca8863d60cda79c42.tar.gz git-bug-b9991d84b913577a17635b4ca8863d60cda79c42.zip |
ls: fix incorrect query parsing with quotes escaped by the shell
Diffstat (limited to 'commands/ls_test.go')
-rw-r--r-- | commands/ls_test.go | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/commands/ls_test.go b/commands/ls_test.go new file mode 100644 index 00000000..aff94e03 --- /dev/null +++ b/commands/ls_test.go @@ -0,0 +1,43 @@ +package commands + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func Test_repairQuery(t *testing.T) { + cases := []struct { + args []string + output string + }{ + { + []string{""}, + "", + }, + { + []string{"foo"}, + "foo", + }, + { + []string{"foo", "bar"}, + "foo bar", + }, + { + []string{"foo bar", "baz"}, + "\"foo bar\" baz", + }, + { + []string{"foo:bar", "baz"}, + "foo:bar baz", + }, + { + []string{"foo:bar boo", "baz"}, + "foo:\"bar boo\" baz", + }, + } + + for _, tc := range cases { + require.Equal(t, tc.output, repairQuery(tc.args)) + } +} |