Skip to content

Commit 42c7864

Browse files
committed
feat: add further checks in TestExtractVariables
1 parent 8e868d4 commit 42c7864

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

error_template_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,23 @@ func TestExtractVariables(t *testing.T) {
197197
})
198198

199199
t.Run("No variables", func(t *testing.T) {
200+
input := "invalid input '123abc'\nin main at /home/user/main.py:123\nin main at /home/user/main.py:1"
201+
if !tmp2.Match(input) {
202+
t.Fatalf("expected template to match input, got false instead")
203+
}
204+
205+
variables := tmp2.ExtractVariables(input)
206+
exp := map[string]string{
207+
"stacktrace": "\nin main at /home/user/main.py:123\nin main at /home/user/main.py:1",
208+
}
209+
210+
fmt.Printf("%q\n", variables)
211+
if !reflect.DeepEqual(variables, exp) {
212+
t.Fatalf("expected %v, got %v", exp, variables)
213+
}
214+
})
215+
216+
t.Run("No variables + no stack trace", func(t *testing.T) {
200217
input := "invalid input '123abc'"
201218
if !tmp2.Match(input) {
202219
t.Fatalf("expected template to match input, got false instead")

0 commit comments

Comments
 (0)