package content import "testing" func TestBuildingKitsAndRequirements(t *testing.T) { c, e := DefaultCatalog() if e != nil { t.Fatal(e) } c.Crafting.Recipes = append(c.Crafting.Recipes, CraftRecipe{ID: "wall_kit_recipe", Name: "Wall kit", Revision: 1, Profession: "builder", Level: 1, XP: 20, Inputs: map[string]int64{"wood": 6, "ore": 2}, Outputs: map[string]int64{"kit_timber_wall": 1}}) if e = c.Validate(); e != nil { t.Fatal("could not author kit recipe", e) } d := c.Building.Definitions[0] d.Height = -1 c.Building.Definitions[0] = d if e = c.Validate(); e == nil { t.Fatal("negative height allowed") } d.Height = 2 d.Profession = "missing" c.Building.Definitions[0] = d if e = c.Validate(); e == nil { t.Fatal("missing profession allowed") } }