From ea67cec9bd286d36d13d832ceb361792f070eba0 Mon Sep 17 00:00:00 2001 From: asr2003 <162500856+asr2003@users.noreply.github.com> Date: Wed, 18 Dec 2024 22:30:17 +0530 Subject: [PATCH] add tests for digestion function --- nativelink-util/tests/resource_info_test.rs | 27 ++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/nativelink-util/tests/resource_info_test.rs b/nativelink-util/tests/resource_info_test.rs index 2321d76ca..e44deeaec 100644 --- a/nativelink-util/tests/resource_info_test.rs +++ b/nativelink-util/tests/resource_info_test.rs @@ -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] @@ -707,3 +707,28 @@ async fn write_invalid_size_test() -> Result<(), Box> { assert!(ResourceInfo::new(RESOURCE_NAME, true).is_err()); Ok(()) } + +#[nativelink_test] +async fn test_supported_digest_functions() -> Result<(), Box> { + 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> { + 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(()) +}