mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Add tests for validation assets
This commit is contained in:
parent
8c1643cad9
commit
457e5b14d8
@ -1,8 +1,8 @@
|
||||
({
|
||||
"head": Item("common.items.npc_armor.biped_small.gnarling.head.gnarling"),
|
||||
"feet": Item("common.items.npc_armor.biped_small.gnarling.foot.gnarling"),
|
||||
"hands": Item("common.items.npc_armor.biped_small.gnarling.hand.gnarling"),
|
||||
"chest": Item("common.items.npc_armor.biped_small.gnarling.chest.gnarling"),
|
||||
"pants": Item("common.items.npc_armor.biped_small.gnarling.pants.gnarling"),
|
||||
"belt": Item("common.items.npc_armor.biped_small.gnarling.tail.gnarling"),
|
||||
Armor(Head): Item("common.items.npc_armor.biped_small.gnarling.head.gnarling"),
|
||||
Armor(Feet): Item("common.items.npc_armor.biped_small.gnarling.foot.gnarling"),
|
||||
Armor(Hands): Item("common.items.npc_armor.biped_small.gnarling.hand.gnarling"),
|
||||
Armor(Chest): Item("common.items.npc_armor.biped_small.gnarling.chest.gnarling"),
|
||||
Armor(Legs): Item("common.items.npc_armor.biped_small.gnarling.pants.gnarling"),
|
||||
Armor(Belt): Item("common.items.npc_armor.biped_small.gnarling.tail.gnarling"),
|
||||
})
|
||||
|
@ -1,8 +1,8 @@
|
||||
({
|
||||
"head": Item("common.items.npc_armor.biped_small.adlet.head.adlet_bow"),
|
||||
"hands": Item("common.items.npc_armor.biped_small.adlet.hand.adlet_bow"),
|
||||
"feet": Item("common.items.npc_armor.biped_small.adlet.foot.adlet"),
|
||||
"chest": Item("common.items.npc_armor.biped_small.adlet.chest.adlet_bow"),
|
||||
"pants": Item("common.items.npc_armor.biped_small.adlet.pants.adlet_bow"),
|
||||
"belt": Item("common.items.npc_armor.biped_small.adlet.tail.adlet"),
|
||||
Armor(Head): Item("common.items.npc_armor.biped_small.adlet.head.adlet_bow"),
|
||||
Armor(Hands): Item("common.items.npc_armor.biped_small.adlet.hand.adlet_bow"),
|
||||
Armor(Feet): Item("common.items.npc_armor.biped_small.adlet.foot.adlet"),
|
||||
Armor(Chest): Item("common.items.npc_armor.biped_small.adlet.chest.adlet_bow"),
|
||||
Armor(Legs): Item("common.items.npc_armor.biped_small.adlet.pants.adlet_bow"),
|
||||
Armor(Belt): Item("common.items.npc_armor.biped_small.adlet.tail.adlet"),
|
||||
})
|
||||
|
@ -1,8 +1,8 @@
|
||||
({
|
||||
"head": Item("common.items.npc_armor.biped_small.adlet.head.adlet_spear"),
|
||||
"hands": Item("common.items.npc_armor.biped_small.adlet.hand.adlet_spear"),
|
||||
"feet": Item("common.items.npc_armor.biped_small.adlet.foot.adlet"),
|
||||
"chest": Item("common.items.npc_armor.biped_small.adlet.chest.adlet_spear"),
|
||||
"pants": Item("common.items.npc_armor.biped_small.adlet.pants.adlet_spear"),
|
||||
"belt": Item("common.items.npc_armor.biped_small.adlet.tail.adlet"),
|
||||
Armor(Head): Item("common.items.npc_armor.biped_small.adlet.head.adlet_spear"),
|
||||
Armor(Hands): Item("common.items.npc_armor.biped_small.adlet.hand.adlet_spear"),
|
||||
Armor(Feet): Item("common.items.npc_armor.biped_small.adlet.foot.adlet"),
|
||||
Armor(Chest): Item("common.items.npc_armor.biped_small.adlet.chest.adlet_spear"),
|
||||
Armor(Legs): Item("common.items.npc_armor.biped_small.adlet.pants.adlet_spear"),
|
||||
Armor(Belt): Item("common.items.npc_armor.biped_small.adlet.tail.adlet"),
|
||||
})
|
||||
|
@ -1,8 +1,8 @@
|
||||
({
|
||||
"head": Item("common.items.npc_armor.biped_small.sahagin.head.sahagin"),
|
||||
"feet": Item("common.items.npc_armor.biped_small.sahagin.foot.sahagin"),
|
||||
"hands": Item("common.items.npc_armor.biped_small.sahagin.hand.sahagin"),
|
||||
"chest": Item("common.items.npc_armor.biped_small.sahagin.chest.sahagin"),
|
||||
"pants": Item("common.items.npc_armor.biped_small.sahagin.pants.sahagin"),
|
||||
"belt": Item("common.items.npc_armor.biped_small.sahagin.tail.sahagin"),
|
||||
Armor(Head): Item("common.items.npc_armor.biped_small.sahagin.head.sahagin"),
|
||||
Armor(Feet): Item("common.items.npc_armor.biped_small.sahagin.foot.sahagin"),
|
||||
Armor(Hands): Item("common.items.npc_armor.biped_small.sahagin.hand.sahagin"),
|
||||
Armor(Chest): Item("common.items.npc_armor.biped_small.sahagin.chest.sahagin"),
|
||||
Armor(Legs): Item("common.items.npc_armor.biped_small.sahagin.pants.sahagin"),
|
||||
Armor(Belt): Item("common.items.npc_armor.biped_small.sahagin.tail.sahagin"),
|
||||
})
|
||||
|
@ -1,7 +1,7 @@
|
||||
({
|
||||
"head": Item("common.items.npc_armor.biped_small.haniwa.head.haniwa"),
|
||||
"feet": Item("common.items.npc_armor.biped_small.haniwa.foot.haniwa"),
|
||||
"hands": Item("common.items.npc_armor.biped_small.haniwa.hand.haniwa"),
|
||||
"chest": Item("common.items.npc_armor.biped_small.haniwa.chest.haniwa"),
|
||||
"pants": Item("common.items.npc_armor.biped_small.haniwa.pants.haniwa"),
|
||||
Armor(Head): Item("common.items.npc_armor.biped_small.haniwa.head.haniwa"),
|
||||
Armor(Feet): Item("common.items.npc_armor.biped_small.haniwa.foot.haniwa"),
|
||||
Armor(Hands): Item("common.items.npc_armor.biped_small.haniwa.hand.haniwa"),
|
||||
Armor(Chest): Item("common.items.npc_armor.biped_small.haniwa.chest.haniwa"),
|
||||
Armor(Legs): Item("common.items.npc_armor.biped_small.haniwa.pants.haniwa"),
|
||||
})
|
||||
|
@ -1,8 +1,8 @@
|
||||
({
|
||||
"head": Item("common.items.npc_armor.biped_small.myrmidon.head.myrmidon"),
|
||||
"feet": Item("common.items.npc_armor.biped_small.myrmidon.foot.myrmidon"),
|
||||
"hands": Item("common.items.npc_armor.biped_small.myrmidon.hand.myrmidon"),
|
||||
"chest": Item("common.items.npc_armor.biped_small.myrmidon.chest.myrmidon"),
|
||||
"pants": Item("common.items.npc_armor.biped_small.myrmidon.pants.myrmidon"),
|
||||
"belt": Item("common.items.npc_armor.biped_small.myrmidon.tail.myrmidon"),
|
||||
Armor(Head): Item("common.items.npc_armor.biped_small.myrmidon.head.myrmidon"),
|
||||
Armor(Feet): Item("common.items.npc_armor.biped_small.myrmidon.foot.myrmidon"),
|
||||
Armor(Hands): Item("common.items.npc_armor.biped_small.myrmidon.hand.myrmidon"),
|
||||
Armor(Chest): Item("common.items.npc_armor.biped_small.myrmidon.chest.myrmidon"),
|
||||
Armor(Legs): Item("common.items.npc_armor.biped_small.myrmidon.pants.myrmidon"),
|
||||
Armor(Belt): Item("common.items.npc_armor.biped_small.myrmidon.tail.myrmidon"),
|
||||
})
|
||||
|
@ -1,17 +1,17 @@
|
||||
({
|
||||
"shoulder": Item("common.items.armor.ferocious.shoulder"),
|
||||
"chest": Item("common.items.armor.ferocious.chest"),
|
||||
"belt": Item("common.items.armor.ferocious.belt"),
|
||||
"hands": Item("common.items.armor.ferocious.hand"),
|
||||
"pants": Item("common.items.armor.ferocious.pants"),
|
||||
"feet": Item("common.items.armor.ferocious.foot"),
|
||||
Armor(Shoulders): Item("common.items.armor.ferocious.shoulder"),
|
||||
Armor(Chest): Item("common.items.armor.ferocious.chest"),
|
||||
Armor(Belt): Item("common.items.armor.ferocious.belt"),
|
||||
Armor(Hands): Item("common.items.armor.ferocious.hand"),
|
||||
Armor(Legs): Item("common.items.armor.ferocious.pants"),
|
||||
Armor(Feet): Item("common.items.armor.ferocious.foot"),
|
||||
|
||||
"back": Item("common.items.armor.ferocious.back"),
|
||||
Armor(Back): Item("common.items.armor.ferocious.back"),
|
||||
|
||||
"lantern": Choice([
|
||||
Lantern: Choice([
|
||||
(1.0, Some(Item("common.items.lantern.black_0"))),
|
||||
(2.0, None),
|
||||
]),
|
||||
|
||||
"glider": Item("common.items.glider.glider_blue"),
|
||||
Glider: Item("common.items.glider.glider_blue"),
|
||||
})
|
||||
|
@ -1,7 +1,7 @@
|
||||
({
|
||||
"head": Item("common.items.npc_armor.biped_small.husk.head.husk"),
|
||||
"feet": Item("common.items.npc_armor.biped_small.husk.foot.husk"),
|
||||
"hands": Item("common.items.npc_armor.biped_small.husk.hand.husk"),
|
||||
"chest": Item("common.items.npc_armor.biped_small.husk.chest.husk"),
|
||||
"pants": Item("common.items.npc_armor.biped_small.husk.pants.husk"),
|
||||
Armor(Head): Item("common.items.npc_armor.biped_small.husk.head.husk"),
|
||||
Armor(Feet): Item("common.items.npc_armor.biped_small.husk.foot.husk"),
|
||||
Armor(Hands): Item("common.items.npc_armor.biped_small.husk.hand.husk"),
|
||||
Armor(Chest): Item("common.items.npc_armor.biped_small.husk.chest.husk"),
|
||||
Armor(Legs): Item("common.items.npc_armor.biped_small.husk.pants.husk"),
|
||||
})
|
||||
|
@ -1,17 +1,17 @@
|
||||
({
|
||||
"shoulder": Item("common.items.armor.warlock.shoulder"),
|
||||
"chest": Item("common.items.armor.warlock.chest"),
|
||||
"belt": Item("common.items.armor.warlock.belt"),
|
||||
"hands": Item("common.items.armor.warlock.hand"),
|
||||
"pants": Item("common.items.armor.warlock.pants"),
|
||||
"feet": Item("common.items.armor.warlock.foot"),
|
||||
Armor(Shoulders): Item("common.items.armor.warlock.shoulder"),
|
||||
Armor(Chest): Item("common.items.armor.warlock.chest"),
|
||||
Armor(Belt): Item("common.items.armor.warlock.belt"),
|
||||
Armor(Hands): Item("common.items.armor.warlock.hand"),
|
||||
Armor(Legs): Item("common.items.armor.warlock.pants"),
|
||||
Armor(Feet): Item("common.items.armor.warlock.foot"),
|
||||
|
||||
"back": Item("common.items.armor.warlock.back"),
|
||||
Armor(Back): Item("common.items.armor.warlock.back"),
|
||||
|
||||
"lantern": Choice([
|
||||
Lantern: Choice([
|
||||
(1.0, Some(Item("common.items.lantern.black_0"))),
|
||||
(2.0, None),
|
||||
]),
|
||||
|
||||
"glider": Item("common.items.glider.glider_purp"),
|
||||
Glider: Item("common.items.glider.glider_purp"),
|
||||
})
|
||||
|
@ -1,17 +1,17 @@
|
||||
({
|
||||
"shoulder": Item("common.items.armor.warlord.shoulder"),
|
||||
"chest": Item("common.items.armor.warlord.chest"),
|
||||
"belt": Item("common.items.armor.warlord.belt"),
|
||||
"hands": Item("common.items.armor.warlord.hand"),
|
||||
"pants": Item("common.items.armor.warlord.pants"),
|
||||
"feet": Item("common.items.armor.warlord.foot"),
|
||||
Armor(Shoulders): Item("common.items.armor.warlord.shoulder"),
|
||||
Armor(Chest): Item("common.items.armor.warlord.chest"),
|
||||
Armor(Belt): Item("common.items.armor.warlord.belt"),
|
||||
Armor(Hands): Item("common.items.armor.warlord.hand"),
|
||||
Armor(Legs): Item("common.items.armor.warlord.pants"),
|
||||
Armor(Feet): Item("common.items.armor.warlord.foot"),
|
||||
|
||||
"back": Item("common.items.armor.warlord.back"),
|
||||
Armor(Back): Item("common.items.armor.warlord.back"),
|
||||
|
||||
"lantern": Choice([
|
||||
Lantern: Choice([
|
||||
(1.0, Some(Item("common.items.lantern.black_0"))),
|
||||
(2.0, None),
|
||||
]),
|
||||
|
||||
"glider": Item("common.items.glider.glider_purp"),
|
||||
Glider: Item("common.items.glider.glider_purp"),
|
||||
})
|
||||
|
@ -1,12 +1,12 @@
|
||||
({
|
||||
"shoulder": Item("common.items.armor.leather_plate.shoulder"),
|
||||
"chest": Item("common.items.armor.leather_plate.chest"),
|
||||
"belt": Item("common.items.armor.leather_plate.belt"),
|
||||
"hands": Item("common.items.armor.leather_plate.hand"),
|
||||
"pants": Item("common.items.armor.leather_plate.pants"),
|
||||
"feet": Item("common.items.armor.leather_plate.foot"),
|
||||
Armor(Shoulders): Item("common.items.armor.leather_plate.shoulder"),
|
||||
Armor(Chest): Item("common.items.armor.leather_plate.chest"),
|
||||
Armor(Belt): Item("common.items.armor.leather_plate.belt"),
|
||||
Armor(Hands): Item("common.items.armor.leather_plate.hand"),
|
||||
Armor(Legs): Item("common.items.armor.leather_plate.pants"),
|
||||
Armor(Feet): Item("common.items.armor.leather_plate.foot"),
|
||||
|
||||
"lantern": Choice([
|
||||
Lantern: Choice([
|
||||
(1.0, Some(Item("common.items.lantern.black_0"))),
|
||||
(2.0, None),
|
||||
]),
|
||||
|
@ -1,13 +1,13 @@
|
||||
({
|
||||
"shoulder": Item("common.items.armor.twigsflowers.shoulder"),
|
||||
"chest": Item("common.items.armor.twigsflowers.chest"),
|
||||
"hands": Item("common.items.armor.twigsflowers.hand"),
|
||||
"pants": Item("common.items.armor.twigsflowers.pants"),
|
||||
"feet": Item("common.items.armor.twigsflowers.foot"),
|
||||
"belt": Item("common.items.armor.twigsflowers.belt"),
|
||||
Armor(Shoulders): Item("common.items.armor.twigsflowers.shoulder"),
|
||||
Armor(Chest): Item("common.items.armor.twigsflowers.chest"),
|
||||
Armor(Hands): Item("common.items.armor.twigsflowers.hand"),
|
||||
Armor(Legs): Item("common.items.armor.twigsflowers.pants"),
|
||||
Armor(Feet): Item("common.items.armor.twigsflowers.foot"),
|
||||
Armor(Belt): Item("common.items.armor.twigsflowers.belt"),
|
||||
|
||||
"lantern": Item("common.items.lantern.black_0"),
|
||||
"neck": Item("common.items.armor.misc.neck.plain_1"),
|
||||
"ring1": Item("common.items.armor.misc.ring.gold"),
|
||||
"ring2": Item("common.items.armor.misc.ring.gold"),
|
||||
Lantern: Item("common.items.lantern.black_0"),
|
||||
Armor(Neck): Item("common.items.armor.misc.neck.plain_1"),
|
||||
Armor(Ring1): Item("common.items.armor.misc.ring.gold"),
|
||||
Armor(Ring2): Item("common.items.armor.misc.ring.gold"),
|
||||
})
|
||||
|
@ -1,5 +1,5 @@
|
||||
({
|
||||
"chest": Choice([
|
||||
Armor(Chest): Choice([
|
||||
(1.0, Some(Item("common.items.armor.misc.chest.worker_green_0"))),
|
||||
(1.0, Some(Item("common.items.armor.misc.chest.worker_green_1"))),
|
||||
(1.0, Some(Item("common.items.armor.misc.chest.worker_red_0"))),
|
||||
@ -12,10 +12,10 @@
|
||||
(1.0, Some(Item("common.items.armor.misc.chest.worker_orange_1"))),
|
||||
]),
|
||||
|
||||
"belt": Item("common.items.armor.swift.belt"),
|
||||
"pants": Item("common.items.armor.misc.pants.worker_blue"),
|
||||
Armor(Belt): Item("common.items.armor.swift.belt"),
|
||||
Armor(Legs): Item("common.items.armor.misc.pants.worker_blue"),
|
||||
|
||||
"feet": Choice([
|
||||
Armor(Feet): Choice([
|
||||
(1.0, Some(Item("common.items.armor.swift.foot"))),
|
||||
(1.0, Some(Item("common.items.armor.misc.foot.sandals"))),
|
||||
]),
|
||||
|
@ -401,9 +401,9 @@ impl LoadoutBuilder {
|
||||
loadout = loadout.glider(Some(item));
|
||||
},
|
||||
EquipSlot::Armor(slot @ ArmorSlot::Bag1)
|
||||
| EquipSlot::Armor(slot @ ArmorSlot::Bag2)
|
||||
| EquipSlot::Armor(slot @ ArmorSlot::Bag3)
|
||||
| EquipSlot::Armor(slot @ ArmorSlot::Bag4) => {
|
||||
| EquipSlot::Armor(slot @ ArmorSlot::Bag2)
|
||||
| EquipSlot::Armor(slot @ ArmorSlot::Bag3)
|
||||
| EquipSlot::Armor(slot @ ArmorSlot::Bag4) => {
|
||||
loadout = loadout.bag(slot, Some(item));
|
||||
},
|
||||
};
|
||||
@ -760,16 +760,16 @@ impl LoadoutBuilder {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::comp::{self, Body};
|
||||
use crate::{
|
||||
assets::{AssetExt, Error},
|
||||
comp::{self, Body},
|
||||
};
|
||||
use rand::thread_rng;
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
// Testing all configs in loadout with weapons of different toolkinds
|
||||
//
|
||||
// Things that will be catched - invalid assets paths
|
||||
// FIXME: if item is used in some branch of rng test may miss it
|
||||
// TODO: as of now there is no rng generation of items.
|
||||
// Validate assets for all possible branches
|
||||
#[test]
|
||||
fn test_loadout_configs() {
|
||||
let test_weapons = vec![
|
||||
@ -852,5 +852,62 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_loadout_assets() { LoadoutBuilder::from_asset_expect("common.loadouts.test"); }
|
||||
fn test_loadout_asset() { LoadoutBuilder::from_asset_expect("common.loadouts.test"); }
|
||||
|
||||
#[test]
|
||||
fn test_all_loadout_assets() {
|
||||
#[derive(Clone)]
|
||||
struct LoadoutsList(Vec<LoadoutSpec>);
|
||||
impl assets::Compound for LoadoutsList {
|
||||
fn load<S: assets::source::Source>(
|
||||
cache: &assets::AssetCache<S>,
|
||||
specifier: &str,
|
||||
) -> Result<Self, Error> {
|
||||
let list = cache
|
||||
.load::<assets::Directory>(specifier)?
|
||||
.read()
|
||||
.iter()
|
||||
.map(|spec| LoadoutSpec::load_cloned(spec))
|
||||
.collect::<Result<_, Error>>()?;
|
||||
|
||||
Ok(LoadoutsList(list))
|
||||
}
|
||||
}
|
||||
|
||||
// It just load everything that could
|
||||
// TODO: add some checks, e.g. that Armor(Head) key correspond
|
||||
// to Item with ItemKind Head(_)
|
||||
fn validate_asset(loadout: LoadoutSpec) {
|
||||
let spec = loadout.0.clone();
|
||||
for (key, specifier) in spec {
|
||||
match specifier {
|
||||
ItemSpec::Item(specifier) => {
|
||||
Item::new_from_asset_expect(&specifier);
|
||||
},
|
||||
ItemSpec::Choice(ref items) => {
|
||||
for item in items {
|
||||
match item {
|
||||
(_, Some(ItemSpec::Item(specifier))) => {
|
||||
Item::new_from_asset_expect(&specifier);
|
||||
},
|
||||
(_, None) => {},
|
||||
(_, _) => {
|
||||
panic!(
|
||||
"\n\nChoice of Choice is unimplemented. (Search for \n{:?}: \
|
||||
{:#?})\n\n",
|
||||
key, specifier,
|
||||
);
|
||||
},
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
let loadouts = LoadoutsList::load_expect_cloned("common.loadouts.*").0;
|
||||
for loadout in loadouts {
|
||||
validate_asset(loadout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user