-
-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ls: fix incorrect query parsing with quotes escaped by the shell
- Loading branch information
1 parent
edc8b75
commit b9991d8
Showing
2 changed files
with
59 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)) | ||
} | ||
} |