Skip to content

Commit

Permalink
feat: add further checks in TestExtractVariables
Browse files Browse the repository at this point in the history
  • Loading branch information
nedpals committed Jan 30, 2024
1 parent 8e868d4 commit 42c7864
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions error_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,23 @@ func TestExtractVariables(t *testing.T) {
})

t.Run("No variables", func(t *testing.T) {
input := "invalid input '123abc'\nin main at /home/user/main.py:123\nin main at /home/user/main.py:1"
if !tmp2.Match(input) {
t.Fatalf("expected template to match input, got false instead")
}

variables := tmp2.ExtractVariables(input)
exp := map[string]string{
"stacktrace": "\nin main at /home/user/main.py:123\nin main at /home/user/main.py:1",
}

fmt.Printf("%q\n", variables)
if !reflect.DeepEqual(variables, exp) {
t.Fatalf("expected %v, got %v", exp, variables)
}
})

t.Run("No variables + no stack trace", func(t *testing.T) {
input := "invalid input '123abc'"
if !tmp2.Match(input) {
t.Fatalf("expected template to match input, got false instead")
Expand Down

0 comments on commit 42c7864

Please sign in to comment.