Skip to content

Commit

Permalink
test: add test for new check
Browse files Browse the repository at this point in the history
  • Loading branch information
MegaRedHand committed Feb 17, 2025
1 parent 519113c commit 905acbe
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion crates/types/src/operator_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ impl OperatorMetadata {
if path.extension().map(|ext| ext != "png").unwrap_or(true) {
return Err(LogoUrlInvalidImageExtension);
}
// Check the server returns content with a "image/png" mime type
let response = reqwest::get(&self.logo).await.unwrap();
let body = response.bytes().await.unwrap();

Expand Down Expand Up @@ -270,13 +271,21 @@ mod tests {
}

#[tokio::test]
async fn test_invalid_wrong_image_format() {
async fn test_invalid_logo_wrong_image_format() {
let mut metadata = get_default_metadata();
metadata.logo = "https://test.com/test.svg".to_string();
let err = metadata.validate().await.unwrap_err();
assert_eq!(err, OperatorMetadataError::LogoUrlInvalidImageExtension);
}

#[tokio::test]
async fn test_invalid_logo_invalid_mime_type() {
let mut metadata = get_default_metadata();
metadata.logo = "https://goerli-operator-metadata.s3.amazonaws.com/cat.png".to_string();
let err = metadata.validate().await.unwrap_err();
assert_eq!(err, OperatorMetadataError::LogoUrlInvalidMimeType);
}

#[tokio::test]
async fn test_invalid_website_url_1() {
let mut metadata = get_default_metadata();
Expand Down

0 comments on commit 905acbe

Please sign in to comment.