use super::tests::{accepted, refused};
#[test]
fn a_fused_field_is_no_node_and_no_resource() {
let model = accepted(quote::quote! {
pub struct Media {
videos: media::Video,
#[ingraph(fuse)]
shots: index::Shots,
}
});
assert_eq!(model.nodes.len(), 1, "one field of two is a node");
assert_eq!(model.mounts.len(), 1);
assert!(model.resources.is_empty());
assert!(model.interfaces.is_empty());
assert_eq!(model.fused.len(), 1);
assert_eq!(model.fused[0].mount, "shots");
assert_eq!(
quote::ToTokens::to_token_stream(&model.fused[0].ty).to_string(),
"index :: Shots"
);
}
#[test]
fn every_retired_spelling_is_refused_by_name() {
for written in [
"fuse(vector)",
"fuse(fulltext)",
"fuse()",
"fuse(hybrid)",
"fuse(vector, fulltext)",
] {
let written: proc_macro2::TokenStream = written.parse().expect("a marker list");
let refusal = refused(quote::quote! {
pub struct Media {
#[ingraph(#written)]
shots: Shots,
}
});
assert!(refusal.contains("`fuse` is a BARE word"), "{refusal}");
assert!(
refusal.contains("`#[ingraph::search]`"),
"the refusal does not say where a fused read is declared now: {refusal}",
);
}
}
#[test]
fn the_word_takes_no_value() {
let refusal = refused(quote::quote! {
pub struct Media {
#[ingraph(fuse = "vector")]
shots: Shots,
}
});
assert!(refusal.contains("`fuse` is a BARE word"), "{refusal}");
}
#[test]
fn a_field_claims_once() {
let refusal = refused(quote::quote! {
pub struct Media {
#[ingraph(fuse, fuse)]
shots: Shots,
}
});
assert!(refusal.contains("declared more than once"), "{refusal}");
}
#[test]
fn a_resource_takes_no_fuse() {
let refusal = refused(quote::quote! {
pub struct Media {
#[ingraph(resource, fuse)]
egemma: Egemma,
}
});
assert!(refusal.contains("takes no `fuse`"), "{refusal}");
assert!(refusal.contains("shared citizen"), "{refusal}");
}
#[test]
fn an_interface_takes_no_fuse() {
let refusal = refused(quote::quote! {
pub struct Media {
#[ingraph(interface, fuse)]
screened: Screened,
}
});
assert!(refusal.contains("owns no slot"), "{refusal}");
assert!(refusal.contains("The MEMBERS fuse"), "{refusal}");
}
#[test]
fn the_two_membership_words_compose() {
let model = accepted(quote::quote! {
pub struct Media {
#[ingraph(fuse)]
shots: Shots,
#[ingraph(query)]
videos: media::Video,
}
});
assert_eq!(model.fused.len(), 1);
assert_eq!(model.queried.len(), 1, "the query membership is untouched");
assert!(
model.fused[0].mount == "shots",
"the fused member is the one that wrote the word",
);
}
#[test]
fn the_words_roster_offers_the_new_one() {
let refusal = refused(quote::quote! {
pub struct Media {
#[ingraph(fyse)]
shots: Shots,
}
});
assert!(refusal.contains("`fuse`"), "{refusal}");
assert!(
!refusal.contains("fuse(vector)"),
"the roster still offers a retired spelling: {refusal}",
);
}