Skip to content

Commit 508f59e

Browse files
committed
fix handling of multiple commands without separators
1 parent b84361c commit 508f59e

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

lib/algora/shared/parser.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ defmodule Algora.Parser do
66
@moduledoc false
77
def whitespace, do: ascii_string([?\s, ?\t], min: 1)
88
def digits, do: ascii_string([?0..?9], min: 1)
9-
def word_chars, do: ascii_string([not: ?\s, not: ?\t, not: ?\n, not: ?\r], min: 1)
9+
def word_chars, do: ascii_string([not: ?/, not: ?\s, not: ?\t, not: ?\n, not: ?\r], min: 1)
1010
def non_separator_chars, do: ascii_string([not: ?#, not: ?/, not: ?\s, not: ?\t, not: ?\n, not: ?\r], min: 1)
1111
def integer, do: reduce(digits(), {__MODULE__, :to_integer, []})
1212

test/algora/github/command_test.exs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,38 @@ defmodule Algora.Github.CommandTest do
110110
end
111111
end
112112

113+
describe "parse/1 with split claim command" do
114+
test "parses claim with multiple split commands separated by spaces" do
115+
assert {:ok,
116+
[
117+
claim: [ticket_ref: [number: 123]],
118+
split: [recipient: "jsmith"],
119+
split: [recipient: "jdoe"]
120+
]} ==
121+
Command.parse("/claim #123 /split @jsmith /split @jdoe")
122+
end
123+
124+
test "parses claim with multiple split commands separated by newlines" do
125+
assert {:ok,
126+
[
127+
claim: [ticket_ref: [number: 123]],
128+
split: [recipient: "jsmith"],
129+
split: [recipient: "jdoe"]
130+
]} ==
131+
Command.parse("/claim #123\r\n/split @jsmith\r\n/split @jdoe")
132+
end
133+
134+
test "parses claim with multiple split commands without separators" do
135+
assert {:ok,
136+
[
137+
claim: [ticket_ref: [number: 123]],
138+
split: [recipient: "jsmith"],
139+
split: [recipient: "jdoe"]
140+
]} ==
141+
Command.parse("/claim #123/split @jsmith/split @jdoe")
142+
end
143+
end
144+
113145
describe "parse/1 with multiple commands" do
114146
test "parses multiple commands in sequence" do
115147
assert {:ok,

0 commit comments

Comments
 (0)