Skip to content

Commit

Permalink
test(wm): add backwards compat integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
LGUG2Z committed Jan 12, 2025
1 parent a069db6 commit eb6e12e
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 144 deletions.
1 change: 1 addition & 0 deletions .github/workflows/windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
key: ${{ matrix.platform.target }}
- run: cargo +nightly fmt --check
- run: cargo clippy
- run: cargo test --package komorebi --test compat
- uses: houseabsolute/actions-rust-cross@v1
with:
command: "build"
Expand Down
147 changes: 3 additions & 144 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions komorebi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,8 @@ winreg = "0.53"
[build-dependencies]
shadow-rs = { workspace = true }

[dev-dependencies]
reqwest = { version = "0.12", features = ["blocking"] }

[features]
deadlock_detection = ["parking_lot/deadlock_detection"]
4 changes: 4 additions & 0 deletions komorebi/src/static_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,10 @@ impl StaticConfig {
Ok(())
}

pub fn read_raw(raw: &str) -> Result<Self> {
Ok(serde_json::from_str(raw)?)
}

pub fn read(path: &PathBuf) -> Result<Self> {
let content = std::fs::read_to_string(path)?;
let mut value: Self = serde_json::from_str(&content)?;
Expand Down
29 changes: 29 additions & 0 deletions komorebi/tests/compat.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use komorebi::StaticConfig;

#[test]
fn backwards_compat() {
let root = vec!["0.1.17", "0.1.18", "0.1.19"];
let docs = vec![
"0.1.20", "0.1.21", "0.1.22", "0.1.23", "0.1.24", "0.1.25", "0.1.26", "0.1.27", "0.1.28",
"0.1.29", "0.1.30", "0.1.31", "0.1.32", "0.1.33",
];

let mut versions = vec![];

let client = reqwest::blocking::Client::new();

for version in root {
let request = client.get(format!("https://raw.githubusercontent.com/LGUG2Z/komorebi/refs/tags/v{version}/komorebi.example.json")).header("User-Agent", "komorebi-backwards-compat-test").build().unwrap();
versions.push((version, client.execute(request).unwrap().text().unwrap()));
}

for version in docs {
let request = client.get(format!("https://raw.githubusercontent.com/LGUG2Z/komorebi/refs/tags/v{version}/docs/komorebi.example.json")).header("User-Agent", "komorebi-backwards-compat-test").build().unwrap();
versions.push((version, client.execute(request).unwrap().text().unwrap()));
}

for (version, config) in versions {
println!("{version}");
StaticConfig::read_raw(&config).unwrap();
}
}

0 comments on commit eb6e12e

Please sign in to comment.