Skip to content

Commit 587d7cd

Browse files
committed
bump to 0.2.0a9
1 parent 7e0d05d commit 587d7cd

File tree

3 files changed

+66
-23
lines changed

3 files changed

+66
-23
lines changed

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ members = [
77
resolver = "2"
88

99
[workspace.package]
10-
version = "0.2.0-a8"
10+
version = "0.2.0-a9"
1111
authors = ["Gabe Fierro <[email protected]>"]
1212
license = "BSD-3-Clause"
1313
edition = "2021"
@@ -35,7 +35,7 @@ clap = { version = "4.4.18", features = ["derive"] }
3535
derive_builder = "0.20"
3636
oxigraph = "0.4.4"
3737

38-
ontoenv = { version = "0.2.0-a8", path = "lib" }
38+
ontoenv = { version = "0.2.0-a9", path = "lib" }
3939

4040
[profile.profiling]
4141
inherits = "release"

lib/tests/ontoenv_test.rs

Lines changed: 61 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,6 @@ fn test_ontoenv_dag_structure() -> Result<()> {
477477
Ok(())
478478
}
479479

480-
481480
// === Initialization Tests Translated from Python ===
482481

483482
#[test]
@@ -488,7 +487,7 @@ fn test_init_with_config_new_dir() -> Result<()> {
488487
assert!(!env_path.exists());
489488

490489
let cfg = Config::new(
491-
env_path.clone(), // root path
490+
env_path.clone(), // root path
492491
Some(vec![env_path.clone()]), // search paths
493492
&["*.ttl"],
494493
&[""],
@@ -524,7 +523,14 @@ fn test_init_with_config_existing_empty_dir() -> Result<()> {
524523
env_path.clone(),
525524
Some(vec![env_path.clone()]),
526525
&["*.ttl"],
527-
&[""], false, false, false, "default".to_string(), false, false)?;
526+
&[""],
527+
false,
528+
false,
529+
false,
530+
"default".to_string(),
531+
false,
532+
false,
533+
)?;
528534

529535
// Initialize with recreate=true
530536
let env = OntoEnv::init(cfg, true)?;
@@ -548,7 +554,15 @@ fn test_init_load_from_existing_dir() -> Result<()> {
548554
let cfg = Config::new(
549555
env_path.clone(),
550556
Some(vec![env_path.clone()]),
551-
&["*.ttl"], &[""], false, false, false, "default".to_string(), false, false)?;
557+
&["*.ttl"],
558+
&[""],
559+
false,
560+
false,
561+
false,
562+
"default".to_string(),
563+
false,
564+
false,
565+
)?;
552566
let mut initial_env = OntoEnv::init(cfg, true)?;
553567
initial_env.flush()?; // Ensure store is created/flushed
554568
let expected_store_path = initial_env.store_path().unwrap().to_path_buf();
@@ -575,7 +589,15 @@ fn test_init_recreate_existing_dir() -> Result<()> {
575589
let cfg = Config::new(
576590
env_path.clone(),
577591
Some(vec![env_path.clone()]),
578-
&["*.ttl"], &[""], false, false, false, "default".to_string(), false, false)?;
592+
&["*.ttl"],
593+
&[""],
594+
false,
595+
false,
596+
false,
597+
"default".to_string(),
598+
false,
599+
false,
600+
)?;
579601
let mut initial_env = OntoEnv::init(cfg.clone(), true)?;
580602
// Add a dummy file to check for removal
581603
let dummy_file_path = env_path.join(".ontoenv").join("dummy.txt");
@@ -609,7 +631,15 @@ fn test_init_read_only() -> Result<()> {
609631
let cfg = Config::new(
610632
env_path.clone(),
611633
Some(vec![env_path.clone()]),
612-
&["*.ttl"], &[""], false, false, false, "default".to_string(), false, false)?;
634+
&["*.ttl"],
635+
&[""],
636+
false,
637+
false,
638+
false,
639+
"default".to_string(),
640+
false,
641+
false,
642+
)?;
613643
let mut initial_env = OntoEnv::init(cfg, true)?;
614644
initial_env.flush()?;
615645
initial_env.save_to_directory()?;
@@ -621,7 +651,10 @@ fn test_init_read_only() -> Result<()> {
621651
// Attempting to modify should fail.
622652
// We need a file that *could* be added if not read-only.
623653
let dummy_ont_path = dir.path().join("dummy.ttl");
624-
std::fs::write(&dummy_ont_path, "<urn:dummy> a <http://www.w3.org/2002/07/owl#Ontology> .")?;
654+
std::fs::write(
655+
&dummy_ont_path,
656+
"<urn:dummy> a <http://www.w3.org/2002/07/owl#Ontology> .",
657+
)?;
625658
let location = OntologyLocation::File(dummy_ont_path);
626659

627660
// The OntoEnv::add method requires &mut self.
@@ -634,14 +667,15 @@ fn test_init_read_only() -> Result<()> {
634667
// Assuming ReadOnlyPersistentGraphIO::add returns a specific error.
635668
// If GraphIO trait doesn't have 'add', this test might need adjustment based on how OntoEnv handles it.
636669
// Let's assume GraphIO has 'add' and ReadOnly returns an error like below.
637-
assert!(add_result.unwrap_err().to_string().contains("Cannot add to read-only store"));
638-
670+
assert!(add_result
671+
.unwrap_err()
672+
.to_string()
673+
.contains("Cannot add to read-only store"));
639674

640675
teardown(dir);
641676
Ok(())
642677
}
643678

644-
645679
#[test]
646680
fn test_init_path_no_env_error() -> Result<()> {
647681
let dir = TempDir::new("ontoenv_path_no_env")?;
@@ -657,30 +691,32 @@ fn test_init_path_no_env_error() -> Result<()> {
657691
let err_msg = load_result.unwrap_err().to_string();
658692
// Check for the specific error message from load_from_directory
659693
let expected_meta_path = env_path.join(".ontoenv");
660-
assert!(err_msg.contains(&format!("OntoEnv directory not found at: {:?}", expected_meta_path)));
661-
694+
assert!(err_msg.contains(&format!(
695+
"OntoEnv directory not found at: {:?}",
696+
expected_meta_path
697+
)));
662698

663699
teardown(dir);
664700
Ok(())
665701
}
666702

667-
668703
#[test]
669704
fn test_init_temporary() -> Result<()> {
670705
let dir = TempDir::new("ontoenv_temporary")?;
671706
let env_path = dir.path().join("temp_env_root");
672707
// Temporary envs shouldn't persist to disk relative to root
673708

674709
let cfg = Config::new(
675-
env_path.clone(), // Root path (shouldn't be used for storage)
710+
env_path.clone(), // Root path (shouldn't be used for storage)
676711
Some(vec![env_path.clone()]), // Search path (can still be used)
677-
&["*.ttl"], &[""],
712+
&["*.ttl"],
713+
&[""],
678714
false, // require_ontology_names
679715
false, // strict
680716
false, // offline
681717
"default".to_string(),
682718
false, // search_imports
683-
true // temporary = true
719+
true, // temporary = true
684720
)?;
685721

686722
let mut env = OntoEnv::init(cfg, false)?; // recreate doesn't matter much for temp
@@ -694,15 +730,22 @@ fn test_init_temporary() -> Result<()> {
694730
// Check if adding works in memory (should not raise read-only error)
695731
// Create a dummy ontology file to add
696732
let dummy_ont_path = dir.path().join("dummy_temp.ttl");
697-
std::fs::write(&dummy_ont_path, "<urn:dummy_temp> a <http://www.w3.org/2002/07/owl#Ontology> .")?;
733+
std::fs::write(
734+
&dummy_ont_path,
735+
"<urn:dummy_temp> a <http://www.w3.org/2002/07/owl#Ontology> .",
736+
)?;
698737
let location = OntologyLocation::File(dummy_ont_path);
699738

700739
let add_result = env.add(location, false);
701740
assert!(add_result.is_ok()); // Should succeed in memory
702741

703742
// Verify the ontology was added (in memory)
704743
assert_eq!(env.ontologies().len(), 1);
705-
assert!(env.resolve(ResolveTarget::Graph(NamedNodeRef::new("urn:dummy_temp")?.into())).is_some());
744+
assert!(env
745+
.resolve(ResolveTarget::Graph(
746+
NamedNodeRef::new("urn:dummy_temp")?.into()
747+
))
748+
.is_some());
706749

707750
teardown(dir);
708751
Ok(())

0 commit comments

Comments
 (0)