Skip to content
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

[Enhancement] mkcws: Unit Tests #1010

Merged
merged 3 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions changelog.d/20240102_174335_GitHub_Actions_mkcws-tests.ron
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(
references: {},
changes: {
"Added": [
"mkcws: unit tests",
],
},
)
13 changes: 12 additions & 1 deletion src/utilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,20 @@ impl Mkcws {
self.output_file.truncate(Box::new(
"{ \"folders\" : [ { \"path\" : \"".to_string()
+ &format!("{}", self.directory.display())
+ "\", }, ], \"settings\" : [], }\n",
+ "\" } ] }\n",
))
}

/// Create a new instance.
pub fn new<T>(directory: T, output_file: Option<T>) -> Self
where
std::path::PathBuf: From<T>,
{
Self {
directory: std::path::PathBuf::from(directory),
output_file: output_file.map(Into::into),
}
}
}

/// Extract Markdown code from Rust documentation comments.
Expand Down
17 changes: 17 additions & 0 deletions tests/utilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,21 @@ make_test!(@rs2md @twice
rs2md_both_inner_and_outer -> true, true
);

#[cfg(feature = "mkcws")]
#[test]
fn mkcws() {
use aeruginous::ReadFile;

assert!(aeruginous::Mkcws::new(".", Some("cwd.code-workspace"))
.main()
.is_ok());

assert_eq!(
"cwd.code-workspace".read().unwrap(),
"{ \"folders\" : [ { \"path\" : \".\" } ] }\n"
);

std::fs::remove_file("cwd.code-workspace").unwrap();
}

/******************************************************************************/