use dist_agent_lang::registry::ResolvedSource;
#[test]
fn test_resolved_source_fetch_source_prefers_url_when_no_prefer_ipfs() {
let r = ResolvedSource {
url: Some("https://registry.example.com/tarball.tgz".to_string()),
ipfs_cid: Some("QmXXX".to_string()),
};
let out = r.fetch_source();
assert_eq!(
out.as_deref(),
Some("https://registry.example.com/tarball.tgz"),
"without DAL_PREFER_IPFS, url should be preferred"
);
}
#[test]
fn test_resolved_source_fetch_source_url_only() {
let r = ResolvedSource {
url: Some("https://x.org/p.tgz".to_string()),
ipfs_cid: None,
};
assert_eq!(r.fetch_source(), Some("https://x.org/p.tgz".to_string()));
}
#[test]
fn test_resolved_source_fetch_source_ipfs_only() {
let r = ResolvedSource {
url: None,
ipfs_cid: Some("QmYYY".to_string()),
};
assert_eq!(r.fetch_source(), Some("ipfs://QmYYY".to_string()));
}