Migrate NPC registry durable contract
This commit is contained in:
@@ -13,21 +13,21 @@ import (
|
||||
)
|
||||
|
||||
func TestValidatorApprovesWellFormedNPCPayload(t *testing.T) {
|
||||
result, err := New(Options{}).Validate(context.Background(), requestWithValue(validNPCList()))
|
||||
result, err := New(Options{}).Validate(context.Background(), requestWithValue(validNPCRegistry()))
|
||||
if err != nil || !result.Approved {
|
||||
t.Fatalf("Validate() = %#v, %v; want approval", result, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidatorRejectsRequiredShapeValues(t *testing.T) {
|
||||
value := validNPCList()
|
||||
value := validNPCRegistry()
|
||||
value.NPCs[0].Name = ""
|
||||
result, err := New(Options{}).Validate(context.Background(), requestWithValue(value))
|
||||
if err != nil || result.Approved || result.ReasonCode != ReasonCode || !strings.Contains(result.Message, "name must not be empty") {
|
||||
t.Fatalf("Validate() = %#v, %v; want bounded shape rejection", result, err)
|
||||
}
|
||||
|
||||
missing := dnd.NPCList{}
|
||||
missing := dnd.NPCRegistry{}
|
||||
result, err = New(Options{}).Validate(context.Background(), requestWithValue(missing))
|
||||
if err != nil || result.Approved || result.ReasonCode != ReasonCode {
|
||||
t.Fatalf("missing Validate() = %#v, %v; want shape rejection", result, err)
|
||||
@@ -35,7 +35,7 @@ func TestValidatorRejectsRequiredShapeValues(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestValidatorBoundsDiagnosticsAndQuotesUnicode(t *testing.T) {
|
||||
value := dnd.NPCList{NPCs: make([]dnd.NPC, 24)}
|
||||
value := dnd.NPCRegistry{NPCs: make([]dnd.NPC, 24)}
|
||||
long := strings.Repeat("火", 220) + "\n\t"
|
||||
for index := range value.NPCs {
|
||||
value.NPCs[index] = dnd.NPC{ID: "", Name: long, SourceRefs: []source.SourceRef{}}
|
||||
@@ -66,7 +66,7 @@ func TestValidatorSpecCheckpointAndRegistration(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestValidatorDoesNotMutateValue(t *testing.T) {
|
||||
value := validNPCList()
|
||||
value := validNPCRegistry()
|
||||
before := value
|
||||
_, err := New(Options{}).Validate(context.Background(), requestWithValue(value))
|
||||
if err != nil || value.NPCs[0].Name != before.NPCs[0].Name {
|
||||
@@ -74,12 +74,12 @@ func TestValidatorDoesNotMutateValue(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func requestWithValue(value dnd.NPCList) contracts.TypedValidationRequest[dnd.NPCList] {
|
||||
return contracts.TypedValidationRequest[dnd.NPCList]{Value: value}
|
||||
func requestWithValue(value dnd.NPCRegistry) contracts.TypedValidationRequest[dnd.NPCRegistry] {
|
||||
return contracts.TypedValidationRequest[dnd.NPCRegistry]{Value: value}
|
||||
}
|
||||
|
||||
func validNPCList() dnd.NPCList {
|
||||
return dnd.NPCList{NPCs: []dnd.NPC{{
|
||||
func validNPCRegistry() dnd.NPCRegistry {
|
||||
return dnd.NPCRegistry{NPCs: []dnd.NPC{{
|
||||
ID: "candidate", Name: "Mira Thorn",
|
||||
SourceRefs: []source.SourceRef{{SourceID: "session", StartUnitID: 1, EndUnitID: 1}},
|
||||
}}}
|
||||
|
||||
Reference in New Issue
Block a user