Fix tests
This commit is contained in:
@@ -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",
|
||||
|
Reference in New Issue
Block a user