refactor(tvix/castore/*): drop utils.rs and grpc directorysvc tests

This drops pretty much all of castore/utils.rs.

There were only two things left in there, both a bit messy and only used
for tests:

Some `gen_*_service()` helper functions. These can be expressed by
`from_addr("memory://")`.

The other thing was some plumbing code to test the gRPC layer, by
exposing a in-memory implementation via gRPC, and then connecting to
that channel via a gRPC client again.

Previous CLs moved the connection setup code to
{directory,blob}service::tests::utils, close to where we exercise them,
the new rstest-based tests.

The tests interacting directly on the gRPC types are removed, all
scenarios that were in there show now be covered through the rstest ones
on the trait level.

Change-Id: I450ccccf983b4c62145a25d81c36a40846664814
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11223
Reviewed-by: Connor Brewster <cbrewster@hey.com>
Tested-by: BuildkiteCI
This commit is contained in:
Florian Klink 2024-03-20 22:36:02 +02:00 committed by flokli
parent 05d3f21eaf
commit 74023a07a4
10 changed files with 31 additions and 612 deletions

View file

@ -51,7 +51,10 @@ mod tests {
use super::from_addr;
use test_case::test_case;
use tvix_castore::utils::{gen_blob_service, gen_directory_service};
use tvix_castore::{
blobservice::{BlobService, MemoryBlobService},
directoryservice::{DirectoryService, MemoryDirectoryService},
};
/// This uses an unsupported scheme.
#[test_case("http://foo.example/test", false; "unsupported scheme")]
@ -71,14 +74,13 @@ mod tests {
#[test_case("grpc+http://localhost/some-path", false; "grpc valid invalid host and path")]
#[tokio::test]
async fn test_from_addr(uri_str: &str, is_ok: bool) {
let blob_service: Arc<dyn BlobService> = Arc::from(MemoryBlobService::default());
let directory_service: Arc<dyn DirectoryService> =
Arc::from(MemoryDirectoryService::default());
assert_eq!(
from_addr(
uri_str,
Arc::from(gen_blob_service()),
Arc::from(gen_directory_service())
)
.await
.is_ok(),
from_addr(uri_str, blob_service, directory_service)
.await
.is_ok(),
is_ok
)
}