The following test reproduces the issue (you can paste it under client::test and run it with cargo test --features test-registry test_pull_blob_not_found):
#[tokio::test]
#[cfg(feature = "test-registry")]
async fn test_pull_blob_not_found() {
// initialize the registry
let docker = clients::Cli::default();
let test_container = docker.run(registry_image());
let port = test_container.get_host_port_ipv4(5000);
let c = Client::new(ClientConfig {
protocol: ClientProtocol::HttpsExcept(vec![format!("localhost:{}", port)]),
..Default::default()
});
// Layer is not found at `image-repository`
let image_reference: Reference = format!("localhost:{}/image-repository", port).parse().unwrap();
let mut buf = Vec::new();
let dummy_digest = sha256_digest(&[]);
let pull_result = c.pull_blob(&image_reference, &dummy_digest, &mut buf).await;
// The result is OK, but the response body does not correspond to the contents of the blob
assert!(pull_result.is_ok());
assert!(String::from_utf8(buf).unwrap().starts_with("{\"errors\":[{\"code\":\"BLOB_UNKNOWN\""));
}
Expected result
As a user of the library, I intuitively expect pull_blob to return Ok only when the blob was found, and Err otherwise.
Steps to reproduce
The following test reproduces the issue (you can paste it under
client::test
and run it withcargo test --features test-registry test_pull_blob_not_found
):Expected result
As a user of the library, I intuitively expect
pull_blob
to returnOk
only when the blob was found, andErr
otherwise.