Skip to content

Commit 9cbde95

Browse files
authored
Merge branch 'main' into metadata-and-discovery
2 parents 31b6bb4 + 0f3ab07 commit 9cbde95

File tree

9 files changed

+62
-75
lines changed

9 files changed

+62
-75
lines changed

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@ qa: analyze test
22

33
analyze:
44
@cargo clippy
5+
@cargo fmt --check
56

67
test:
78
@cargo test
89

9-
.PHONY: analyze qa test
10+
format:
11+
@cargo fmt
12+
13+
.PHONY: analyze format qa test

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: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ use chrono::{DateTime, Utc};
22
use serde::{Deserialize, Serialize};
33
use serde_json::Value;
44

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

87
/// Represents an event that has been received from the DB.
98
#[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;
12
use serde::{Deserialize, Serialize};
23
use serde_json::Value;
34
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};
12
use serde::{Deserialize, Serialize};
23
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: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ 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-
1413
/// The traceparent and tracestate of the event.
1514
/// This is used for distributed tracing.
1615
WithState {
@@ -52,7 +51,7 @@ impl TraceInfo {
5251
///
5352
/// # Errors
5453
/// If the cloudevent contains a tracestate but no traceparent, an error will be returned.
55-
#[cfg(feature="cloudevents")]
54+
#[cfg(feature = "cloudevents")]
5655
pub fn from_cloudevent(event: &cloudevents::Event) -> Result<Option<Self>, EventError> {
5756
let traceparent = event.extension("traceparent").map(ToString::to_string);
5857
let tracestate = event.extension("tracestate").map(ToString::to_string);

tests/essentials.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ 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.verify_api_token().await.expect("Failed to verify API token");
21+
client
22+
.verify_api_token()
23+
.await
24+
.expect("Failed to verify API token");
2225
}
2326

2427
#[tokio::test]

tests/write_events.rs

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

33
use eventsourcingdb_client_rust::{
4-
client::Precondition, container::Container, event::{EventCandidate, TraceInfo}
4+
client::Precondition,
5+
container::Container,
6+
event::{EventCandidate, TraceInfo},
57
};
68
use serde_json::json;
79
use utils::{
@@ -46,11 +48,9 @@ async fn write_event_with_is_pristine_condition_on_empty_subject() {
4648
let result = client
4749
.write_events(
4850
vec![event_candidate.clone()],
49-
vec![
50-
Precondition::IsSubjectPristine {
51-
subject: event_candidate.subject.clone(),
52-
},
53-
],
51+
vec![Precondition::IsSubjectPristine {
52+
subject: event_candidate.subject.clone(),
53+
}],
5454
)
5555
.await;
5656
assert!(result.is_ok(), "Failed to write events: {:?}", result);
@@ -74,11 +74,9 @@ 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![
78-
Precondition::IsSubjectPristine {
79-
subject: event_candidate.subject.clone(),
80-
},
81-
],
77+
vec![Precondition::IsSubjectPristine {
78+
subject: event_candidate.subject.clone(),
79+
}],
8280
)
8381
.await;
8482
assert!(result.is_err(), "Expected an error, but got: {:?}", result);
@@ -96,11 +94,9 @@ async fn write_events_with_is_pristine_condition_on_empty_subject() {
9694
let result = client
9795
.write_events(
9896
event_candidates.clone(),
99-
vec![
100-
Precondition::IsSubjectPristine {
101-
subject: event_candidates[1].subject.clone(),
102-
},
103-
],
97+
vec![Precondition::IsSubjectPristine {
98+
subject: event_candidates[1].subject.clone(),
99+
}],
104100
)
105101
.await;
106102
assert!(result.is_ok(), "Failed to write events: {:?}", result);
@@ -125,11 +121,9 @@ async fn write_events_with_is_pristine_condition_on_non_empty_subject() {
125121
let result = client
126122
.write_events(
127123
event_candidates,
128-
vec![
129-
Precondition::IsSubjectPristine {
130-
subject: fill_event_candidate.subject.clone(),
131-
},
132-
],
124+
vec![Precondition::IsSubjectPristine {
125+
subject: fill_event_candidate.subject.clone(),
126+
}],
133127
)
134128
.await;
135129
assert!(result.is_err(), "Expected an error, but got: {:?}", result);
@@ -144,12 +138,10 @@ async fn write_event_with_is_subject_on_event_id_condition_on_empty_subject() {
144138
let result = client
145139
.write_events(
146140
vec![event_candidate.clone()],
147-
vec![
148-
Precondition::IsSubjectOnEventId {
149-
subject: event_candidate.subject.clone(),
150-
event_id: "100".to_string(),
151-
},
152-
],
141+
vec![Precondition::IsSubjectOnEventId {
142+
subject: event_candidate.subject.clone(),
143+
event_id: "100".to_string(),
144+
}],
153145
)
154146
.await;
155147
assert!(result.is_err(), "Expected an error, but got: {:?}", result);
@@ -170,12 +162,10 @@ async fn write_event_with_is_subject_on_event_id_condition_on_non_empty_subject_
170162
let result = client
171163
.write_events(
172164
vec![event_candidate.clone()],
173-
vec![
174-
Precondition::IsSubjectOnEventId {
175-
subject: event_candidate.subject.clone(),
176-
event_id: written.id().to_string(),
177-
},
178-
],
165+
vec![Precondition::IsSubjectOnEventId {
166+
subject: event_candidate.subject.clone(),
167+
event_id: written.id().to_string(),
168+
}],
179169
)
180170
.await;
181171
assert!(result.is_ok(), "Writing the event failed: {:?}", result);
@@ -196,12 +186,10 @@ async fn write_event_with_is_subject_on_event_id_condition_on_non_empty_subject_
196186
let result = client
197187
.write_events(
198188
vec![event_candidate.clone()],
199-
vec![
200-
Precondition::IsSubjectOnEventId {
201-
subject: event_candidate.subject.clone(),
202-
event_id: 100.to_string(),
203-
},
204-
],
189+
vec![Precondition::IsSubjectOnEventId {
190+
subject: event_candidate.subject.clone(),
191+
event_id: 100.to_string(),
192+
}],
205193
)
206194
.await;
207195
assert!(result.is_err(), "Expected an error, but got: {:?}", result);
@@ -219,12 +207,10 @@ async fn write_events_with_is_subject_on_event_id_condition_on_empty_subject() {
219207
let result = client
220208
.write_events(
221209
event_candidates.clone(),
222-
vec![
223-
Precondition::IsSubjectOnEventId {
224-
subject: event_candidates[1].subject.clone(),
225-
event_id: "100".to_string(),
226-
},
227-
],
210+
vec![Precondition::IsSubjectOnEventId {
211+
subject: event_candidates[1].subject.clone(),
212+
event_id: "100".to_string(),
213+
}],
228214
)
229215
.await;
230216
assert!(result.is_err(), "Expected an error, but got: {:?}", result);
@@ -249,12 +235,10 @@ async fn write_events_with_is_subject_on_event_id_condition_on_non_empty_subject
249235
let result = client
250236
.write_events(
251237
event_candidates,
252-
vec![
253-
Precondition::IsSubjectOnEventId {
254-
subject: fill_event_candidate.subject.clone(),
255-
event_id: written.id().to_string(),
256-
},
257-
],
238+
vec![Precondition::IsSubjectOnEventId {
239+
subject: fill_event_candidate.subject.clone(),
240+
event_id: written.id().to_string(),
241+
}],
258242
)
259243
.await;
260244
assert!(result.is_ok(), "Writing the events failed: {:?}", result);
@@ -279,12 +263,10 @@ async fn write_events_with_is_subject_on_event_id_condition_on_non_empty_subject
279263
let result = client
280264
.write_events(
281265
event_candidates,
282-
vec![
283-
Precondition::IsSubjectOnEventId {
284-
subject: fill_event_candidate.subject.clone(),
285-
event_id: 100.to_string(),
286-
},
287-
],
266+
vec![Precondition::IsSubjectOnEventId {
267+
subject: fill_event_candidate.subject.clone(),
268+
event_id: 100.to_string(),
269+
}],
288270
)
289271
.await;
290272
assert!(result.is_err(), "Expected an error, but got: {:?}", result);

0 commit comments

Comments
 (0)