Skip to content

Commit 9d6d4fd

Browse files
committed
chore(formatting): undo some formatting to make PR smaller
Signed-off-by: Raphael Höser <[email protected]>
1 parent a6c814f commit 9d6d4fd

File tree

8 files changed

+74
-57
lines changed

8 files changed

+74
-57
lines changed

src/container.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,10 @@ impl ContainerBuilder {
137137
}
138138

139139
/// A running test container for the [EventSourcingDB](https://www.eventsourcingdb.io/).
140-
///
140+
///
141141
/// Aside from managing the container, this struct also provides methods to get the data needed to connect to
142142
/// the database or even a fully configured client.
143-
///
143+
///
144144
/// You'll most likely want to use the [`Container::start_default`] method to create a new container instance for your tests.
145145
/// For more details, see the [`crate::container`] module documentation.
146146
/// ```
@@ -167,7 +167,7 @@ impl Container {
167167
}
168168

169169
/// Shortcut method to start the container with default settings.
170-
///
170+
///
171171
/// This is the same as calling [`Container::builder`] and then [`ContainerBuilder::start`].
172172
/// In most cases this will create a contaienr with the latest image tag and a working configuration.
173173
///
@@ -178,7 +178,7 @@ impl Container {
178178
}
179179

180180
/// Get the host of the container.
181-
///
181+
///
182182
/// This is the host that you can use to connect to the database. In most cases this will be `localhost`.
183183
///
184184
/// # Errors
@@ -188,7 +188,7 @@ impl Container {
188188
}
189189

190190
/// Get the mapped port for the database.
191-
///
191+
///
192192
/// This is the port that you can use to connect to the database. This will be a random port that is mapped to the internal port configured via [`ContainerBuilder::with_port`].
193193
///
194194
/// # Errors

src/event.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ pub use event_types::event_candidate::EventCandidate;
1010
pub use event_types::management_event::ManagementEvent;
1111
pub use trace_info::TraceInfo;
1212

13-
#[cfg(feature = "cloudevents")]
13+
#[cfg(feature="cloudevents")]
1414
use crate::error::EventError;

src/event/event_types/event.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ use chrono::{DateTime, Utc};
22
use serde::{Deserialize, Serialize};
33
use serde_json::Value;
44

5-
use crate::event::{EventCandidate, trace_info::TraceInfo};
5+
use crate::event::{trace_info::TraceInfo, EventCandidate};
6+
67

78
/// Represents an event that has been received from the DB.
89
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]

src/event/event_types/event_candidate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use crate::event::trace_info::TraceInfo;
21
use serde::{Deserialize, Serialize};
32
use serde_json::Value;
43
use typed_builder::TypedBuilder;
4+
use crate::event::trace_info::TraceInfo;
55

66
#[cfg(feature = "cloudevents")]
77
use crate::error::EventError;

src/event/event_types/management_event.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
use chrono::{DateTime, Utc};
21
use serde::{Deserialize, Serialize};
32
use serde_json::Value;
3+
use chrono::{DateTime, Utc};
44

55
/// Represents a management event that has been received from the DB.
6-
///
6+
///
77
/// For management requests like [`crate::client::Client::ping`] and [`crate::client::Client::verify_api_token`] the DB will send a management event.
8-
///
8+
///
99
/// Compared to a normal Event, this does not contain the following fields:
1010
/// - hash
1111
/// - predecessorhash
@@ -18,7 +18,7 @@ pub struct ManagementEvent {
1818
source: String,
1919
specversion: String,
2020
subject: String,
21-
time: DateTime<Utc>,
21+
time: DateTime<Utc>,
2222
r#type: String,
2323
}
2424

@@ -61,7 +61,7 @@ impl ManagementEvent {
6161
&self.time
6262
}
6363
/// Get the type of an event.
64-
///
64+
///
6565
/// This method is called `ty` to avoid conflicts with the `type` keyword in Rust.
6666
#[must_use]
6767
pub fn ty(&self) -> &str {

src/event/trace_info.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use serde::{Deserialize, Serialize};
1010
pub enum TraceInfo {
1111
// LEAVE ORDER AS IS
1212
// This is important for deserialization as the traceparent is always present
13+
1314
/// The traceparent and tracestate of the event.
1415
/// This is used for distributed tracing.
1516
WithState {
@@ -51,7 +52,7 @@ impl TraceInfo {
5152
///
5253
/// # Errors
5354
/// If the cloudevent contains a tracestate but no traceparent, an error will be returned.
54-
#[cfg(feature = "cloudevents")]
55+
#[cfg(feature="cloudevents")]
5556
pub fn from_cloudevent(event: &cloudevents::Event) -> Result<Option<Self>, EventError> {
5657
let traceparent = event.extension("traceparent").map(ToString::to_string);
5758
let tracestate = event.extension("tracestate").map(ToString::to_string);

tests/essentials.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ async fn ping_unavailable_server_errors() {
1818
async fn verify_api_token() {
1919
let container = Container::start_default().await.unwrap();
2020
let client = container.get_client().await.unwrap();
21-
client
22-
.verify_api_token()
23-
.await
24-
.expect("Failed to verify API token");
21+
client.verify_api_token().await.expect("Failed to verify API token");
2522
}
2623

2724
#[tokio::test]

tests/write_events.rs

Lines changed: 57 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
mod utils;
22

33
use eventsourcingdb_client_rust::{
4-
client::Precondition,
5-
container::Container,
6-
event::{EventCandidate, TraceInfo},
4+
client::Precondition, container::Container, event::{EventCandidate, TraceInfo}
75
};
86
use serde_json::json;
97
use utils::{
@@ -48,9 +46,11 @@ async fn write_event_with_is_pristine_condition_on_empty_subject() {
4846
let result = client
4947
.write_events(
5048
vec![event_candidate.clone()],
51-
vec![Precondition::IsSubjectPristine {
52-
subject: event_candidate.subject.clone(),
53-
}],
49+
vec![
50+
Precondition::IsSubjectPristine {
51+
subject: event_candidate.subject.clone(),
52+
},
53+
],
5454
)
5555
.await;
5656
assert!(result.is_ok(), "Failed to write events: {:?}", result);
@@ -74,9 +74,11 @@ async fn write_event_with_is_pristine_condition_on_non_empty_subject() {
7474
let result = client
7575
.write_events(
7676
vec![event_candidate.clone()],
77-
vec![Precondition::IsSubjectPristine {
78-
subject: event_candidate.subject.clone(),
79-
}],
77+
vec![
78+
Precondition::IsSubjectPristine {
79+
subject: event_candidate.subject.clone(),
80+
},
81+
],
8082
)
8183
.await;
8284
assert!(result.is_err(), "Expected an error, but got: {:?}", result);
@@ -94,9 +96,11 @@ async fn write_events_with_is_pristine_condition_on_empty_subject() {
9496
let result = client
9597
.write_events(
9698
event_candidates.clone(),
97-
vec![Precondition::IsSubjectPristine {
98-
subject: event_candidates[1].subject.clone(),
99-
}],
99+
vec![
100+
Precondition::IsSubjectPristine {
101+
subject: event_candidates[1].subject.clone(),
102+
},
103+
],
100104
)
101105
.await;
102106
assert!(result.is_ok(), "Failed to write events: {:?}", result);
@@ -121,9 +125,11 @@ async fn write_events_with_is_pristine_condition_on_non_empty_subject() {
121125
let result = client
122126
.write_events(
123127
event_candidates,
124-
vec![Precondition::IsSubjectPristine {
125-
subject: fill_event_candidate.subject.clone(),
126-
}],
128+
vec![
129+
Precondition::IsSubjectPristine {
130+
subject: fill_event_candidate.subject.clone(),
131+
},
132+
],
127133
)
128134
.await;
129135
assert!(result.is_err(), "Expected an error, but got: {:?}", result);
@@ -138,10 +144,12 @@ async fn write_event_with_is_subject_on_event_id_condition_on_empty_subject() {
138144
let result = client
139145
.write_events(
140146
vec![event_candidate.clone()],
141-
vec![Precondition::IsSubjectOnEventId {
142-
subject: event_candidate.subject.clone(),
143-
event_id: "100".to_string(),
144-
}],
147+
vec![
148+
Precondition::IsSubjectOnEventId {
149+
subject: event_candidate.subject.clone(),
150+
event_id: "100".to_string(),
151+
},
152+
],
145153
)
146154
.await;
147155
assert!(result.is_err(), "Expected an error, but got: {:?}", result);
@@ -162,10 +170,12 @@ async fn write_event_with_is_subject_on_event_id_condition_on_non_empty_subject_
162170
let result = client
163171
.write_events(
164172
vec![event_candidate.clone()],
165-
vec![Precondition::IsSubjectOnEventId {
166-
subject: event_candidate.subject.clone(),
167-
event_id: written.id().to_string(),
168-
}],
173+
vec![
174+
Precondition::IsSubjectOnEventId {
175+
subject: event_candidate.subject.clone(),
176+
event_id: written.id().to_string(),
177+
},
178+
],
169179
)
170180
.await;
171181
assert!(result.is_ok(), "Writing the event failed: {:?}", result);
@@ -186,10 +196,12 @@ async fn write_event_with_is_subject_on_event_id_condition_on_non_empty_subject_
186196
let result = client
187197
.write_events(
188198
vec![event_candidate.clone()],
189-
vec![Precondition::IsSubjectOnEventId {
190-
subject: event_candidate.subject.clone(),
191-
event_id: 100.to_string(),
192-
}],
199+
vec![
200+
Precondition::IsSubjectOnEventId {
201+
subject: event_candidate.subject.clone(),
202+
event_id: 100.to_string(),
203+
},
204+
],
193205
)
194206
.await;
195207
assert!(result.is_err(), "Expected an error, but got: {:?}", result);
@@ -207,10 +219,12 @@ async fn write_events_with_is_subject_on_event_id_condition_on_empty_subject() {
207219
let result = client
208220
.write_events(
209221
event_candidates.clone(),
210-
vec![Precondition::IsSubjectOnEventId {
211-
subject: event_candidates[1].subject.clone(),
212-
event_id: "100".to_string(),
213-
}],
222+
vec![
223+
Precondition::IsSubjectOnEventId {
224+
subject: event_candidates[1].subject.clone(),
225+
event_id: "100".to_string(),
226+
},
227+
],
214228
)
215229
.await;
216230
assert!(result.is_err(), "Expected an error, but got: {:?}", result);
@@ -235,10 +249,12 @@ async fn write_events_with_is_subject_on_event_id_condition_on_non_empty_subject
235249
let result = client
236250
.write_events(
237251
event_candidates,
238-
vec![Precondition::IsSubjectOnEventId {
239-
subject: fill_event_candidate.subject.clone(),
240-
event_id: written.id().to_string(),
241-
}],
252+
vec![
253+
Precondition::IsSubjectOnEventId {
254+
subject: fill_event_candidate.subject.clone(),
255+
event_id: written.id().to_string(),
256+
},
257+
],
242258
)
243259
.await;
244260
assert!(result.is_ok(), "Writing the events failed: {:?}", result);
@@ -263,10 +279,12 @@ async fn write_events_with_is_subject_on_event_id_condition_on_non_empty_subject
263279
let result = client
264280
.write_events(
265281
event_candidates,
266-
vec![Precondition::IsSubjectOnEventId {
267-
subject: fill_event_candidate.subject.clone(),
268-
event_id: 100.to_string(),
269-
}],
282+
vec![
283+
Precondition::IsSubjectOnEventId {
284+
subject: fill_event_candidate.subject.clone(),
285+
event_id: 100.to_string(),
286+
},
287+
],
270288
)
271289
.await;
272290
assert!(result.is_err(), "Expected an error, but got: {:?}", result);

0 commit comments

Comments
 (0)