Skip to content

Commit

Permalink
Fix nesting prefixes in service API groups
Browse files Browse the repository at this point in the history
  • Loading branch information
rexf authored Nov 13, 2024
1 parent 21ea5ca commit 79bf679
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 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: 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,30 @@ 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 79bf679

Please sign in to comment.