Fix tests

This commit is contained in:
2025-08-21 22:20:07 +02:00
parent 491a030bf8
commit c3d26e79f0
2 changed files with 20 additions and 52 deletions

View File

@@ -16,46 +16,25 @@ func TestProcessJSON(t *testing.T) {
expectedMods int
}{
{
name: "Basic JSON object modification",
input: `{"name": "test", "value": 42}`,
luaExpression: `data.value = data.value * 2; return true`,
expectedOutput: `{
"name": "test",
"value": 84
}`,
expectedMods: 1,
name: "Basic JSON object modification",
input: `{"name": "test", "value": 42}`,
luaExpression: `data.value = data.value * 2; return true`,
expectedOutput: `{"name": "test", "value": 84}`, // Surgical editing preserves compact format
expectedMods: 1,
},
{
name: "JSON array modification",
input: `{"items": [{"id": 1, "value": 10}, {"id": 2, "value": 20}]}`,
luaExpression: `for i, item in ipairs(data.items) do data.items[i].value = item.value * 1.5 end; return true`,
expectedOutput: `{
"items": [
{
"id": 1,
"value": 15
},
{
"id": 2,
"value": 30
}
]
}`,
expectedMods: 1,
name: "JSON array modification",
input: `{"items": [{"id": 1, "value": 10}, {"id": 2, "value": 20}]}`,
luaExpression: `for i, item in ipairs(data.items) do data.items[i].value = item.value * 1.5 end; return true`,
expectedOutput: `{"items": [{"id": 1, "value": 15}, {"id": 2, "value": 30}]}`, // Surgical editing preserves compact format
expectedMods: 1,
},
{
name: "JSON nested object modification",
input: `{"config": {"settings": {"enabled": false, "timeout": 30}}}`,
luaExpression: `data.config.settings.enabled = true; data.config.settings.timeout = 60; return true`,
expectedOutput: `{
"config": {
"settings": {
"enabled": true,
"timeout": 60
}
}
}`,
expectedMods: 1,
name: "JSON nested object modification",
input: `{"config": {"settings": {"enabled": false, "timeout": 30}}}`,
luaExpression: `data.config.settings.enabled = true; data.config.settings.timeout = 60; return true`,
expectedOutput: `{"config": {"settings": {"enabled": true, "timeout": 60}}}`, // Surgical editing preserves compact format
expectedMods: 1,
},
{
name: "JSON no modification",