Skip to content

Commit

Permalink
re-design test of changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
jellllly420 committed May 1, 2023
1 parent 4de50cc commit ff6cd17
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 11 deletions.
2 changes: 1 addition & 1 deletion tools/changelog/src/write_changelog_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub fn write_changelog(changelog_path: &str, version_changelog: &[u8]) -> Result
.context(format!("could not open {changelog_path} for reading"))?;
let old_changelog_reader = BufReader::new(old_changelog);

let changelog_path_new = &format!("../{changelog_path}.new");
let changelog_path_new = &format!("{changelog_path}.new");

let mut new_changelog = fs::OpenOptions::new()
.write(true)
Expand Down
37 changes: 27 additions & 10 deletions tools/changelog/tests/generate_yew_changelog_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,12 @@ impl Drop for FileDeleteOnDrop {
}
}

#[test]
fn generate_yew_changelog_file() -> Result<()> {
// Setup
let file_delete_on_drop = FileDeleteOnDrop;

fs::copy("tests/test_base.md", "tests/test_changelog.md")?;

// Run
fn _generate_yew_changelog_file(from: &str, to: &str) -> Result<()> {
let cli_args = Cli {
package: YewPackage::from_str("yew").unwrap(),
new_version_level: NewVersionLevel::Minor,
from: Some("abeb8bc3f1ffabc8a58bd9ba4430cd091a06335a".to_string()),
to: "d8ec50150ed27e2835bb1def26d2371a8c2ab750".to_string(),
from: Some(from.to_string()),
to: to.to_string(),
changelog_path: "tests/test_changelog.md".to_string(),
skip_file_write: false,
skip_get_bump_version: true,
Expand All @@ -38,6 +31,23 @@ fn generate_yew_changelog_file() -> Result<()> {

cli_args.run().unwrap();

Ok(())
}

#[test]
fn generate_yew_changelog_file() -> Result<()> {
// Setup
let file_delete_on_drop = FileDeleteOnDrop;

fs::copy("tests/test_base.md", "tests/test_changelog.md")?;

// Run
_generate_yew_changelog_file("abeb8bc3f1ffabc8a58bd9ba4430cd091a06335a",
"d8ec50150ed27e2835bb1def26d2371a8c2ab750")?;

_generate_yew_changelog_file("8086a73a217a099a46138f4363411827b18d1cb0",
"934aedbc8815fd77fc6630b644cfea4f9a071236")?;

// Check
let expected = File::open("tests/test_expected.md")?;
let expected_reader_lines = BufReader::new(expected).lines();
Expand All @@ -55,6 +65,13 @@ fn generate_yew_changelog_file() -> Result<()> {
Utc::now().format("%Y-%m-%d").to_string().as_str(),
);
assert_eq!(expected_third_line, after_line?);
} else if i == 13 {
// thirteenth line has dynamic things that may break the tests
let expected_thirteenth_line = expected_line?.replace(
"date_goes_here",
Utc::now().format("%Y-%m-%d").to_string().as_str(),
);
assert_eq!(expected_thirteenth_line, after_line?);
} else {
assert_eq!(expected_line?, after_line?);
}
Expand Down
11 changes: 11 additions & 0 deletions tools/changelog/tests/test_expected.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

## ✨ yew **0.0.0** *(date_goes_here)* Changelog

### ⚡️ Features

- Incremental performance improvements to element creation. [[@Greg Johnston](https://github.com/Greg Johnston), [#3169](https://github.com/yewstack/yew/pull/3169)]

### 🚨 Breaking changes

- Enable PartialEq for all virtual dom types. [[@Kaede Hoshikawa](https://github.com/Kaede Hoshikawa), [#3206](https://github.com/yewstack/yew/pull/3206)]
- Pass hook dependencies as the first function argument. [[@Arniu Tseng](https://github.com/Arniu Tseng), [#2861](https://github.com/yewstack/yew/pull/2861)]

## ✨ yew **0.0.0** *(date_goes_here)* Changelog

### 🛠 Fixes

- Fix defaulted type parameter.. [[@futursolo](https://github.com/futursolo), [#2284](https://github.com/yewstack/yew/pull/2284)]
Expand Down

0 comments on commit ff6cd17

Please sign in to comment.