refactor(tvix/store): cargo clippy
Change-Id: I3a80560d036e7ed08036b5e9f0974080d1a30ded Reviewed-on: https://cl.tvl.fyi/c/depot/+/9096 Tested-by: BuildkiteCI Reviewed-by: raitobezarius <tvl@lahfa.xyz> Autosubmit: flokli <flokli@flokli.de>
This commit is contained in:
parent
bc852fa56f
commit
3ffbcc6c8a
7 changed files with 27 additions and 36 deletions
|
@ -169,7 +169,7 @@ impl BlobService for GRPCBlobService {
|
||||||
|
|
||||||
// bytes arriving on the RX side are wrapped inside a
|
// bytes arriving on the RX side are wrapped inside a
|
||||||
// [proto::BlobChunk], and a [ReceiverStream] is constructed.
|
// [proto::BlobChunk], and a [ReceiverStream] is constructed.
|
||||||
let blobchunk_stream = ReceiverStream::new(rx).map(|x| proto::BlobChunk { data: x.into() });
|
let blobchunk_stream = ReceiverStream::new(rx).map(|x| proto::BlobChunk { data: x });
|
||||||
|
|
||||||
// That receiver stream is used as a stream in the gRPC BlobService.put rpc call.
|
// That receiver stream is used as a stream in the gRPC BlobService.put rpc call.
|
||||||
let task: tokio::task::JoinHandle<Result<_, Status>> = self
|
let task: tokio::task::JoinHandle<Result<_, Status>> = self
|
||||||
|
|
|
@ -24,12 +24,9 @@ fn gen_sled_blob_service() -> impl BlobService {
|
||||||
#[test_case(gen_memory_blob_service(); "memory")]
|
#[test_case(gen_memory_blob_service(); "memory")]
|
||||||
#[test_case(gen_sled_blob_service(); "sled")]
|
#[test_case(gen_sled_blob_service(); "sled")]
|
||||||
fn has_nonexistent_false(blob_service: impl BlobService) {
|
fn has_nonexistent_false(blob_service: impl BlobService) {
|
||||||
assert_eq!(
|
assert!(!blob_service
|
||||||
blob_service
|
.has(&fixtures::BLOB_A_DIGEST)
|
||||||
.has(&fixtures::BLOB_A_DIGEST)
|
.expect("must not fail"));
|
||||||
.expect("must not fail"),
|
|
||||||
false
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Trying to read a non-existing blob should return a None instead of a reader.
|
/// Trying to read a non-existing blob should return a None instead of a reader.
|
||||||
|
@ -62,9 +59,8 @@ fn put_has_get(blob_service: impl BlobService, blob_contents: &[u8], blob_digest
|
||||||
|
|
||||||
assert_eq!(*blob_digest, digest, "returned digest must be correct");
|
assert_eq!(*blob_digest, digest, "returned digest must be correct");
|
||||||
|
|
||||||
assert_eq!(
|
assert!(
|
||||||
blob_service.has(blob_digest).expect("must not fail"),
|
blob_service.has(blob_digest).expect("must not fail"),
|
||||||
true,
|
|
||||||
"blob service should now have the blob"
|
"blob service should now have the blob"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -116,9 +112,7 @@ fn put_seek(blob_service: impl BlobService) {
|
||||||
pos += buf.len() as u64;
|
pos += buf.len() as u64;
|
||||||
}
|
}
|
||||||
// seek by 0 bytes, using SeekFrom::Start.
|
// seek by 0 bytes, using SeekFrom::Start.
|
||||||
let p = r
|
let p = r.seek(io::SeekFrom::Start(pos)).expect("must not fail");
|
||||||
.seek(io::SeekFrom::Start(pos as u64))
|
|
||||||
.expect("must not fail");
|
|
||||||
assert_eq!(pos, p);
|
assert_eq!(pos, p);
|
||||||
|
|
||||||
// read the next 10 bytes, they must match the data in the fixture.
|
// read the next 10 bytes, they must match the data in the fixture.
|
||||||
|
@ -136,9 +130,7 @@ fn put_seek(blob_service: impl BlobService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// seek by 5 bytes, using SeekFrom::Start.
|
// seek by 5 bytes, using SeekFrom::Start.
|
||||||
let p = r
|
let p = r.seek(io::SeekFrom::Start(pos + 5)).expect("must not fail");
|
||||||
.seek(io::SeekFrom::Start(pos as u64 + 5))
|
|
||||||
.expect("must not fail");
|
|
||||||
pos += 5;
|
pos += 5;
|
||||||
assert_eq!(pos, p);
|
assert_eq!(pos, p);
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,7 @@ mod tests {
|
||||||
)
|
)
|
||||||
.expect("must succeed");
|
.expect("must succeed");
|
||||||
|
|
||||||
assert_eq!(Some(node_directory_with_keep.clone()), resp);
|
assert_eq!(Some(node_directory_with_keep), resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
// traversal to `keep/.keep` should return the node for the .keep file
|
// traversal to `keep/.keep` should return the node for the .keep file
|
||||||
|
@ -166,7 +166,7 @@ mod tests {
|
||||||
)
|
)
|
||||||
.expect("must succeed");
|
.expect("must succeed");
|
||||||
|
|
||||||
assert_eq!(Some(node_file_keep.clone()), resp);
|
assert_eq!(Some(node_file_keep), resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
// traversal to `void` should return None (doesn't exist)
|
// traversal to `void` should return None (doesn't exist)
|
||||||
|
@ -215,7 +215,7 @@ mod tests {
|
||||||
)
|
)
|
||||||
.expect("must succeed");
|
.expect("must succeed");
|
||||||
|
|
||||||
assert_eq!(Some(node_directory_complicated.clone()), resp);
|
assert_eq!(Some(node_directory_complicated), resp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -283,7 +283,7 @@ mod tests {
|
||||||
let dir: InodeData = fixtures::DIRECTORY_WITH_KEEP.clone().into();
|
let dir: InodeData = fixtures::DIRECTORY_WITH_KEEP.clone().into();
|
||||||
|
|
||||||
// put it in
|
// put it in
|
||||||
let dir_ino = inode_tracker.put(dir.clone());
|
let dir_ino = inode_tracker.put(dir);
|
||||||
|
|
||||||
// a get should return the right data
|
// a get should return the right data
|
||||||
let data = inode_tracker.get(dir_ino).expect("must be some");
|
let data = inode_tracker.get(dir_ino).expect("must be some");
|
||||||
|
@ -316,7 +316,7 @@ mod tests {
|
||||||
InodeData::Regular(ref digest, size, executable) => {
|
InodeData::Regular(ref digest, size, executable) => {
|
||||||
assert_eq!(&fixtures::EMPTY_BLOB_DIGEST.clone(), digest);
|
assert_eq!(&fixtures::EMPTY_BLOB_DIGEST.clone(), digest);
|
||||||
assert_eq!(0, size);
|
assert_eq!(0, size);
|
||||||
assert_eq!(false, executable);
|
assert!(!executable);
|
||||||
}
|
}
|
||||||
InodeData::Symlink(_) | InodeData::Directory(..) => panic!("wrong type"),
|
InodeData::Symlink(_) | InodeData::Directory(..) => panic!("wrong type"),
|
||||||
}
|
}
|
||||||
|
@ -335,7 +335,7 @@ mod tests {
|
||||||
let dir_complicated: InodeData = fixtures::DIRECTORY_COMPLICATED.clone().into();
|
let dir_complicated: InodeData = fixtures::DIRECTORY_COMPLICATED.clone().into();
|
||||||
|
|
||||||
// put it in
|
// put it in
|
||||||
let dir_complicated_ino = inode_tracker.put(dir_complicated.clone());
|
let dir_complicated_ino = inode_tracker.put(dir_complicated);
|
||||||
|
|
||||||
// a get should return the right data
|
// a get should return the right data
|
||||||
let dir_data = inode_tracker
|
let dir_data = inode_tracker
|
||||||
|
@ -360,7 +360,7 @@ mod tests {
|
||||||
// check the first child (.keep)
|
// check the first child (.keep)
|
||||||
{
|
{
|
||||||
let (child_ino, child_node) = &children[0];
|
let (child_ino, child_node) = &children[0];
|
||||||
assert!(!seen_inodes.contains(&child_ino));
|
assert!(!seen_inodes.contains(child_ino));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
&proto::node::Node::File(fixtures::DIRECTORY_COMPLICATED.files[0].clone()),
|
&proto::node::Node::File(fixtures::DIRECTORY_COMPLICATED.files[0].clone()),
|
||||||
child_node
|
child_node
|
||||||
|
@ -371,7 +371,7 @@ mod tests {
|
||||||
// check the second child (aa)
|
// check the second child (aa)
|
||||||
{
|
{
|
||||||
let (child_ino, child_node) = &children[1];
|
let (child_ino, child_node) = &children[1];
|
||||||
assert!(!seen_inodes.contains(&child_ino));
|
assert!(!seen_inodes.contains(child_ino));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
&proto::node::Node::Symlink(
|
&proto::node::Node::Symlink(
|
||||||
fixtures::DIRECTORY_COMPLICATED.symlinks[0].clone()
|
fixtures::DIRECTORY_COMPLICATED.symlinks[0].clone()
|
||||||
|
@ -384,7 +384,7 @@ mod tests {
|
||||||
// check the third child (keep)
|
// check the third child (keep)
|
||||||
{
|
{
|
||||||
let (child_ino, child_node) = &children[2];
|
let (child_ino, child_node) = &children[2];
|
||||||
assert!(!seen_inodes.contains(&child_ino));
|
assert!(!seen_inodes.contains(child_ino));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
&proto::node::Node::Directory(
|
&proto::node::Node::Directory(
|
||||||
fixtures::DIRECTORY_COMPLICATED.directories[0].clone()
|
fixtures::DIRECTORY_COMPLICATED.directories[0].clone()
|
||||||
|
|
|
@ -444,7 +444,7 @@ fn read_stat_directory() {
|
||||||
let p = tmpdir.path().join(DIRECTORY_WITH_KEEP_NAME);
|
let p = tmpdir.path().join(DIRECTORY_WITH_KEEP_NAME);
|
||||||
|
|
||||||
// peek at the metadata of the directory
|
// peek at the metadata of the directory
|
||||||
let metadata = fs::metadata(&p).expect("must succeed");
|
let metadata = fs::metadata(p).expect("must succeed");
|
||||||
assert!(metadata.is_dir());
|
assert!(metadata.is_dir());
|
||||||
assert!(metadata.permissions().readonly());
|
assert!(metadata.permissions().readonly());
|
||||||
|
|
||||||
|
@ -667,8 +667,8 @@ fn compare_inodes_directories() {
|
||||||
|
|
||||||
// peek at metadata.
|
// peek at metadata.
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
fs::metadata(&p_dir_with_keep).expect("must succeed").ino(),
|
fs::metadata(p_dir_with_keep).expect("must succeed").ino(),
|
||||||
fs::metadata(&p_sibling_dir).expect("must succeed").ino()
|
fs::metadata(p_sibling_dir).expect("must succeed").ino()
|
||||||
);
|
);
|
||||||
|
|
||||||
fuser_session.join()
|
fuser_session.join()
|
||||||
|
@ -697,8 +697,8 @@ fn compare_inodes_files() {
|
||||||
|
|
||||||
// peek at metadata.
|
// peek at metadata.
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
fs::metadata(&p_keep1).expect("must succeed").ino(),
|
fs::metadata(p_keep1).expect("must succeed").ino(),
|
||||||
fs::metadata(&p_keep2).expect("must succeed").ino()
|
fs::metadata(p_keep2).expect("must succeed").ino()
|
||||||
);
|
);
|
||||||
|
|
||||||
fuser_session.join()
|
fuser_session.join()
|
||||||
|
@ -726,8 +726,8 @@ fn compare_inodes_symlinks() {
|
||||||
|
|
||||||
// peek at metadata.
|
// peek at metadata.
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
fs::symlink_metadata(&p1).expect("must succeed").ino(),
|
fs::symlink_metadata(p1).expect("must succeed").ino(),
|
||||||
fs::symlink_metadata(&p2).expect("must succeed").ino()
|
fs::symlink_metadata(p2).expect("must succeed").ino()
|
||||||
);
|
);
|
||||||
|
|
||||||
fuser_session.join()
|
fuser_session.join()
|
||||||
|
@ -786,7 +786,7 @@ fn disallow_writes() {
|
||||||
let fuser_session = setup_and_mount(tmpdir.path(), |_, _, _| {}).expect("must succeed");
|
let fuser_session = setup_and_mount(tmpdir.path(), |_, _, _| {}).expect("must succeed");
|
||||||
|
|
||||||
let p = tmpdir.path().join(BLOB_A_NAME);
|
let p = tmpdir.path().join(BLOB_A_NAME);
|
||||||
let e = std::fs::File::create(&p).expect_err("must fail");
|
let e = std::fs::File::create(p).expect_err("must fail");
|
||||||
|
|
||||||
assert_eq!(std::io::ErrorKind::Unsupported, e.kind());
|
assert_eq!(std::io::ErrorKind::Unsupported, e.kind());
|
||||||
|
|
||||||
|
@ -815,7 +815,6 @@ fn missing_directory() {
|
||||||
// It fails when trying to pull the first entry, because we don't implement opendir separately
|
// It fails when trying to pull the first entry, because we don't implement opendir separately
|
||||||
fs::read_dir(&p)
|
fs::read_dir(&p)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.into_iter()
|
|
||||||
.next()
|
.next()
|
||||||
.expect("must be some")
|
.expect("must be some")
|
||||||
.expect_err("must be err");
|
.expect_err("must be err");
|
||||||
|
|
|
@ -54,7 +54,7 @@ async fn put_read_stat() {
|
||||||
// Send blob A.
|
// Send blob A.
|
||||||
let put_resp = service
|
let put_resp = service
|
||||||
.put(tonic_mock::streaming_request(vec![BlobChunk {
|
.put(tonic_mock::streaming_request(vec![BlobChunk {
|
||||||
data: BLOB_A.clone().into(),
|
data: BLOB_A.clone(),
|
||||||
}]))
|
}]))
|
||||||
.await
|
.await
|
||||||
.expect("must succeed")
|
.expect("must succeed")
|
||||||
|
|
|
@ -177,7 +177,7 @@ fn test_complicated() {
|
||||||
&mut buf,
|
&mut buf,
|
||||||
&crate::proto::node::Node::Directory(DirectoryNode {
|
&crate::proto::node::Node::Directory(DirectoryNode {
|
||||||
name: "doesntmatter".into(),
|
name: "doesntmatter".into(),
|
||||||
digest: DIRECTORY_COMPLICATED.digest().clone().into(),
|
digest: DIRECTORY_COMPLICATED.digest().into(),
|
||||||
size: DIRECTORY_COMPLICATED.size(),
|
size: DIRECTORY_COMPLICATED.size(),
|
||||||
}),
|
}),
|
||||||
blob_service.clone(),
|
blob_service.clone(),
|
||||||
|
@ -191,7 +191,7 @@ fn test_complicated() {
|
||||||
let (nar_size, nar_digest) = calculate_size_and_sha256(
|
let (nar_size, nar_digest) = calculate_size_and_sha256(
|
||||||
&crate::proto::node::Node::Directory(DirectoryNode {
|
&crate::proto::node::Node::Directory(DirectoryNode {
|
||||||
name: "doesntmatter".into(),
|
name: "doesntmatter".into(),
|
||||||
digest: DIRECTORY_COMPLICATED.digest().clone().into(),
|
digest: DIRECTORY_COMPLICATED.digest().into(),
|
||||||
size: DIRECTORY_COMPLICATED.size(),
|
size: DIRECTORY_COMPLICATED.size(),
|
||||||
}),
|
}),
|
||||||
blob_service,
|
blob_service,
|
||||||
|
|
Loading…
Reference in a new issue