Skip to content

Commit

Permalink
adding test case
Browse files Browse the repository at this point in the history
  • Loading branch information
rexf committed Nov 12, 2024
1 parent 169206b commit 55beded
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion async-nats/src/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ impl Group {
queue_group: Z,
) -> Group {
Group {
prefix: format!("{}.{}", self.prefix.to_string(), prefix.to_string()),
prefix: format!("{}.{}", self.prefix, prefix.to_string()),
stats: self.stats.clone(),
client: self.client.clone(),
shutdown_tx: self.shutdown_tx.clone(),
Expand Down Expand Up @@ -891,3 +891,29 @@ impl std::fmt::Debug for StatsHandler {
write!(f, "Stats handler")
}
}

#[cfg(test)]
mod tests {
use super::*;

#[tokio::test]
async fn test_group_with_queue_group() {
let server = nats_server::run_basic_server();
let client = crate::connect(server.client_url()).await.unwrap();

let group = Group {
prefix: "test".to_string(),
stats: Arc::new(Mutex::new(Endpoints { endpoints: HashMap::new() })),
client,
shutdown_tx: tokio::sync::broadcast::channel(1).0,
subjects: Arc::new(Mutex::new(vec![])),
queue_group: "default".to_string(),
};

let new_group = group.group_with_queue_group("v1", "custom_queue");

assert_eq!(new_group.prefix, "test.v1");
assert_eq!(new_group.queue_group, "custom_queue");
}
}

0 comments on commit 55beded

Please sign in to comment.