fix test and failed map access
This commit is contained in:
@@ -156,7 +156,7 @@ func (r Rule) Evaluate(it data.Item) (RuleResult, error) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if itemTypes, found := blockedStatsForItemType[statName[0]]; found {
|
if itemTypes, found := blockedStatsForItemType[statName[1]]; found {
|
||||||
if slices.Contains(itemTypes, it.TypeAsString()) {
|
if slices.Contains(itemTypes, it.TypeAsString()) {
|
||||||
return RuleResultNoMatch, fmt.Errorf("property %s is not supported for item type %s", statName[0], it.TypeAsString())
|
return RuleResultNoMatch, fmt.Errorf("property %s is not supported for item type %s", statName[0], it.TypeAsString())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -163,6 +163,23 @@ func TestRule_Evaluate(t *testing.T) {
|
|||||||
},
|
},
|
||||||
want: RuleResultFullMatch,
|
want: RuleResultFullMatch,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "enhanceddamage should not work for weapons",
|
||||||
|
fields: fields{
|
||||||
|
RawLine: "[type] == axe && [quality] == superior # [enhanceddamage] >= 15 #",
|
||||||
|
Enabled: true,
|
||||||
|
},
|
||||||
|
args: args{
|
||||||
|
item: data.Item{
|
||||||
|
Identified: true,
|
||||||
|
ID: 0,
|
||||||
|
Name: "handaxe",
|
||||||
|
Quality: item.QualityUnique,
|
||||||
|
Stats: []stat.Data{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
wantErr: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
@@ -192,9 +209,9 @@ func TestNew(t *testing.T) {
|
|||||||
wantErr bool
|
wantErr bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "Enhanced Damage should throw an error",
|
name: "itemthrustdamage should throw an error",
|
||||||
args: args{
|
args: args{
|
||||||
rawRule: "[type] == armor # [enhanceddamage] >= 15",
|
rawRule: "[type] == axe # [itemthrustdamage] >= 15",
|
||||||
},
|
},
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user