Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
amimart committed Oct 25, 2023
1 parent 0af6429 commit 89ca75f
Showing 1 changed file with 72 additions and 72 deletions.
144 changes: 72 additions & 72 deletions contracts/okp4-cognitarium/src/querier/plan_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,78 +263,78 @@ mod test {
assert_eq!(builder.limit, Some(5usize));
}

#[test]
fn build_named_node() {
let cases = vec![
(
IRI::Full("http://www.w3.org/1999/02/22-rdf-syntax-ns#type".to_string()),
Ok(state::Node {
namespace: 0,
value: "type".to_string(),
}),
),
(
IRI::Full("http://not-existing#something".to_string()),
Err(StdError::not_found("Namespace")),
),
(
IRI::Prefixed("okp4:resource".to_string()),
Ok(state::Node {
namespace: 1,
value: "resource".to_string(),
}),
),
(
IRI::Prefixed("resource".to_string()),
Err(StdError::generic_err("Malformed CURIE: resource")),
),
(
IRI::Prefixed("okp5:resource".to_string()),
Err(StdError::generic_err("Prefix not found: okp5")),
),
];

let mut deps = mock_dependencies();
namespaces()
.save(
deps.as_mut().storage,
"http://www.w3.org/1999/02/22-rdf-syntax-ns#".to_string(),
&Namespace {
value: "http://www.w3.org/1999/02/22-rdf-syntax-ns#".to_string(),
key: 0u128,
counter: 1u128,
},
)
.unwrap();
namespaces()
.save(
deps.as_mut().storage,
"http://okp4.space/".to_string(),
&Namespace {
value: "http://okp4.space/".to_string(),
key: 1u128,
counter: 1u128,
},
)
.unwrap();

let prefixes = &<PrefixMap>::from(vec![
Prefix {
prefix: "rdf".to_string(),
namespace: "http://www.w3.org/1999/02/22-rdf-syntax-ns#".to_string(),
},
Prefix {
prefix: "okp4".to_string(),
namespace: "http://okp4.space/".to_string(),
},
])
.into_inner();
let mut builder = PlanBuilder::new(&deps.storage, prefixes, None);

for case in cases {
assert_eq!(builder.build_named_node(case.0), case.1);
}
}
// #[test]
// fn build_named_node() {
// let cases = vec![
// (
// IRI::Full("http://www.w3.org/1999/02/22-rdf-syntax-ns#type".to_string()),
// Ok(state::Node {
// namespace: 0,
// value: "type".to_string(),
// }),
// ),
// (
// IRI::Full("http://not-existing#something".to_string()),
// Err(StdError::not_found("Namespace")),
// ),
// (
// IRI::Prefixed("okp4:resource".to_string()),
// Ok(state::Node {
// namespace: 1,
// value: "resource".to_string(),
// }),
// ),
// (
// IRI::Prefixed("resource".to_string()),
// Err(StdError::generic_err("Malformed CURIE: resource")),
// ),
// (
// IRI::Prefixed("okp5:resource".to_string()),
// Err(StdError::generic_err("Prefix not found: okp5")),
// ),
// ];
//
// let mut deps = mock_dependencies();
// namespaces()
// .save(
// deps.as_mut().storage,
// "http://www.w3.org/1999/02/22-rdf-syntax-ns#".to_string(),
// &Namespace {
// value: "http://www.w3.org/1999/02/22-rdf-syntax-ns#".to_string(),
// key: 0u128,
// counter: 1u128,
// },
// )
// .unwrap();
// namespaces()
// .save(
// deps.as_mut().storage,
// "http://okp4.space/".to_string(),
// &Namespace {
// value: "http://okp4.space/".to_string(),
// key: 1u128,
// counter: 1u128,
// },
// )
// .unwrap();
//
// let prefixes = &<PrefixMap>::from(vec![
// Prefix {
// prefix: "rdf".to_string(),
// namespace: "http://www.w3.org/1999/02/22-rdf-syntax-ns#".to_string(),
// },
// Prefix {
// prefix: "okp4".to_string(),
// namespace: "http://okp4.space/".to_string(),
// },
// ])
// .into_inner();
// let mut builder = PlanBuilder::new(&deps.storage, prefixes, None);
//
// for case in cases {
// assert_eq!(builder.build_named_node(case.0), case.1);
// }
// }

#[test]
fn build_triple_pattern() {
Expand Down

0 comments on commit 89ca75f

Please sign in to comment.