Skip to content

Commit

Permalink
fix config path
Browse files Browse the repository at this point in the history
  • Loading branch information
YuliaProkopovych committed Apr 9, 2024
1 parent c4e9d99 commit 595d760
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 7 deletions.
8 changes: 6 additions & 2 deletions module/move/unitore/src/action/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,13 @@ pub async fn config_add( storage : FeedStorage< SledStorage >, args : &wca::Args
if !path.exists()
{
return Err( error_tools::for_app::Error::msg( err_str ) );
}
}

let config = Config::new( path.to_string_lossy().to_string() );
//let abs_path = proper_path_tools::path::canonicalize( path )?;
let abs_path = path.canonicalize()?;
println!("{}", abs_path.to_string_lossy().to_string() );

let config = Config::new( abs_path.to_string_lossy().to_string() );
let mut manager = FeedManager::new( storage );

let config_report = manager.storage
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
use std::path::PathBuf;

use gluesql::sled_storage::sled::Config;
use gluesql::{
sled_storage::sled::Config,
test_suite::data_type::list,
prelude::Payload::Select,
};
use unitore::
{
executor::FeedManager,
storage::FeedStorage,
entity::feed::FeedStore,
entity::{ feed::FeedStore, config::ConfigStore },
action::config,
};
use error_tools::Result;

#[ tokio::test ]
async fn add_config_file() -> Result< () >
async fn config_add() -> Result< () >
{
let path = PathBuf::from( "./tests/fixtures/test_config.toml" );
let path = path.canonicalize().expect( "Invalid path" );

let config = Config::default()
.path( "./test".to_owned() )
.path( "./test_add".to_owned() )
.temporary( true )
;

Expand All @@ -39,3 +42,32 @@ async fn add_config_file() -> Result< () >

Ok( () )
}

#[ tokio::test ]
async fn config_delete() -> Result< () >
{
let path = PathBuf::from( "./tests/fixtures/test_config.toml" );

let config = Config::default()
.path( "./test_del".to_owned() )
.temporary( true )
;

let mut feed_storage = FeedStorage::init_storage( &config ).await?;
config::config_add( feed_storage.clone(), &wca::Args( vec![ wca::Value::Path( path.clone() ) ] ) ).await?;

config::config_delete( feed_storage.clone(), &wca::Args( vec![ wca::Value::Path( path ) ] ) ).await?;

let list = feed_storage.config_list().await?;

if let Select{ labels, rows } = list
{
assert!( rows.len() == 0 )
}
else
{
assert!( false );
}

Ok( () )
}

0 comments on commit 595d760

Please sign in to comment.