-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(#9): storage init #20
Conversation
@l3r8yJ I suggest the following test convention: all unit test we specify in the same |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@h1alexbel take a look, please
src/xml/storage.rs
Outdated
pub fn init() { | ||
let path = "fakehub.xml"; | ||
info!("Initializing XML storage: {path}"); | ||
File::create(path).unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think it would be better to handle result of creation File::create(path)
and give an human readable message in error case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@l3r8yJ did you meant foo.expect("some message after failure")
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@h1alexbel i meant smth like
let creating_file = File::create("storage.xml");
let storage = match creating_file {
Ok(file) => file,
Err(error) => panic!("Problem during creating the file: {:?}", error),
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, got it, thanks
Co-authored-by: Ivan Ivanchuk <[email protected]>
Co-authored-by: Ivan Ivanchuk <[email protected]>
Co-authored-by: Ivan Ivanchuk <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@h1alexbel last comment, take a look, please
src/xml/storage.rs
Outdated
let path = "fakehub.xml"; | ||
info!("Initializing XML storage: {path}"); | ||
let creating = File::create(path); | ||
let _ = match creating { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be we should return the file from touch_storage
and pass it to next function instead of sharing it by name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@h1alexbel a few changes
src/xml/storage.rs
Outdated
use crate::xml::storage::touch_storage; | ||
|
||
fn clean() { | ||
fs::remove_file("fakehub.xml").unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think better solution would be using temp files, like this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@l3r8yJ we create this file inside touch_storage()
, how we can create a temp file there? Or I miss something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@h1alexbel you can pass a temp directory and create file inside of it. I think that even better would be if touch_storage
will accept directory or smth like that
src/xml/storage.rs
Outdated
} | ||
|
||
#[test] | ||
fn creates_xml_storage() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
best practise is to return anyhow::Result<()>
and add Ok(())
at the end of test
Co-authored-by: Ivan Ivanchuk <[email protected]>
@h1alexbel yes, good idea |
@h1alexbel do you mind if I pull your branch and make some changes to it? |
@l3r8yJ no, but I already applied the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@h1alexbel looks good to me! added some fix
@l3r8yJ looks like |
@rultor merge |
|
@h1alexbel The pull request is closed already, so I can't merge it |
@h1alexbel I'm sorry, I don't understand you :( Check this page and try again please |
@l3r8yJ take a look, please
ref #9
PR-Codex overview
The focus of this PR is adding XML storage functionality with tests and updating dependencies.
Detailed summary
anyhow
,log
,env_logger
, andtempdir
dependenciesxml
module