Skip to content

Commit

Permalink
Add first test for ac_server
Browse files Browse the repository at this point in the history
  • Loading branch information
allada committed Dec 27, 2020
1 parent b4682cb commit 221ed5f
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cas/grpc_service/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,16 @@ rust_test(
"//third_party:tokio",
],
)

rust_test(
name = "ac_server_test",
srcs = ["tests/ac_server_test.rs"],
deps = [
":ac_server",
"//cas/store",
"//util:macros",
"//proto",
"//third_party:tonic",
"//third_party:tokio",
],
)
45 changes: 45 additions & 0 deletions cas/grpc_service/tests/ac_server_test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright 2020 Nathan (Blaise) Bruer. All rights reserved.

use tonic::{Code, Request};

use proto::build::bazel::remote::execution::v2::Digest;

use ac_server::AcServer;
use proto::build::bazel::remote::execution::v2::action_cache_server::ActionCache;
use store::{create_store, StoreType};

const INSTANCE_NAME: &str = "foo";
const HASH1: &str = "0123456789abcdef000000000000000000000000000000000123456789abcdef";

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

use proto::build::bazel::remote::execution::v2::GetActionResultRequest;

#[tokio::test]
#[ignore]
async fn empty_store() {
let ac_store = create_store(&StoreType::Memory);
let cas_store = create_store(&StoreType::Memory);
let ac_server = AcServer::new(ac_store.clone(), cas_store.clone());

let raw_response = ac_server
.get_action_result(Request::new(GetActionResultRequest {
instance_name: INSTANCE_NAME.to_string(),
action_digest: Some(Digest {
hash: HASH1.to_string(),
size_bytes: 0,
}),
inline_stdout: false,
inline_stderr: false,
inline_output_files: vec![],
}))
.await;

assert!(raw_response.is_err());
let err = raw_response.unwrap_err();
assert_eq!(err.code(), Code::NotFound);
assert_eq!(err.message(), format!("Hash {} not found", HASH1));
}
}

0 comments on commit 221ed5f

Please sign in to comment.