test: add asset path validity tests

This commit is contained in:
2025-08-12 17:05:01 -05:00
parent be5eec64c9
commit 1529a64588
3 changed files with 16 additions and 2 deletions

View File

@@ -43,7 +43,6 @@ jobs:
- uses: taiki-e/install-action@cargo-llvm-cov - uses: taiki-e/install-action@cargo-llvm-cov
- uses: taiki-e/install-action@nextest - uses: taiki-e/install-action@nextest
# Note: We manually link zlib. This should be synchronized with the flags set for Linux in .cargo/config.toml.
- name: Generate coverage report - name: Generate coverage report
run: | run: |
cargo llvm-cov --no-fail-fast --lcov --output-path lcov.info nextest cargo llvm-cov --no-fail-fast --lcov --output-path lcov.info nextest

View File

@@ -3,8 +3,9 @@
//! On desktop, assets are embedded using include_bytes!; on Emscripten, assets are loaded from the filesystem. //! On desktop, assets are embedded using include_bytes!; on Emscripten, assets are loaded from the filesystem.
use std::borrow::Cow; use std::borrow::Cow;
use strum_macros::EnumIter;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, EnumIter)]
pub enum Asset { pub enum Asset {
Wav1, Wav1,
Wav2, Wav2,

14
tests/asset.rs Normal file
View File

@@ -0,0 +1,14 @@
use pacman::asset::Asset;
use std::path::Path;
use strum::IntoEnumIterator;
#[test]
fn test_asset_paths_valid() {
let base_path = Path::new("assets/game/");
for asset in Asset::iter() {
let path = base_path.join(asset.path());
assert!(path.exists(), "Asset path does not exist: {:?}", path);
assert!(path.is_file(), "Asset path is not a file: {:?}", path);
}
}