Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
Add another batch test
Browse files Browse the repository at this point in the history
  • Loading branch information
bretthoerner committed Jan 31, 2024
1 parent 9cd1132 commit 393c079
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions capture-server/tests/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,54 @@ async fn it_captures_a_batch() -> Result<()> {
Ok(())
}

#[tokio::test]
async fn it_captures_a_different_batch() -> Result<()> {
setup_tracing();
let token = random_string("token", 16);
let distinct_id1 = random_string("id", 16);
let distinct_id2 = random_string("id", 16);

let topic = EphemeralTopic::new().await;
let server = ServerHandle::for_topic(&topic);

let event = json!([{
"api_key": token,
"event": "event1",
"properties": {
"prop1": "str1",
"prop2": 1234f64,
"distinct_id": distinct_id1,
"timestamp": 1705418635246f64,
},
"timestamp": "2024-01-16T15:23:55.246Z"
},{
"api_key": token,
"event": "event2",
"distinct_id": distinct_id2,
"timestamp": "2024-01-16T17:23:55.246Z"
}]);

let res = server.capture_events(event.to_string()).await;
assert_eq!(StatusCode::OK, res.status());

assert_json_include!(
actual: topic.next_event()?,
expected: json!({
"token": token,
"distinct_id": distinct_id1
})
);
assert_json_include!(
actual: topic.next_event()?,
expected: json!({
"token": token,
"distinct_id": distinct_id2
})
);

Ok(())
}

#[tokio::test]
async fn it_overflows_events_on_burst() -> Result<()> {
setup_tracing();
Expand Down

0 comments on commit 393c079

Please sign in to comment.