Make regex matching set INTEGER keys not string

This commit is contained in:
2025-11-03 19:06:59 +01:00
parent ee8c4b9aa5
commit 590f19603e
2 changed files with 6 additions and 7 deletions

View File

@@ -1,7 +1,6 @@
package processor_test
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
@@ -30,8 +29,8 @@ func TestEvalRegex_CaptureGroupsReturned(t *testing.T) {
}
expected := []string{"test-42", "test", "42"}
for i, v := range expected {
val := tbl.RawGetString(fmt.Sprintf("%d", i))
assert.Equal(t, lua.LString(v), val, "Expected index %d to be %q", i, v)
val := tbl.RawGetInt(i + 1)
assert.Equal(t, lua.LString(v), val, "Expected index %d to be %q", i+1, v)
}
}
@@ -67,9 +66,9 @@ func TestEvalRegex_NoCaptureGroups(t *testing.T) {
if !ok {
t.Fatalf("Expected Lua table, got %T", out)
}
fullMatch := tbl.RawGetString("0")
fullMatch := tbl.RawGetInt(1)
assert.Equal(t, lua.LString("foo123"), fullMatch)
// There should be only the full match (index 0)
// There should be only the full match (index 1)
count := 0
tbl.ForEach(func(k, v lua.LValue) {
count++