|
|
@ -1865,19 +1865,15 @@ mod tests { |
|
|
|
use std::fs::remove_dir_all; |
|
|
|
use std::fs::remove_dir_all; |
|
|
|
use std::io::read_to_string; |
|
|
|
use std::io::read_to_string; |
|
|
|
|
|
|
|
|
|
|
|
fn cli_command() -> Result<Command> { |
|
|
|
fn cli_command() -> Command { |
|
|
|
Ok(Command::from_std( |
|
|
|
let mut command = Command::new(env!("CARGO")); |
|
|
|
escargot::CargoBuild::new() |
|
|
|
command.arg("run").arg("--bin").arg("oxigraph").arg("--"); |
|
|
|
.bin("oxigraph") |
|
|
|
command |
|
|
|
.manifest_path(format!("{}/Cargo.toml", env!("CARGO_MANIFEST_DIR"))) |
|
|
|
|
|
|
|
.run()? |
|
|
|
|
|
|
|
.command(), |
|
|
|
|
|
|
|
)) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fn initialized_cli_store(data: &'static str) -> Result<TempDir> { |
|
|
|
fn initialized_cli_store(data: &'static str) -> Result<TempDir> { |
|
|
|
let store_dir = TempDir::new()?; |
|
|
|
let store_dir = TempDir::new()?; |
|
|
|
cli_command()? |
|
|
|
cli_command() |
|
|
|
.arg("load") |
|
|
|
.arg("load") |
|
|
|
.arg("--location") |
|
|
|
.arg("--location") |
|
|
|
.arg(store_dir.path()) |
|
|
|
.arg(store_dir.path()) |
|
|
@ -1889,8 +1885,8 @@ mod tests { |
|
|
|
Ok(store_dir) |
|
|
|
Ok(store_dir) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fn assert_cli_state(store_dir: &TempDir, data: &'static str) -> Result<()> { |
|
|
|
fn assert_cli_state(store_dir: &TempDir, data: &'static str) { |
|
|
|
cli_command()? |
|
|
|
cli_command() |
|
|
|
.arg("dump") |
|
|
|
.arg("dump") |
|
|
|
.arg("--location") |
|
|
|
.arg("--location") |
|
|
|
.arg(store_dir.path()) |
|
|
|
.arg(store_dir.path()) |
|
|
@ -1899,17 +1895,15 @@ mod tests { |
|
|
|
.assert() |
|
|
|
.assert() |
|
|
|
.stdout(data) |
|
|
|
.stdout(data) |
|
|
|
.success(); |
|
|
|
.success(); |
|
|
|
Ok(()) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
#[test] |
|
|
|
fn cli_help() -> Result<()> { |
|
|
|
fn cli_help() { |
|
|
|
cli_command()? |
|
|
|
cli_command() |
|
|
|
.assert() |
|
|
|
.assert() |
|
|
|
.failure() |
|
|
|
.failure() |
|
|
|
.stdout("") |
|
|
|
.stdout("") |
|
|
|
.stderr(predicate::str::starts_with("Oxigraph")); |
|
|
|
.stderr(predicate::str::contains("Oxigraph")); |
|
|
|
Ok(()) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
#[test] |
|
|
@ -1917,7 +1911,7 @@ mod tests { |
|
|
|
let store_dir = TempDir::new()?; |
|
|
|
let store_dir = TempDir::new()?; |
|
|
|
let input_file = NamedTempFile::new("input.ttl")?; |
|
|
|
let input_file = NamedTempFile::new("input.ttl")?; |
|
|
|
input_file.write_str("<s> <http://example.com/p> <http://example.com/o> .")?; |
|
|
|
input_file.write_str("<s> <http://example.com/p> <http://example.com/o> .")?; |
|
|
|
cli_command()? |
|
|
|
cli_command() |
|
|
|
.arg("load") |
|
|
|
.arg("load") |
|
|
|
.arg("--location") |
|
|
|
.arg("--location") |
|
|
|
.arg(store_dir.path()) |
|
|
|
.arg(store_dir.path()) |
|
|
@ -1928,7 +1922,7 @@ mod tests { |
|
|
|
.assert() |
|
|
|
.assert() |
|
|
|
.success(); |
|
|
|
.success(); |
|
|
|
|
|
|
|
|
|
|
|
cli_command()? |
|
|
|
cli_command() |
|
|
|
.arg("optimize") |
|
|
|
.arg("optimize") |
|
|
|
.arg("--location") |
|
|
|
.arg("--location") |
|
|
|
.arg(store_dir.path()) |
|
|
|
.arg(store_dir.path()) |
|
|
@ -1936,7 +1930,7 @@ mod tests { |
|
|
|
.success(); |
|
|
|
.success(); |
|
|
|
|
|
|
|
|
|
|
|
let output_file = NamedTempFile::new("output.nt")?; |
|
|
|
let output_file = NamedTempFile::new("output.nt")?; |
|
|
|
cli_command()? |
|
|
|
cli_command() |
|
|
|
.arg("dump") |
|
|
|
.arg("dump") |
|
|
|
.arg("--location") |
|
|
|
.arg("--location") |
|
|
|
.arg(store_dir.path()) |
|
|
|
.arg(store_dir.path()) |
|
|
@ -1957,7 +1951,7 @@ mod tests { |
|
|
|
let input_file = NamedTempFile::new("input.nq")?; |
|
|
|
let input_file = NamedTempFile::new("input.nq")?; |
|
|
|
input_file |
|
|
|
input_file |
|
|
|
.write_str("<http://example.com/s> <http://example.com/p> <http://example.com/o> <http://example.com/g> .")?; |
|
|
|
.write_str("<http://example.com/s> <http://example.com/p> <http://example.com/o> <http://example.com/g> .")?; |
|
|
|
cli_command()? |
|
|
|
cli_command() |
|
|
|
.arg("load") |
|
|
|
.arg("load") |
|
|
|
.arg("--location") |
|
|
|
.arg("--location") |
|
|
|
.arg(store_dir.path()) |
|
|
|
.arg(store_dir.path()) |
|
|
@ -1967,7 +1961,7 @@ mod tests { |
|
|
|
.success(); |
|
|
|
.success(); |
|
|
|
|
|
|
|
|
|
|
|
let output_file = NamedTempFile::new("output.nq")?; |
|
|
|
let output_file = NamedTempFile::new("output.nq")?; |
|
|
|
cli_command()? |
|
|
|
cli_command() |
|
|
|
.arg("dump") |
|
|
|
.arg("dump") |
|
|
|
.arg("--location") |
|
|
|
.arg("--location") |
|
|
|
.arg(store_dir.path()) |
|
|
|
.arg(store_dir.path()) |
|
|
@ -1988,7 +1982,7 @@ mod tests { |
|
|
|
encoder |
|
|
|
encoder |
|
|
|
.write_all(b"<http://example.com/s> <http://example.com/p> <http://example.com/o> .")?; |
|
|
|
.write_all(b"<http://example.com/s> <http://example.com/p> <http://example.com/o> .")?; |
|
|
|
file.write_binary(&encoder.finish()?)?; |
|
|
|
file.write_binary(&encoder.finish()?)?; |
|
|
|
cli_command()? |
|
|
|
cli_command() |
|
|
|
.arg("load") |
|
|
|
.arg("load") |
|
|
|
.arg("-l") |
|
|
|
.arg("-l") |
|
|
|
.arg(store_dir.path()) |
|
|
|
.arg(store_dir.path()) |
|
|
@ -1997,7 +1991,7 @@ mod tests { |
|
|
|
.assert() |
|
|
|
.assert() |
|
|
|
.success(); |
|
|
|
.success(); |
|
|
|
|
|
|
|
|
|
|
|
cli_command()? |
|
|
|
cli_command() |
|
|
|
.arg("dump") |
|
|
|
.arg("dump") |
|
|
|
.arg("-l") |
|
|
|
.arg("-l") |
|
|
|
.arg(store_dir.path()) |
|
|
|
.arg(store_dir.path()) |
|
|
@ -2016,7 +2010,7 @@ mod tests { |
|
|
|
input_file.write_str( |
|
|
|
input_file.write_str( |
|
|
|
"<http://example.com/s> <http://example.com/p> <http://example.com/o> .\n", |
|
|
|
"<http://example.com/s> <http://example.com/p> <http://example.com/o> .\n", |
|
|
|
)?; |
|
|
|
)?; |
|
|
|
cli_command()? |
|
|
|
cli_command() |
|
|
|
.arg("load") |
|
|
|
.arg("load") |
|
|
|
.arg("-l") |
|
|
|
.arg("-l") |
|
|
|
.arg(store_dir.path()) |
|
|
|
.arg(store_dir.path()) |
|
|
@ -2028,7 +2022,7 @@ mod tests { |
|
|
|
.success(); |
|
|
|
.success(); |
|
|
|
|
|
|
|
|
|
|
|
let output_file = NamedTempFile::new("output.nt")?; |
|
|
|
let output_file = NamedTempFile::new("output.nt")?; |
|
|
|
cli_command()? |
|
|
|
cli_command() |
|
|
|
.arg("dump") |
|
|
|
.arg("dump") |
|
|
|
.arg("-l") |
|
|
|
.arg("-l") |
|
|
|
.arg(store_dir.path()) |
|
|
|
.arg(store_dir.path()) |
|
|
@ -2049,7 +2043,7 @@ mod tests { |
|
|
|
let input_file = NamedTempFile::new("input")?; |
|
|
|
let input_file = NamedTempFile::new("input")?; |
|
|
|
input_file |
|
|
|
input_file |
|
|
|
.write_str("<http://example.com/s> <http://example.com/p> <http://example.com/o> .")?; |
|
|
|
.write_str("<http://example.com/s> <http://example.com/p> <http://example.com/o> .")?; |
|
|
|
cli_command()? |
|
|
|
cli_command() |
|
|
|
.arg("load") |
|
|
|
.arg("load") |
|
|
|
.arg("-l") |
|
|
|
.arg("-l") |
|
|
|
.arg(store_dir.path()) |
|
|
|
.arg(store_dir.path()) |
|
|
@ -2061,7 +2055,7 @@ mod tests { |
|
|
|
.success(); |
|
|
|
.success(); |
|
|
|
|
|
|
|
|
|
|
|
let output_file = NamedTempFile::new("output")?; |
|
|
|
let output_file = NamedTempFile::new("output")?; |
|
|
|
cli_command()? |
|
|
|
cli_command() |
|
|
|
.arg("dump") |
|
|
|
.arg("dump") |
|
|
|
.arg("--location") |
|
|
|
.arg("--location") |
|
|
|
.arg(store_dir.path()) |
|
|
|
.arg(store_dir.path()) |
|
|
@ -2081,7 +2075,7 @@ mod tests { |
|
|
|
#[test] |
|
|
|
#[test] |
|
|
|
fn cli_load_from_stdin_and_dump_to_stdout() -> Result<()> { |
|
|
|
fn cli_load_from_stdin_and_dump_to_stdout() -> Result<()> { |
|
|
|
let store_dir = TempDir::new()?; |
|
|
|
let store_dir = TempDir::new()?; |
|
|
|
cli_command()? |
|
|
|
cli_command() |
|
|
|
.arg("load") |
|
|
|
.arg("load") |
|
|
|
.arg("--location") |
|
|
|
.arg("--location") |
|
|
|
.arg(store_dir.path()) |
|
|
|
.arg(store_dir.path()) |
|
|
@ -2091,7 +2085,7 @@ mod tests { |
|
|
|
.assert() |
|
|
|
.assert() |
|
|
|
.success(); |
|
|
|
.success(); |
|
|
|
|
|
|
|
|
|
|
|
cli_command()? |
|
|
|
cli_command() |
|
|
|
.arg("dump") |
|
|
|
.arg("dump") |
|
|
|
.arg("--location") |
|
|
|
.arg("--location") |
|
|
|
.arg(store_dir.path()) |
|
|
|
.arg(store_dir.path()) |
|
|
@ -2111,7 +2105,7 @@ mod tests { |
|
|
|
|
|
|
|
|
|
|
|
let backup_dir = TempDir::new()?; |
|
|
|
let backup_dir = TempDir::new()?; |
|
|
|
remove_dir_all(backup_dir.path())?; // The directory should not exist yet
|
|
|
|
remove_dir_all(backup_dir.path())?; // The directory should not exist yet
|
|
|
|
cli_command()? |
|
|
|
cli_command() |
|
|
|
.arg("backup") |
|
|
|
.arg("backup") |
|
|
|
.arg("--location") |
|
|
|
.arg("--location") |
|
|
|
.arg(store_dir.path()) |
|
|
|
.arg(store_dir.path()) |
|
|
@ -2123,7 +2117,8 @@ mod tests { |
|
|
|
assert_cli_state( |
|
|
|
assert_cli_state( |
|
|
|
&store_dir, |
|
|
|
&store_dir, |
|
|
|
"<http://example.com/s> <http://example.com/p> <http://example.com/o> .\n", |
|
|
|
"<http://example.com/s> <http://example.com/p> <http://example.com/o> .\n", |
|
|
|
) |
|
|
|
); |
|
|
|
|
|
|
|
Ok(()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
#[test] |
|
|
@ -2131,7 +2126,7 @@ mod tests { |
|
|
|
let store_dir = initialized_cli_store( |
|
|
|
let store_dir = initialized_cli_store( |
|
|
|
"<http://example.com/s> <http://example.com/p> <http://example.com/o> .", |
|
|
|
"<http://example.com/s> <http://example.com/p> <http://example.com/o> .", |
|
|
|
)?; |
|
|
|
)?; |
|
|
|
cli_command()? |
|
|
|
cli_command() |
|
|
|
.arg("query") |
|
|
|
.arg("query") |
|
|
|
.arg("--location") |
|
|
|
.arg("--location") |
|
|
|
.arg(store_dir.path()) |
|
|
|
.arg(store_dir.path()) |
|
|
@ -2152,7 +2147,7 @@ mod tests { |
|
|
|
let store_dir = initialized_cli_store( |
|
|
|
let store_dir = initialized_cli_store( |
|
|
|
"<http://example.com/s> <http://example.com/p> <http://example.com/o> .", |
|
|
|
"<http://example.com/s> <http://example.com/p> <http://example.com/o> .", |
|
|
|
)?; |
|
|
|
)?; |
|
|
|
cli_command()? |
|
|
|
cli_command() |
|
|
|
.arg("query") |
|
|
|
.arg("query") |
|
|
|
.arg("--location") |
|
|
|
.arg("--location") |
|
|
|
.arg(store_dir.path()) |
|
|
|
.arg(store_dir.path()) |
|
|
@ -2175,7 +2170,7 @@ mod tests { |
|
|
|
let input_file = NamedTempFile::new("input.rq")?; |
|
|
|
let input_file = NamedTempFile::new("input.rq")?; |
|
|
|
input_file.write_str("SELECT ?s WHERE { ?s ?p ?o }")?; |
|
|
|
input_file.write_str("SELECT ?s WHERE { ?s ?p ?o }")?; |
|
|
|
let output_file = NamedTempFile::new("output.tsv")?; |
|
|
|
let output_file = NamedTempFile::new("output.tsv")?; |
|
|
|
cli_command()? |
|
|
|
cli_command() |
|
|
|
.arg("query") |
|
|
|
.arg("query") |
|
|
|
.arg("--location") |
|
|
|
.arg("--location") |
|
|
|
.arg(store_dir.path()) |
|
|
|
.arg(store_dir.path()) |
|
|
@ -2192,7 +2187,7 @@ mod tests { |
|
|
|
#[test] |
|
|
|
#[test] |
|
|
|
fn cli_ask_update_inline() -> Result<()> { |
|
|
|
fn cli_ask_update_inline() -> Result<()> { |
|
|
|
let store_dir = TempDir::new()?; |
|
|
|
let store_dir = TempDir::new()?; |
|
|
|
cli_command()? |
|
|
|
cli_command() |
|
|
|
.arg("update") |
|
|
|
.arg("update") |
|
|
|
.arg("--location") |
|
|
|
.arg("--location") |
|
|
|
.arg(store_dir.path()) |
|
|
|
.arg(store_dir.path()) |
|
|
@ -2205,13 +2200,14 @@ mod tests { |
|
|
|
assert_cli_state( |
|
|
|
assert_cli_state( |
|
|
|
&store_dir, |
|
|
|
&store_dir, |
|
|
|
"<http://example.com/s> <http://example.com/p> <http://example.com/o> .\n", |
|
|
|
"<http://example.com/s> <http://example.com/p> <http://example.com/o> .\n", |
|
|
|
) |
|
|
|
); |
|
|
|
|
|
|
|
Ok(()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
#[test] |
|
|
|
fn cli_construct_update_stdin() -> Result<()> { |
|
|
|
fn cli_construct_update_stdin() -> Result<()> { |
|
|
|
let store_dir = TempDir::new()?; |
|
|
|
let store_dir = TempDir::new()?; |
|
|
|
cli_command()? |
|
|
|
cli_command() |
|
|
|
.arg("update") |
|
|
|
.arg("update") |
|
|
|
.arg("--location") |
|
|
|
.arg("--location") |
|
|
|
.arg(store_dir.path()) |
|
|
|
.arg(store_dir.path()) |
|
|
@ -2223,7 +2219,8 @@ mod tests { |
|
|
|
assert_cli_state( |
|
|
|
assert_cli_state( |
|
|
|
&store_dir, |
|
|
|
&store_dir, |
|
|
|
"<http://example.com/s> <http://example.com/p> <http://example.com/o> .\n", |
|
|
|
"<http://example.com/s> <http://example.com/p> <http://example.com/o> .\n", |
|
|
|
) |
|
|
|
); |
|
|
|
|
|
|
|
Ok(()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
#[test] |
|
|
@ -2233,7 +2230,7 @@ mod tests { |
|
|
|
input_file.write_str( |
|
|
|
input_file.write_str( |
|
|
|
"INSERT DATA { <http://example.com/s> <http://example.com/p> <http://example.com/o> }", |
|
|
|
"INSERT DATA { <http://example.com/s> <http://example.com/p> <http://example.com/o> }", |
|
|
|
)?; |
|
|
|
)?; |
|
|
|
cli_command()? |
|
|
|
cli_command() |
|
|
|
.arg("update") |
|
|
|
.arg("update") |
|
|
|
.arg("--location") |
|
|
|
.arg("--location") |
|
|
|
.arg(store_dir.path()) |
|
|
|
.arg(store_dir.path()) |
|
|
@ -2244,7 +2241,8 @@ mod tests { |
|
|
|
assert_cli_state( |
|
|
|
assert_cli_state( |
|
|
|
&store_dir, |
|
|
|
&store_dir, |
|
|
|
"<http://example.com/s> <http://example.com/p> <http://example.com/o> .\n", |
|
|
|
"<http://example.com/s> <http://example.com/p> <http://example.com/o> .\n", |
|
|
|
) |
|
|
|
); |
|
|
|
|
|
|
|
Ok(()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
#[test] |
|
|
@ -2252,7 +2250,7 @@ mod tests { |
|
|
|
let input_file = NamedTempFile::new("input.ttl")?; |
|
|
|
let input_file = NamedTempFile::new("input.ttl")?; |
|
|
|
input_file.write_str("@prefix schema: <http://schema.org/> .\n<http://example.com#me> a schema:Person ;\n\tschema:name \"Foo Bar\"@en .\n")?; |
|
|
|
input_file.write_str("@prefix schema: <http://schema.org/> .\n<http://example.com#me> a schema:Person ;\n\tschema:name \"Foo Bar\"@en .\n")?; |
|
|
|
let output_file = NamedTempFile::new("output.rdf")?; |
|
|
|
let output_file = NamedTempFile::new("output.rdf")?; |
|
|
|
cli_command()? |
|
|
|
cli_command() |
|
|
|
.arg("convert") |
|
|
|
.arg("convert") |
|
|
|
.arg("--from-file") |
|
|
|
.arg("--from-file") |
|
|
|
.arg(input_file.path()) |
|
|
|
.arg(input_file.path()) |
|
|
@ -2268,8 +2266,8 @@ mod tests { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
#[test] |
|
|
|
fn cli_convert_from_default_graph_to_named_graph() -> Result<()> { |
|
|
|
fn cli_convert_from_default_graph_to_named_graph() { |
|
|
|
cli_command()? |
|
|
|
cli_command() |
|
|
|
.arg("convert") |
|
|
|
.arg("convert") |
|
|
|
.arg("--from-format") |
|
|
|
.arg("--from-format") |
|
|
|
.arg("trig") |
|
|
|
.arg("trig") |
|
|
@ -2282,12 +2280,11 @@ mod tests { |
|
|
|
.assert() |
|
|
|
.assert() |
|
|
|
.stdout("<http://example.com/s> <http://example.com/p> <http://example.com/o> <http://example.com/t> .\n") |
|
|
|
.stdout("<http://example.com/s> <http://example.com/p> <http://example.com/o> <http://example.com/t> .\n") |
|
|
|
.success(); |
|
|
|
.success(); |
|
|
|
Ok(()) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
#[test] |
|
|
|
fn cli_convert_from_named_graph() -> Result<()> { |
|
|
|
fn cli_convert_from_named_graph() { |
|
|
|
cli_command()? |
|
|
|
cli_command() |
|
|
|
.arg("convert") |
|
|
|
.arg("convert") |
|
|
|
.arg("--from-format") |
|
|
|
.arg("--from-format") |
|
|
|
.arg("trig") |
|
|
|
.arg("trig") |
|
|
@ -2298,7 +2295,6 @@ mod tests { |
|
|
|
.write_stdin("@base <http://example.com/> . <s> <p> <o> . <g> { <sg> <pg> <og> . }") |
|
|
|
.write_stdin("@base <http://example.com/> . <s> <p> <o> . <g> { <sg> <pg> <og> . }") |
|
|
|
.assert() |
|
|
|
.assert() |
|
|
|
.stdout("<http://example.com/sg> <http://example.com/pg> <http://example.com/og> .\n"); |
|
|
|
.stdout("<http://example.com/sg> <http://example.com/pg> <http://example.com/og> .\n"); |
|
|
|
Ok(()) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
#[test] |
|
|
|