Skip to content

Commit

Permalink
chore: add extra ParseCommandLine tests for json
Browse files Browse the repository at this point in the history
  • Loading branch information
rolznz committed Jan 28, 2025
1 parent 618bffc commit d34aacf
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ func TestParseCommandLine(t *testing.T) {
expectedError string
}

// When called by the API, the first argument of the command input is actually the command name
testCases := []testCase{
{
name: "empty input",
Expand Down Expand Up @@ -53,6 +54,18 @@ func TestParseCommandLine(t *testing.T) {
expectedSuccess: []string{"arg 1", "arg2"},
expectedError: "",
},
{
name: "escaped JSON",
input: `{\"hello\":\"world\"}`,
expectedSuccess: []string{`{"hello":"world"}`},
expectedError: "",
},
{
name: "escaped JSON with space",
input: `"{\"hello\": \"world\"}"`,
expectedSuccess: []string{`{"hello": "world"}`},
expectedError: "",
},
{
name: "unclosed quote",
input: `"arg 1", "arg2", "arg\"3`,
Expand Down

0 comments on commit d34aacf

Please sign in to comment.