use super::BlobLocation;
use crate::ToGraphqlOutput;
#[test]
fn a_bare_location_says_only_where() {
let location = BlobLocation::new("thumbnail/clip/1.png");
assert_eq!(location.address(), "thumbnail/clip/1.png");
assert_eq!(location.content_type(), None);
assert_eq!(location.size(), None);
}
#[test]
fn a_backend_states_what_it_already_knows() {
let typed = BlobLocation::new("thumbnail/clip/1.png").with_content_type("image/png");
assert_eq!(typed.content_type(), Some("image/png"));
assert_eq!(typed.size(), None);
let sized = BlobLocation::new("waveform/clip").with_size(4096);
assert_eq!(sized.content_type(), None);
assert_eq!(sized.size(), Some(4096));
let both = BlobLocation::new("thumbnail/clip/1.png")
.with_content_type("image/png")
.with_size(9);
assert_eq!(both.content_type(), Some("image/png"));
assert_eq!(both.size(), Some(9));
}
#[test]
fn the_crossing_borrows_rather_than_copies() {
let location = BlobLocation::new("thumbnail/clip/1.png").with_size(9);
let crossed: &BlobLocation = BlobLocation::to_graphql_output(&location);
assert!(core::ptr::eq(crossed, &location));
}