Skip to content

Commit b507fd1

Browse files
committed
Add partial digest variants to cmd_info_test and cmd_read_test
Signed-off-by: J Robert Ray <[email protected]>
1 parent f5de122 commit b507fd1

File tree

2 files changed

+26
-14
lines changed

2 files changed

+26
-14
lines changed

crates/spfs-cli/main/src/cmd_info_test.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ async fn info_on_payload(
2323
#[case]
2424
#[future]
2525
repo: TempRepo,
26+
#[values(true, false)] use_partial_digest: bool,
2627
) {
2728
let repo = repo.await;
2829

@@ -32,13 +33,18 @@ async fn info_on_payload(
3233
.find(|entry| entry.is_regular_file())
3334
.expect("at least one regular file");
3435

35-
let mut opt = Opt::try_parse_from([
36-
"info",
37-
"-r",
38-
&repo.address().to_string(),
39-
&file.object().to_string(),
40-
])
41-
.unwrap();
36+
let digest_arg = if use_partial_digest {
37+
file.object()
38+
.to_string()
39+
.chars()
40+
.take(12)
41+
.collect::<String>()
42+
} else {
43+
file.object().to_string()
44+
};
45+
46+
let mut opt =
47+
Opt::try_parse_from(["info", "-r", &repo.address().to_string(), &digest_arg]).unwrap();
4248
let config = Config::default();
4349
let code = opt
4450
.info

crates/spfs-cli/main/src/cmd_read_test.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ async fn read_on_payload(
2323
#[case]
2424
#[future]
2525
repo: TempRepo,
26+
#[values(true, false)] use_partial_digest: bool,
2627
) {
2728
let repo = repo.await;
2829

@@ -32,13 +33,18 @@ async fn read_on_payload(
3233
.find(|entry| entry.is_regular_file())
3334
.expect("at least one regular file");
3435

35-
let mut opt = Opt::try_parse_from([
36-
"read",
37-
"-r",
38-
&repo.address().to_string(),
39-
&file.object().to_string(),
40-
])
41-
.unwrap();
36+
let digest_arg = if use_partial_digest {
37+
file.object()
38+
.to_string()
39+
.chars()
40+
.take(12)
41+
.collect::<String>()
42+
} else {
43+
file.object().to_string()
44+
};
45+
46+
let mut opt =
47+
Opt::try_parse_from(["read", "-r", &repo.address().to_string(), &digest_arg]).unwrap();
4248
let config = Config::default();
4349
let code = opt
4450
.read

0 commit comments

Comments
 (0)