Skip to content

Commit

Permalink
Extend unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaeling committed Aug 6, 2024
1 parent 277fc5d commit 3f6a68c
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions databroker/src/grpc/kuksa_val_v2/val.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,17 +571,25 @@ mod tests {
.await
.expect("Register datapoint should succeed");

let mut wildcard_req = tonic::Request::new(proto::ListMetadataRequest {
let mut wildcard_req_two_asteriks = tonic::Request::new(proto::ListMetadataRequest {
root: "test.**".to_owned(),
filter: "".to_owned(),
});

let mut wildcard_req_one_asterik = tonic::Request::new(proto::ListMetadataRequest {
root: "test.*".to_owned(),
filter: "".to_owned(),
});
// Manually insert permissions
wildcard_req
wildcard_req_two_asteriks
.extensions_mut()
.insert(permissions::ALLOW_ALL.clone());

match proto::val_server::Val::list_metadata(&broker, wildcard_req)
wildcard_req_one_asterik
.extensions_mut()
.insert(permissions::ALLOW_ALL.clone());

match proto::val_server::Val::list_metadata(&broker, wildcard_req_two_asteriks)
.await
.map(|res| res.into_inner())
{
Expand All @@ -591,6 +599,17 @@ mod tests {
}
Err(_status) => panic!("failed to execute get request"),
}

match proto::val_server::Val::list_metadata(&broker, wildcard_req_one_asterik)
.await
.map(|res| res.into_inner())
{
Ok(list_response) => {
let entries_size = list_response.metadata.len();
assert_eq!(entries_size, 1);
}
Err(_status) => panic!("failed to execute get request"),
}
}

#[tokio::test]
Expand Down

0 comments on commit 3f6a68c

Please sign in to comment.