From 42c786406790b5761adf5842b8a74d2c842a4fc0 Mon Sep 17 00:00:00 2001 From: Ned Palacios Date: Tue, 30 Jan 2024 10:54:20 +0800 Subject: [PATCH] feat: add further checks in TestExtractVariables --- error_template_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/error_template_test.go b/error_template_test.go index 7f1263a..327609d 100644 --- a/error_template_test.go +++ b/error_template_test.go @@ -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")