Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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")
},
})
}
Expand Down
15 changes: 13 additions & 2 deletions crates/store/re_log_types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<RecordingId>) -> 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()),
)
}
Expand Down
8 changes: 5 additions & 3 deletions crates/viewer/re_recording_panel/tests/snapshot_tests.rs
Original file line number Diff line number Diff line change
@@ -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, _| {
Expand All @@ -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();
Expand Down
4 changes: 3 additions & 1 deletion crates/viewer/re_selection_panel/src/selection_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion crates/viewer/re_test_context/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion tests/rust/re_integration_test/src/kittest_harness_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Loading