diff --git a/crates/store/re_log_encoding/src/rrd/decoder/state_machine.rs b/crates/store/re_log_encoding/src/rrd/decoder/state_machine.rs index 436198ad6f4d..c068b3ae05b2 100644 --- a/crates/store/re_log_encoding/src/rrd/decoder/state_machine.rs +++ b/crates/store/re_log_encoding/src/rrd/decoder/state_machine.rs @@ -411,7 +411,7 @@ mod tests { row_id: *RowId::ZERO, info: StoreInfo { store_version: Some(CrateVersion::LOCAL), // Encoder sets the crate version - ..StoreInfo::testing() + ..StoreInfo::testing_with_recording_id("test_recording") }, }) } diff --git a/crates/store/re_log_types/src/lib.rs b/crates/store/re_log_types/src/lib.rs index 948ee21d9c38..8f98901291cc 100644 --- a/crates/store/re_log_types/src/lib.rs +++ b/crates/store/re_log_types/src/lib.rs @@ -617,9 +617,20 @@ impl StoreInfo { /// Creates a new store info for testing purposes. pub fn testing() -> Self { - // Don't use a version for testing since it may show up in snapshots that then would change on every version. + // Do not use a version since it breaks snapshot tests on every update otherwise. Self::new_unversioned( - StoreId::new(StoreKind::Recording, "test_app", "test_recording"), + StoreId::random(StoreKind::Recording, "test_app"), + StoreSource::Other("test".to_owned()), + ) + } + + /// Creates a new store info for testing purposes with a fixed store id. + /// + /// Most of the time we don't want to fix the store id since it is used as a key in static store subscribers. + pub fn testing_with_recording_id(recording_id: impl Into) -> Self { + // Do not use a version since it breaks snapshot tests on every update otherwise. + Self::new_unversioned( + StoreId::new(StoreKind::Recording, "test_app", recording_id), StoreSource::Other("test".to_owned()), ) } diff --git a/crates/viewer/re_recording_panel/tests/snapshot_tests.rs b/crates/viewer/re_recording_panel/tests/snapshot_tests.rs index b4e03604873f..05a9919b9190 100644 --- a/crates/viewer/re_recording_panel/tests/snapshot_tests.rs +++ b/crates/viewer/re_recording_panel/tests/snapshot_tests.rs @@ -1,13 +1,14 @@ #![cfg(feature = "testing")] use re_entity_db::EntityDb; -use re_log_types::{StoreId, StoreKind}; +use re_log_types::{StoreId, StoreInfo, StoreKind}; use re_recording_panel::data::RecordingPanelData; use re_test_context::TestContext; #[test] fn empty_context_test() { - let test_context = TestContext::new(); + let test_context = + TestContext::new_with_store_info(StoreInfo::testing_with_recording_id("test_recording")); let servers = re_redap_browser::RedapServers::default(); test_context.run_once_in_egui_central_panel(|ctx, _| { @@ -19,7 +20,8 @@ fn empty_context_test() { #[test] fn fake_local_and_example_recordings_test() { - let test_context = TestContext::new(); + let test_context = + TestContext::new_with_store_info(StoreInfo::testing_with_recording_id("test_recording")); let servers = re_redap_browser::RedapServers::default(); let mut store_hub = test_context.store_hub.lock(); diff --git a/crates/viewer/re_selection_panel/src/selection_panel.rs b/crates/viewer/re_selection_panel/src/selection_panel.rs index bd58730e8ac7..e8dcf5b2821d 100644 --- a/crates/viewer/re_selection_panel/src/selection_panel.rs +++ b/crates/viewer/re_selection_panel/src/selection_panel.rs @@ -1205,7 +1205,9 @@ mod tests { use super::*; fn get_test_context() -> TestContext { - let mut test_context = TestContext::new(); + let mut test_context = TestContext::new_with_store_info( + re_log_types::StoreInfo::testing_with_recording_id("test_recording"), + ); test_context.component_ui_registry = re_component_ui::create_component_ui_registry(); re_data_ui::register_component_uis(&mut test_context.component_ui_registry); test_context diff --git a/crates/viewer/re_test_context/src/lib.rs b/crates/viewer/re_test_context/src/lib.rs index 642345524b27..6a751b275cbb 100644 --- a/crates/viewer/re_test_context/src/lib.rs +++ b/crates/viewer/re_test_context/src/lib.rs @@ -110,9 +110,12 @@ impl Default for TestContext { impl TestContext { pub fn new() -> Self { + Self::new_with_store_info(StoreInfo::testing()) + } + + pub fn new_with_store_info(store_info: StoreInfo) -> Self { re_log::setup_logging(); - let store_info = StoreInfo::testing(); let application_id = store_info.application_id().clone(); let recording_store_id = store_info.store_id.clone(); let mut recording_store = EntityDb::new(recording_store_id.clone()); diff --git a/tests/rust/re_integration_test/src/kittest_harness_ext.rs b/tests/rust/re_integration_test/src/kittest_harness_ext.rs index 3175946d7682..d695c6b82fc5 100644 --- a/tests/rust/re_integration_test/src/kittest_harness_ext.rs +++ b/tests/rust/re_integration_test/src/kittest_harness_ext.rs @@ -245,7 +245,7 @@ impl<'h> HarnessExt<'h> for egui_kittest::Harness<'h, re_viewer::App> { let app = self.state_mut(); let store_hub = app.testonly_get_store_hub(); - let store_info = StoreInfo::testing(); + let store_info = StoreInfo::testing_with_recording_id("test_recording"); // Fixed id shouldn't cause any problems with store subscribers here since we tear down the entire application for every test. let application_id = store_info.application_id().clone(); let recording_store_id = store_info.store_id.clone(); let mut recording_store = EntityDb::new(recording_store_id.clone());