Skip to content

Commit

Permalink
Added test cases
Browse files Browse the repository at this point in the history
Signed-off-by: shubham <[email protected]>
  • Loading branch information
shubhamdixit863 committed May 23, 2024
1 parent 1461156 commit a818075
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
7 changes: 2 additions & 5 deletions examples/map-cat/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ struct Cat;
#[tonic::async_trait]
impl map::Mapper for Cat {
async fn map(&self, input: map::MapRequest) -> Vec<map::Message> {
vec![map::Message {
keys: input.keys,
value: input.value,
tags: vec![],
}]
let message=MessageBuilder::new().keys(input.keys).values(input.value).tags(vec![]).build();
vec![message]
}
}
24 changes: 22 additions & 2 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ where
}

/// Message is the response struct from the [`Mapper::map`] .
#[derive(Debug, PartialEq)]
pub struct Message {
/// Keys are a collection of strings which will be passed on to the next vertex as is. It can
/// be an empty collection.
Expand Down Expand Up @@ -252,7 +252,7 @@ impl<T> Server<T> {
mod tests {
use std::{error::Error, time::Duration};
use tower::service_fn;

use crate::map::{Message, MessageBuilder};
use crate::map;
use crate::map::proto::map_client::MapClient;
use tempfile::TempDir;
Expand Down Expand Up @@ -325,4 +325,24 @@ mod tests {
assert!(task.is_finished(), "gRPC server is still running");
Ok(())
}


// builder test
#[test]
fn builder_test(){
let message=Message{
tags:vec![],
keys:vec![],
value:vec![]
};

let message_builder=MessageBuilder::new()
.keys(vec![])
.values(vec![])
.tags(vec![])
.build();

assert_eq!(message,message_builder)

}
}
2 changes: 1 addition & 1 deletion src/reduce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ pub struct Metadata {
}

/// Message is the response from the user's [`Reducer::reduce`].
#[derive(Debug, PartialEq)]
pub struct Message {
/// Keys are a collection of strings which will be passed on to the next vertex as is. It can
/// be an empty collection. It is mainly used in creating a partition in [`Reducer::reduce`].
Expand Down
1 change: 1 addition & 0 deletions src/sourcetransform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ pub trait SourceTransformer {
}

/// Message is the response struct from the [`SourceTransformer::transform`] .
#[derive(Debug, PartialEq)]
pub struct Message {
/// Keys are a collection of strings which will be passed on to the next vertex as is. It can
/// be an empty collection.
Expand Down

0 comments on commit a818075

Please sign in to comment.