Minor fixes and tweaks

This commit is contained in:
2025-03-28 01:00:26 +01:00
parent 1f6c4e4976
commit 2629722f67
5 changed files with 68 additions and 14 deletions

View File

@@ -523,6 +523,36 @@ func TestLoadCommandsFromCookFileWithMultipleEntries(t *testing.T) {
assert.Equal(t, "append", commands[2].Lua)
}
func TestLoadCommandsFromCookFileLegitExample(t *testing.T) {
// Arrange
yamlData := []byte(`
- name: crewlayabout
pattern: '<Talent identifier="crewlayabout">!anyvalue="(?<repairspeedpenalty>!num)"!anyvalue="(?<skillpenalty>!num)"!anyvalue="(?<repairspeedbonus>!num)"!anyvalue="(?<skillbonus>!num)"!anydistance="(?<distance>!num)"!anySkillBonus!anyvalue="(?<skillpenaltyv>!num)"!anyvalue="(?<skillpenaltyv1>!num)"!anyvalue="(?<skillpenaltyv2>!num)"!anyvalue="(?<skillpenaltyv3>!num)"!anyvalue="(?<skillpenaltyv4>!num)"!anyvalue="(?<repairspeedpenaltyv>!num)'
lua: |
repairspeedpenalty=round(repairspeedpenalty/2, 2)
skillpenalty=round(skillpenalty/2, 0)
repairspeedbonus=round(repairspeedbonus*2, 2)
skillbonus=round(skillbonus*2, 0)
distance=round(distance*2, 0)
skillpenaltyv=skillpenalty
skillpenaltyv1=skillpenalty
skillpenaltyv2=skillpenalty
skillpenaltyv3=skillpenalty
skillpenaltyv4=skillpenalty
repairspeedpenaltyv=round(-repairspeedpenalty/100, 2)
files:
- '**/TalentsAssistant.xml'
`)
// Act
commands, err := LoadCommandsFromCookFile(yamlData)
// Assert
assert.NoError(t, err)
assert.Len(t, commands, 1)
assert.Equal(t, "crewlayabout", commands[0].Name)
}
// Valid command with minimum 3 arguments returns a ModifyCommand slice with correct values
func TestLoadCommandFromArgsWithValidArguments(t *testing.T) {
// Setup