mirror of
https://github.com/Steffo99/patched-porobot.git
synced 2024-12-23 01:54:22 +00:00
Add more tests and fix things based on them
This commit is contained in:
parent
09a55bee68
commit
e933030b80
10 changed files with 256 additions and 8 deletions
|
@ -16,7 +16,7 @@ log = { version = "0.4.17" }
|
||||||
pretty_env_logger = { version = "0.4.0", optional = true }
|
pretty_env_logger = { version = "0.4.0", optional = true }
|
||||||
glob = { version = "0.3.0", optional = true }
|
glob = { version = "0.3.0", optional = true }
|
||||||
# schema
|
# schema
|
||||||
serde = { version = "1.0.140" }
|
serde = { version = "1.0.140", features = ["derive"] }
|
||||||
serde_json = { version = "1.0.82" }
|
serde_json = { version = "1.0.82" }
|
||||||
# search
|
# search
|
||||||
tantivy = { version = "0.18.0", optional = true }
|
tantivy = { version = "0.18.0", optional = true }
|
||||||
|
|
|
@ -25,4 +25,98 @@ pub struct CoreGlobals {
|
||||||
|
|
||||||
/// A [Vec] of all [CoreRarity]s in the game.
|
/// A [Vec] of all [CoreRarity]s in the game.
|
||||||
pub rarities: Vec<CoreRarity>,
|
pub rarities: Vec<CoreRarity>,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use crate::schema::corebundle::*;
|
||||||
|
use crate::schema::setbundle::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn deserialize() {
|
||||||
|
assert_eq!(
|
||||||
|
serde_json::de::from_str::<'static, CoreGlobals>(r#"
|
||||||
|
{
|
||||||
|
"vocabTerms": [
|
||||||
|
{
|
||||||
|
"description": "When you summon this, it gets its allegiance bonus if the top card of your deck matches its region.",
|
||||||
|
"name": "Allegiance",
|
||||||
|
"nameRef": "Allegiance"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"keywords": [
|
||||||
|
{
|
||||||
|
"description": "Inflicts damage beyond what would kill the target(s) to the enemy Nexus.",
|
||||||
|
"name": "Overwhelm",
|
||||||
|
"nameRef": "SpellOverwhelm"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"regions": [
|
||||||
|
{
|
||||||
|
"abbreviation": "NX",
|
||||||
|
"iconAbsolutePath": "http://dd.b.pvp.net/3_11_0/core/en_us/img/regions/icon-noxus.png",
|
||||||
|
"name": "Noxus",
|
||||||
|
"nameRef": "Noxus"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"spellSpeeds": [
|
||||||
|
{
|
||||||
|
"name": "Slow",
|
||||||
|
"nameRef": "Slow"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"rarities": [
|
||||||
|
{
|
||||||
|
"name": "COMMON",
|
||||||
|
"nameRef": "Common"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"sets": [
|
||||||
|
{
|
||||||
|
"iconAbsolutePath": "http://dd.b.pvp.net/3_11_0/core/en_us/img/sets/set3_crispmip.png",
|
||||||
|
"name": "Call of the Mountain",
|
||||||
|
"nameRef": "Set3"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
"#).unwrap(),
|
||||||
|
CoreGlobals {
|
||||||
|
vocab_terms: vec![
|
||||||
|
CoreVocabTerm {
|
||||||
|
vocabterm: "Allegiance".to_string(),
|
||||||
|
name: "Allegiance".to_string(),
|
||||||
|
description: "When you summon this, it gets its allegiance bonus if the top card of your deck matches its region.".to_string(),
|
||||||
|
}
|
||||||
|
],
|
||||||
|
keywords: vec![
|
||||||
|
CoreKeyword {
|
||||||
|
keyword: CardKeyword::SpellOverwhelm,
|
||||||
|
name: "Overwhelm".to_string(),
|
||||||
|
description: "Inflicts damage beyond what would kill the target(s) to the enemy Nexus.".to_string(),
|
||||||
|
}
|
||||||
|
],
|
||||||
|
regions: vec![
|
||||||
|
CoreRegion {
|
||||||
|
region: CardRegion::Noxus,
|
||||||
|
name: "Noxus".to_string(),
|
||||||
|
abbreviation: "NX".to_string(),
|
||||||
|
icon_png: "http://dd.b.pvp.net/3_11_0/core/en_us/img/regions/icon-noxus.png".to_string(),
|
||||||
|
}
|
||||||
|
],
|
||||||
|
spell_speeds: vec![
|
||||||
|
CoreSpellSpeed {
|
||||||
|
spell_speed: SpellSpeed::Slow,
|
||||||
|
name: "Slow".to_string(),
|
||||||
|
}
|
||||||
|
],
|
||||||
|
rarities: vec![
|
||||||
|
CoreRarity {
|
||||||
|
rarity: CardRarity::Common,
|
||||||
|
name: "COMMON".to_string(),
|
||||||
|
}
|
||||||
|
],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -15,3 +15,29 @@ pub struct CoreKeyword {
|
||||||
/// The description of the keyword, the text of the in-game tooltip.
|
/// The description of the keyword, the text of the in-game tooltip.
|
||||||
pub description: String,
|
pub description: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use crate::schema::setbundle::CardKeyword;
|
||||||
|
|
||||||
|
use super::CoreKeyword;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn deserialize() {
|
||||||
|
assert_eq!(
|
||||||
|
serde_json::de::from_str::<'static, CoreKeyword>(r#"
|
||||||
|
{
|
||||||
|
"description": "Inflicts damage beyond what would kill the target(s) to the enemy Nexus.",
|
||||||
|
"name": "Overwhelm",
|
||||||
|
"nameRef": "SpellOverwhelm"
|
||||||
|
}
|
||||||
|
"#).unwrap(),
|
||||||
|
CoreKeyword {
|
||||||
|
keyword: CardKeyword::SpellOverwhelm,
|
||||||
|
name: "Overwhelm".to_string(),
|
||||||
|
description: "Inflicts damage beyond what would kill the target(s) to the enemy Nexus.".to_string(),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -12,3 +12,27 @@ pub struct CoreRarity {
|
||||||
/// The localized name of the rarity.
|
/// The localized name of the rarity.
|
||||||
pub name: String,
|
pub name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use crate::schema::setbundle::CardRarity;
|
||||||
|
|
||||||
|
use super::CoreRarity;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn deserialize() {
|
||||||
|
assert_eq!(
|
||||||
|
serde_json::de::from_str::<'static, CoreRarity>(r#"
|
||||||
|
{
|
||||||
|
"name": "COMMON",
|
||||||
|
"nameRef": "Common"
|
||||||
|
}
|
||||||
|
"#).unwrap(),
|
||||||
|
CoreRarity {
|
||||||
|
rarity: CardRarity::Common,
|
||||||
|
name: "COMMON".to_string(),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -21,3 +21,31 @@ pub struct CoreRegion {
|
||||||
#[serde(rename = "iconAbsolutePath")]
|
#[serde(rename = "iconAbsolutePath")]
|
||||||
pub icon_png: String,
|
pub icon_png: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use crate::schema::setbundle::CardRegion;
|
||||||
|
|
||||||
|
use super::CoreRegion;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn deserialize() {
|
||||||
|
assert_eq!(
|
||||||
|
serde_json::de::from_str::<'static, CoreRegion>(r#"
|
||||||
|
{
|
||||||
|
"abbreviation": "NX",
|
||||||
|
"iconAbsolutePath": "http://dd.b.pvp.net/3_11_0/core/en_us/img/regions/icon-noxus.png",
|
||||||
|
"name": "Noxus",
|
||||||
|
"nameRef": "Noxus"
|
||||||
|
}
|
||||||
|
"#).unwrap(),
|
||||||
|
CoreRegion {
|
||||||
|
region: CardRegion::Noxus,
|
||||||
|
name: "Noxus".to_string(),
|
||||||
|
abbreviation: "NX".to_string(),
|
||||||
|
icon_png: "http://dd.b.pvp.net/3_11_0/core/en_us/img/regions/icon-noxus.png".to_string(),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -7,12 +7,38 @@ use crate::schema::setbundle::CardSet;
|
||||||
pub struct CoreSet {
|
pub struct CoreSet {
|
||||||
/// The [CardSet] these strings refer to.
|
/// The [CardSet] these strings refer to.
|
||||||
#[serde(rename = "nameRef")]
|
#[serde(rename = "nameRef")]
|
||||||
set: CardSet,
|
pub set: CardSet,
|
||||||
|
|
||||||
/// The localized name of the set.
|
/// The localized name of the set.
|
||||||
name: String,
|
pub name: String,
|
||||||
|
|
||||||
/// URL to the icon of the set in `.png` format.
|
/// URL to the icon of the set in `.png` format.
|
||||||
#[serde(rename = "iconAbsolutePath")]
|
#[serde(rename = "iconAbsolutePath")]
|
||||||
icon_png: String,
|
pub icon_png: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use crate::schema::setbundle::CardSet;
|
||||||
|
|
||||||
|
use super::CoreSet;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn deserialize() {
|
||||||
|
assert_eq!(
|
||||||
|
serde_json::de::from_str::<'static, CoreSet>(r#"
|
||||||
|
{
|
||||||
|
"iconAbsolutePath": "http://dd.b.pvp.net/3_11_0/core/en_us/img/sets/set3_crispmip.png",
|
||||||
|
"name": "Call of the Mountain",
|
||||||
|
"nameRef": "Set3"
|
||||||
|
}
|
||||||
|
"#).unwrap(),
|
||||||
|
CoreSet {
|
||||||
|
set: CardSet::CallOfTheMountain,
|
||||||
|
name: "Call of the Mountain".to_string(),
|
||||||
|
icon_png: "http://dd.b.pvp.net/3_11_0/core/en_us/img/sets/set3_crispmip.png".to_string(),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,3 +12,27 @@ pub struct CoreSpellSpeed {
|
||||||
/// The localized name of the spell speed.
|
/// The localized name of the spell speed.
|
||||||
pub name: String,
|
pub name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use crate::schema::setbundle::SpellSpeed;
|
||||||
|
|
||||||
|
use super::CoreSpellSpeed;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn deserialize() {
|
||||||
|
assert_eq!(
|
||||||
|
serde_json::de::from_str::<'static, CoreSpellSpeed>(r#"
|
||||||
|
{
|
||||||
|
"name": "Slow",
|
||||||
|
"nameRef": "Slow"
|
||||||
|
}
|
||||||
|
"#).unwrap(),
|
||||||
|
CoreSpellSpeed {
|
||||||
|
spell_speed: SpellSpeed::Slow,
|
||||||
|
name: "Slow".to_string(),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -19,4 +19,28 @@ pub struct CoreVocabTerm {
|
||||||
|
|
||||||
/// The description of the vocabulary term, the text of the in-game tooltip.
|
/// The description of the vocabulary term, the text of the in-game tooltip.
|
||||||
pub description: String,
|
pub description: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::CoreVocabTerm;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn deserialize() {
|
||||||
|
assert_eq!(
|
||||||
|
serde_json::de::from_str::<'static, CoreVocabTerm>(r#"
|
||||||
|
{
|
||||||
|
"description": "When you summon this, it gets its allegiance bonus if the top card of your deck matches its region.",
|
||||||
|
"name": "Allegiance",
|
||||||
|
"nameRef": "Allegiance"
|
||||||
|
}
|
||||||
|
"#).unwrap(),
|
||||||
|
CoreVocabTerm {
|
||||||
|
vocabterm: "Allegiance".to_string(),
|
||||||
|
name: "Allegiance".to_string(),
|
||||||
|
description: "When you summon this, it gets its allegiance bonus if the top card of your deck matches its region.".to_string(),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -120,9 +120,11 @@ pub struct Card {
|
||||||
pub(crate) associated_card_names_localized: Vec<String>,
|
pub(crate) associated_card_names_localized: Vec<String>,
|
||||||
|
|
||||||
/// Flavor text of the card, displayed when its image is inspected.
|
/// Flavor text of the card, displayed when its image is inspected.
|
||||||
|
#[serde(rename = "flavorText")]
|
||||||
pub flavor_text: String,
|
pub flavor_text: String,
|
||||||
|
|
||||||
/// Name of the artist who drew the card.
|
/// Name of the artist who drew the card.
|
||||||
|
#[serde(rename = "artistName")]
|
||||||
pub artist_name: String,
|
pub artist_name: String,
|
||||||
|
|
||||||
/// The subtypes the card has, such as `"PORO"`.
|
/// The subtypes the card has, such as `"PORO"`.
|
||||||
|
|
|
@ -49,9 +49,9 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
test_deserialization!(deserialize_none, r#""None""#, CardRarity::None);
|
test_deserialization!(deserialize_none, r#""None""#, CardRarity::None);
|
||||||
test_deserialization!(deserialize_common, r#""COMMON""#, CardRarity::Common);
|
test_deserialization!(deserialize_common, r#""Common""#, CardRarity::Common);
|
||||||
test_deserialization!(deserialize_rare, r#""RARE""#, CardRarity::Rare);
|
test_deserialization!(deserialize_rare, r#""Rare""#, CardRarity::Rare);
|
||||||
test_deserialization!(deserialize_epic, r#""EPIC""#, CardRarity::Epic);
|
test_deserialization!(deserialize_epic, r#""Epic""#, CardRarity::Epic);
|
||||||
test_deserialization!(deserialize_champion, r#""Champion""#, CardRarity::Champion);
|
test_deserialization!(deserialize_champion, r#""Champion""#, CardRarity::Champion);
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in a new issue