Skip to content

Commit

Permalink
add tests for digestion function
Browse files Browse the repository at this point in the history
  • Loading branch information
asr2003 authored Dec 18, 2024
1 parent 8b954aa commit ea67cec
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion nativelink-util/tests/resource_info_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use std::borrow::Cow;

use nativelink_macro::nativelink_test;
use nativelink_util::resource_info::ResourceInfo;
use nativelink_util::resource_info::{is_supported_digest_function, ResourceInfo};
use pretty_assertions::assert_eq;

#[nativelink_test]
Expand Down Expand Up @@ -707,3 +707,28 @@ async fn write_invalid_size_test() -> Result<(), Box<dyn std::error::Error>> {
assert!(ResourceInfo::new(RESOURCE_NAME, true).is_err());
Ok(())
}

#[nativelink_test]
async fn test_supported_digest_functions() -> Result<(), Box<dyn std::error::Error>> {
assert_eq!(is_supported_digest_function("sha256"), true);
assert_eq!(is_supported_digest_function("sha1"), true);
assert_eq!(is_supported_digest_function("md5"), true);
assert_eq!(is_supported_digest_function("vso"), true);
assert_eq!(is_supported_digest_function("sha384"), true);
assert_eq!(is_supported_digest_function("sha512"), true);
assert_eq!(is_supported_digest_function("murmur3"), true);
assert_eq!(is_supported_digest_function("sha256tree"), true);
assert_eq!(is_supported_digest_function("blake3"), true);

Ok(())
}

#[nativelink_test]
async fn test_unsupported_digest_functions() -> Result<(), Box<dyn std::error::Error>> {
assert_eq!(is_supported_digest_function("sha3"), false);
assert_eq!(is_supported_digest_function("invalid_digest_function"), false);
assert_eq!(is_supported_digest_function("boo"), false);
assert_eq!(is_supported_digest_function("random_hash"), false);

Ok(())
}

0 comments on commit ea67cec

Please sign in to comment.