Skip to content

Commit

Permalink
Improve
Browse files Browse the repository at this point in the history
  • Loading branch information
iambriccardo committed Aug 16, 2024
1 parent 4d1c06f commit bc3b2fd
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions relay-server/src/services/buffer/envelope_buffer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,9 +563,21 @@ mod tests {
envelope
}

fn mock_config() -> Config {
Config::from_json_value(serde_json::json!({
"spool": {
"envelopes": {
"version": "experimental",
"max_evictable_stacks": 3
}
}
}))
.unwrap()
}

#[tokio::test]
async fn test_insert_pop() {
let mut buffer = EnvelopeBuffer::<MemoryStackProvider>::new(10);
let mut buffer = EnvelopeBuffer::<MemoryStackProvider>::new(&mock_config());

let project_key1 = ProjectKey::parse("a94ae32be2584e0bbd7a4cbb95971fed").unwrap();
let project_key2 = ProjectKey::parse("a94ae32be2584e0bbd7a4cbb95971fee").unwrap();
Expand Down Expand Up @@ -649,7 +661,7 @@ mod tests {

#[tokio::test]
async fn test_project_internal_order() {
let mut buffer = EnvelopeBuffer::<MemoryStackProvider>::new(10);
let mut buffer = EnvelopeBuffer::<MemoryStackProvider>::new(&mock_config());

let project_key = ProjectKey::parse("a94ae32be2584e0bbd7a4cbb95971fed").unwrap();

Expand All @@ -676,7 +688,7 @@ mod tests {

#[tokio::test]
async fn test_sampling_projects() {
let mut buffer = EnvelopeBuffer::<MemoryStackProvider>::new(10);
let mut buffer = EnvelopeBuffer::<MemoryStackProvider>::new(&mock_config());

let project_key1 = ProjectKey::parse("a94ae32be2584e0bbd7a4cbb95971fed").unwrap();
let project_key2 = ProjectKey::parse("a94ae32be2584e0bbd7a4cbb95971fef").unwrap();
Expand Down Expand Up @@ -754,7 +766,7 @@ mod tests {

assert_ne!(stack_key1, stack_key2);

let mut buffer = EnvelopeBuffer::<MemoryStackProvider>::new(10);
let mut buffer = EnvelopeBuffer::<MemoryStackProvider>::new(&mock_config());
buffer
.push(new_envelope(project_key1, Some(project_key2), None))
.await
Expand All @@ -768,7 +780,7 @@ mod tests {

#[tokio::test]
async fn test_last_peek_internal_order() {
let mut buffer = EnvelopeBuffer::<MemoryStackProvider>::new(10);
let mut buffer = EnvelopeBuffer::<MemoryStackProvider>::new(&mock_config());

let project_key_1 = ProjectKey::parse("a94ae32be2584e0bbd7a4cbb95971fed").unwrap();
let event_id_1 = EventId::new();
Expand Down Expand Up @@ -798,7 +810,7 @@ mod tests {

#[tokio::test]
async fn test_eviction() {
let mut buffer = EnvelopeBuffer::<MemoryStackProvider>::new(3);
let mut buffer = EnvelopeBuffer::<MemoryStackProvider>::new(&mock_config());

let project_key_1 = ProjectKey::parse("a94ae32be2584e0bbd7a4cbb95971fed").unwrap();
let project_key_2 = ProjectKey::parse("b56ae32be2584e0bbd7a4cbb95971fed").unwrap();
Expand Down

0 comments on commit bc3b2fd

Please sign in to comment.