feat(scum): rebuild plugin-owned management data
This commit is contained in:
@@ -42,6 +42,9 @@ func (*adapterFixture) PatchGameState(context.Context, map[string]any) (map[stri
|
||||
func (*adapterFixture) DeliverReward(context.Context, map[string]any) (map[string]any, error) {
|
||||
return nil, nil
|
||||
}
|
||||
func (*adapterFixture) StartEvent(context.Context, map[string]any) (map[string]any, error) {
|
||||
return nil, nil
|
||||
}
|
||||
func (*adapterFixture) NotifyPlayer(context.Context, map[string]any) (map[string]any, error) {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -92,3 +95,21 @@ func TestRegistryRejectsUndeclaredAndMalformedPayloads(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRewardPayloadValidationRequiresItemsOrOperations(t *testing.T) {
|
||||
validBase := map[string]any{"grantId": "grant-1", "playerId": "76561198000000001"}
|
||||
for name, payload := range map[string]map[string]any{
|
||||
"items": {"grantId": validBase["grantId"], "playerId": validBase["playerId"], "items": []any{map[string]any{"catalogCode": "BPC_Apple", "quantity": float64(1)}}, "operations": []any{}},
|
||||
"operations": {"grantId": validBase["grantId"], "playerId": validBase["playerId"], "items": []any{}, "operations": []any{"#SetFamePoints 250"}},
|
||||
"both": {"grantId": validBase["grantId"], "playerId": validBase["playerId"], "items": []any{map[string]any{"catalogCode": "BPC_Apple", "quantity": float64(1)}}, "operations": []any{"#SetFamePoints 250"}},
|
||||
} {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
if err := validateCommandPayload("reward.deliver", payload); err != nil {
|
||||
t.Fatalf("valid reward payload was rejected: %v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
if err := validateCommandPayload("reward.deliver", map[string]any{"grantId": "grant-empty", "playerId": "76561198000000001", "items": []any{}, "operations": []any{}}); err == nil {
|
||||
t.Fatal("reward payload with no items or operations was accepted")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user