Update example file with json commands

This commit is contained in:
2025-12-19 11:30:38 +01:00
parent 09cdc91761
commit b309e3e6f0
3 changed files with 138 additions and 22 deletions

View File

@@ -70,8 +70,10 @@ func TestTOMLGlobalModifiers(t *testing.T) {
defer os.RemoveAll(tmpDir)
// Create TOML content with global modifiers
tomlContent := `[[commands]]
modifiers = { multiplier = 3, prefix = "TEST_", enabled = true }
tomlContent := `[modifiers]
multiplier = 3
prefix = "TEST_"
enabled = true
[[commands]]
name = "UseGlobalModifiers"
@@ -116,8 +118,8 @@ func TestTOMLMultilineRegex(t *testing.T) {
defer os.RemoveAll(tmpDir)
// Create TOML content with multiline regex using literal strings
tomlContent := `[[commands]]
modifiers = { factor = 2.5 }
tomlContent := `[modifiers]
factor = 2.5
[[commands]]
name = "MultilineTest"
@@ -301,8 +303,9 @@ func TestTOMLEndToEndIntegration(t *testing.T) {
defer os.RemoveAll(tmpDir)
// Create comprehensive TOML content
tomlContent := `[[commands]]
modifiers = { multiplier = 4, base_value = 100 }
tomlContent := `[modifiers]
multiplier = 4
base_value = 100
[[commands]]
name = "IntegrationTest"
@@ -475,19 +478,27 @@ func TestYAMLToTOMLConversion(t *testing.T) {
tomlContent := string(tomlData)
assert.Contains(t, tomlContent, `name = "ConversionTest"`, "TOML should contain first command name")
assert.Contains(t, tomlContent, `name = "AnotherTest"`, "TOML should contain second command name")
assert.Contains(t, tomlContent, `name = "GlobalModifiers"`, "TOML should contain global modifiers command")
assert.Contains(t, tomlContent, `[modifiers]`, "TOML should contain modifiers section")
assert.Contains(t, tomlContent, `multiplier = 2.5`, "TOML should contain multiplier")
assert.Contains(t, tomlContent, `prefix = "CONV_"`, "TOML should contain prefix")
// Test that converted TOML loads correctly
commands, modifiers, err := utils.LoadCommandsFromTomlFiles("test.toml")
assert.NoError(t, err, "Should load converted TOML without error")
assert.Len(t, commands, 2, "Should load 2 commands from converted TOML")
assert.Len(t, modifiers, 2, "Should load 2 modifiers from converted TOML")
assert.Len(t, commands, 3, "Should load 3 commands from converted TOML")
assert.Len(t, modifiers, 0, "Should have no top-level modifiers")
// Verify modifiers
assert.Equal(t, 2.5, modifiers["multiplier"], "Should preserve multiplier value")
assert.Equal(t, "CONV_", modifiers["prefix"], "Should preserve prefix value")
// Find the modifier command entry
var modifierCmd *utils.ModifyCommand
for i := range commands {
if commands[i].Name == "GlobalModifiers" {
modifierCmd = &commands[i]
break
}
}
assert.NotNil(t, modifierCmd, "Should find GlobalModifiers command")
assert.Equal(t, 2.5, modifierCmd.Modifiers["multiplier"], "Should preserve multiplier value")
assert.Equal(t, "CONV_", modifierCmd.Modifiers["prefix"], "Should preserve prefix value")
// Test skip functionality - run conversion again
err = utils.ConvertYAMLToTOML("test.yml")