Skip to content

Commit 5d29cf1

Browse files
committed
Updated URI and added integration tests
1 parent 2df0600 commit 5d29cf1

4 files changed

Lines changed: 57 additions & 3 deletions

File tree

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub enum GraphOrMessage {
4040
/// ```rust
4141
/// use json2rdf::json_to_rdf;
4242
///
43-
/// json_to_rdf(&"test/airplane.json".to_string(), &Some("http://example.com/ns#".to_string()), &Some("output.nt".to_string()));
43+
/// json_to_rdf(&"tests/airplane.json".to_string(), &Some("http://example.com/ns#".to_string()), &Some("output.nt".to_string()));
4444
/// ```
4545
4646
pub fn json_to_rdf(
@@ -51,7 +51,7 @@ pub fn json_to_rdf(
5151
let rdf_namespace: String = if namespace.is_some() {
5252
namespace.clone().unwrap()
5353
} else {
54-
"https://decisym/data".to_owned()
54+
"https://decisym.ai/json2rdf/model".to_owned()
5555
};
5656

5757
let file = File::open(file_path).unwrap();

test/intergration_test.rs

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/airplane.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"aircraft": {
3+
"id": "A12345",
4+
"model": "Boeing 747",
5+
"manufacturer": "Boeing",
6+
"capacity": {
7+
"seats": 416,
8+
"cargo_volume": 150.4
9+
},
10+
"flights": [
11+
{
12+
"flight_number": "BA123",
13+
"departure": {
14+
"airport": "JFK",
15+
"time": "2024-10-29T10:00:00Z"
16+
},
17+
"arrival": {
18+
"airport": "LHR",
19+
"time": "2024-10-29T22:00:00Z"
20+
}
21+
},
22+
{
23+
"flight_number": "BA456",
24+
"departure": {
25+
"airport": "LHR",
26+
"time": "2024-10-30T12:00:00Z"
27+
},
28+
"arrival": {
29+
"airport": "JFK",
30+
"time": "2024-10-30T20:00:00Z"
31+
}
32+
}
33+
]
34+
}
35+
}

tests/integration_test.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
use json2rdf::json_to_rdf;
2+
3+
#[test]
4+
fn test_graph_triple_count() {
5+
let triple_count_string = json_to_rdf(&"tests/airplane.json".to_string(), &None, &None);
6+
7+
match triple_count_string {
8+
Ok(res) => match res {
9+
json2rdf::GraphOrMessage::Graph(graph) => {
10+
// Handle the case where the function returns a Graph
11+
println!("Graph created with {} triples", graph.len());
12+
assert_eq!(graph.len(), 23)
13+
}
14+
json2rdf::GraphOrMessage::Message(message) => {
15+
println!("{}", message);
16+
}
17+
},
18+
Err(e) => eprintln!("Error writing: {}", e),
19+
}
20+
}

0 commit comments

Comments
 (0)