Skip to content

Commit c3bbb8d

Browse files
committed
Move TrivialLoader out of a test so it can be reused in other tests.
1 parent 8c8a0f7 commit c3bbb8d

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

crates/bevy_asset/src/lib.rs

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2574,31 +2574,32 @@ mod tests {
25742574
assert_eq!(get_started_load_count(app.world()), 2);
25752575
}
25762576

2577-
#[test]
2578-
fn get_strong_handle_prevents_reload_when_asset_still_alive() {
2579-
let (mut app, dir) = create_app();
2580-
dir.insert_asset(Path::new("test.txt"), &[]);
2581-
2582-
struct TrivialLoader;
2577+
/// A loader that immediately returns a [`TestAsset`].
2578+
struct TrivialLoader;
25832579

2584-
impl AssetLoader for TrivialLoader {
2585-
type Asset = TestAsset;
2586-
type Settings = ();
2587-
type Error = std::io::Error;
2580+
impl AssetLoader for TrivialLoader {
2581+
type Asset = TestAsset;
2582+
type Settings = ();
2583+
type Error = std::io::Error;
25882584

2589-
async fn load(
2590-
&self,
2591-
_reader: &mut dyn Reader,
2592-
_settings: &Self::Settings,
2593-
_load_context: &mut LoadContext<'_>,
2594-
) -> Result<Self::Asset, Self::Error> {
2595-
Ok(TestAsset)
2596-
}
2585+
async fn load(
2586+
&self,
2587+
_reader: &mut dyn Reader,
2588+
_settings: &Self::Settings,
2589+
_load_context: &mut LoadContext<'_>,
2590+
) -> Result<Self::Asset, Self::Error> {
2591+
Ok(TestAsset)
2592+
}
25972593

2598-
fn extensions(&self) -> &[&str] {
2599-
&["txt"]
2600-
}
2594+
fn extensions(&self) -> &[&str] {
2595+
&["txt"]
26012596
}
2597+
}
2598+
2599+
#[test]
2600+
fn get_strong_handle_prevents_reload_when_asset_still_alive() {
2601+
let (mut app, dir) = create_app();
2602+
dir.insert_asset(Path::new("test.txt"), &[]);
26022603

26032604
app.init_asset::<TestAsset>()
26042605
.register_asset_loader(TrivialLoader);

0 commit comments

Comments
 (0)