Skip to content

Commit 32c64e2

Browse files
committed
Fix old threshold migration
1 parent ff08d58 commit 32c64e2

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "reffect"
3-
version = "0.2.2"
3+
version = "0.2.3"
44
authors = ["Zerthox"]
55
edition = "2021"
66
description = "Customizable effect & resource displays"

src/trigger/progress/threshold/mod.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ use nexus::imgui::{ComboBoxFlags, Ui};
1313
use serde::{Deserialize, Serialize};
1414

1515
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
16-
#[serde(default)]
1716
pub struct ProgressThreshold {
1817
/// Threshold type.
1918
pub threshold_type: ThresholdType,
2019

2120
/// Amount type.
21+
#[serde(default)] // TODO: move up after migration period
2222
pub amount_type: AmountType,
2323
}
2424

@@ -72,3 +72,19 @@ impl RenderOptions for ProgressThreshold {
7272
}
7373
}
7474
}
75+
76+
#[cfg(test)]
77+
mod tests {
78+
use super::*;
79+
use crate::serde_migrate::Migrate;
80+
81+
#[test]
82+
fn migrate() {
83+
let old_json = "{ \"Between\": [1, 23] }";
84+
85+
let result = serde_json::from_str::<Migrate<ProgressThreshold, ThresholdType>>(&old_json);
86+
assert!(result.is_ok());
87+
let threshold = result.unwrap().inner;
88+
assert_eq!(threshold.threshold_type, ThresholdType::Between(1.0, 23.0));
89+
}
90+
}

src/trigger/progress/threshold/threshold_type.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
use serde::{Deserialize, Serialize};
22
use strum::{AsRefStr, EnumIter, IntoStaticStr, VariantArray};
33

4-
#[derive(Debug, Default, Clone, AsRefStr, IntoStaticStr, EnumIter, Serialize, Deserialize)]
4+
#[derive(
5+
Debug, Default, Clone, PartialEq, AsRefStr, IntoStaticStr, EnumIter, Serialize, Deserialize,
6+
)]
57
pub enum ThresholdType {
68
/// Always met.
79
Always,

0 commit comments

Comments
 (0)