public_surface.rs (3848B)
1 #[test] 2 fn approved_module_skeleton_is_public() { 3 #[allow(unused_imports)] 4 use radroots::{ 5 client, event, farm, identity, knowledge, listing, signing, storage, sync, trade, transport, 6 }; 7 } 8 9 #[test] 10 fn root_exports_only_the_client_boundary() { 11 fn assert_client<T: Clone + Send + Sync>() {} 12 fn assert_builder<T: Send + Sync>() {} 13 fn assert_error<T: std::error::Error + Send + Sync + 'static>() {} 14 15 assert_client::<radroots::Client>(); 16 assert_builder::<radroots::ClientBuilder>(); 17 assert_error::<radroots::Error>(); 18 let result: radroots::Result<()> = Ok(()); 19 assert!(result.is_ok()); 20 } 21 22 #[test] 23 fn canonical_domain_paths_compile() { 24 #[allow(unused_imports)] 25 use radroots::{ 26 event::{Event, EventId, GenericEventDraft}, 27 farm::{Farm, FarmPublicLocation, Plan as FarmPlan, PrepareRequest as FarmRequest}, 28 identity::{AccountId, PublicKey, Username}, 29 listing::{EditV1, OperationalListing, Plan as ListingPlan}, 30 signing::{Mode, Provider}, 31 storage::{IntegrityStatus, Operations as StorageOperations, Status}, 32 trade::{Money, MutationV1, Plan as TradePlan, Projection}, 33 transport::{Profile, SatisfactionPolicy, Target, TargetSet, TransportId}, 34 }; 35 } 36 37 #[cfg(feature = "client")] 38 #[test] 39 fn ordinary_memory_and_local_only_construction_is_inert() { 40 let client = radroots::client::memory().build().expect("memory client"); 41 assert!(!client.is_closed()); 42 assert!(radroots::client::local_only().is_local_only()); 43 } 44 45 #[cfg(any(feature = "nostr", feature = "full"))] 46 #[test] 47 fn explicit_transport_composition_is_inert() { 48 use std::sync::Arc; 49 50 use radroots::transport::{EventSink, EventSource}; 51 use radroots_transport::{ 52 DeliveryReceipt, DeliveryRequest, Error, FetchPage, FetchRequest, SinkFailure, SinkStatus, 53 SourceStatus, outcome::Retryability, source::BoxFuture, 54 }; 55 56 struct Source; 57 struct Sink; 58 59 impl EventSource for Source { 60 fn status(&self) -> BoxFuture<'_, Result<SourceStatus, Error>> { 61 Box::pin(async { Err(Error::UnsupportedOperation) }) 62 } 63 64 fn fetch(&self, _request: FetchRequest) -> BoxFuture<'_, Result<FetchPage, Error>> { 65 Box::pin(async { Err(Error::UnsupportedOperation) }) 66 } 67 } 68 69 impl EventSink for Sink { 70 fn status(&self) -> BoxFuture<'_, Result<SinkStatus, Error>> { 71 Box::pin(async { Err(Error::UnsupportedOperation) }) 72 } 73 74 fn deliver( 75 &self, 76 request: DeliveryRequest, 77 ) -> BoxFuture<'_, Result<DeliveryReceipt, SinkFailure>> { 78 Box::pin(async move { 79 Err(SinkFailure::for_request( 80 &request, 81 "test_sink_unavailable", 82 Retryability::Terminal, 83 None, 84 None, 85 Vec::new(), 86 ) 87 .expect("test sink failure")) 88 }) 89 } 90 } 91 92 let client = radroots::client::with_transport( 93 radroots::client::memory(), 94 Arc::new(Source), 95 Arc::new(Sink), 96 ) 97 .build() 98 .expect("explicit transport client"); 99 assert!(client.source().expect("source").is_some()); 100 assert!(client.sink().expect("sink").is_some()); 101 } 102 103 #[cfg(any(feature = "geonames", feature = "full"))] 104 #[test] 105 fn geonames_selection_is_explicit() { 106 assert!(radroots::client::geonames_enabled()); 107 } 108 109 #[cfg(any(feature = "knowledge", feature = "full"))] 110 #[test] 111 fn knowledge_selection_is_explicit() { 112 assert!(radroots::client::knowledge_enabled()); 113 } 114 115 #[cfg(any(feature = "knowledge", feature = "full"))] 116 #[test] 117 fn canonical_knowledge_paths_compile() { 118 #[allow(unused_imports)] 119 use radroots::knowledge::{KnowledgeClaim, WikiArticle, normalize_wiki_d_tag}; 120 }