Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor refactor for insertion tests #324

Merged
merged 2 commits into from
Sep 3, 2024
Merged
Changes from all commits
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
43 changes: 20 additions & 23 deletions tests/insertion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn table_storage() {
..Default::default()
}),
))
.replicate::<TableComponent>();
.replicate::<DummyComponent>();
}

server_app.connect_client(&mut client_app);
Expand All @@ -39,15 +39,15 @@ fn table_storage() {
server_app
.world_mut()
.entity_mut(server_entity)
.insert(TableComponent);
.insert(DummyComponent);

server_app.update();
server_app.exchange_with_client(&mut client_app);
client_app.update();

client_app
.world_mut()
.query_filtered::<(), With<TableComponent>>()
.query_filtered::<(), With<DummyComponent>>()
.single(client_app.world());
}

Expand Down Expand Up @@ -346,18 +346,18 @@ fn not_replicated() {
server_app
.world_mut()
.entity_mut(server_entity)
.insert(NotReplicatedComponent);
.insert(DummyComponent);

server_app.update();
server_app.exchange_with_client(&mut client_app);
client_app.update();

let not_replicated_components = client_app
let components = client_app
.world_mut()
.query_filtered::<(), With<NotReplicatedComponent>>()
.query_filtered::<(), With<DummyComponent>>()
.iter(client_app.world())
.count();
assert_eq!(not_replicated_components, 0);
assert_eq!(components, 0);
}

#[test]
Expand All @@ -372,14 +372,14 @@ fn after_removal() {
..Default::default()
}),
))
.replicate::<TableComponent>();
.replicate::<DummyComponent>();
}

server_app.connect_client(&mut client_app);

let server_entity = server_app
.world_mut()
.spawn((Replicated, TableComponent))
.spawn((Replicated, DummyComponent))
.id();

server_app.update();
Expand All @@ -391,16 +391,16 @@ fn after_removal() {
server_app
.world_mut()
.entity_mut(server_entity)
.remove::<TableComponent>()
.insert(TableComponent);
.remove::<DummyComponent>()
.insert(DummyComponent);

server_app.update();
server_app.exchange_with_client(&mut client_app);
client_app.update();

client_app
.world_mut()
.query_filtered::<(), With<TableComponent>>()
.query_filtered::<(), With<DummyComponent>>()
.single(client_app.world());
}

Expand All @@ -417,12 +417,12 @@ fn before_started_replication() {
..Default::default()
}),
))
.replicate::<TableComponent>();
.replicate::<DummyComponent>();
}

server_app.connect_client(&mut client_app);

server_app.world_mut().spawn((Replicated, TableComponent));
server_app.world_mut().spawn((Replicated, DummyComponent));

server_app.update();
server_app.exchange_with_client(&mut client_app);
Expand All @@ -431,7 +431,7 @@ fn before_started_replication() {

let replicated_components = client_app
.world_mut()
.query_filtered::<(), With<TableComponent>>()
.query_filtered::<(), With<DummyComponent>>()
.iter(client_app.world())
.count();

Expand All @@ -453,7 +453,7 @@ fn before_started_replication() {

client_app
.world_mut()
.query_filtered::<(), With<TableComponent>>()
.query_filtered::<(), With<DummyComponent>>()
.single(client_app.world());
}

Expand All @@ -470,7 +470,7 @@ fn after_started_replication() {
..Default::default()
}),
))
.replicate::<TableComponent>();
.replicate::<DummyComponent>();
}

server_app.connect_client(&mut client_app);
Expand All @@ -486,7 +486,7 @@ fn after_started_replication() {
client_app.update();
server_app.exchange_with_client(&mut client_app);

server_app.world_mut().spawn((Replicated, TableComponent));
server_app.world_mut().spawn((Replicated, DummyComponent));

server_app.update();
server_app.exchange_with_client(&mut client_app);
Expand All @@ -495,7 +495,7 @@ fn after_started_replication() {

client_app
.world_mut()
.query_filtered::<(), With<TableComponent>>()
.query_filtered::<(), With<DummyComponent>>()
.single(client_app.world());
}

Expand All @@ -509,7 +509,7 @@ impl MapEntities for MappedComponent {
}

#[derive(Component, Deserialize, Serialize)]
struct TableComponent;
struct DummyComponent;

#[derive(Component, Deserialize, Serialize)]
#[component(storage = "SparseSet")]
Expand All @@ -521,9 +521,6 @@ struct GroupComponentA;
#[derive(Component, Deserialize, Serialize)]
struct GroupComponentB;

#[derive(Component, Deserialize, Serialize)]
struct NotReplicatedComponent;

#[derive(Component)]
struct ReplaceMarker;

Expand Down