Skip to content

Commit 4830aeb

Browse files
committed
chore: Fix tests
1 parent 0e8cb65 commit 4830aeb

4 files changed

Lines changed: 11 additions & 7 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/change.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ impl Display for Change {
111111
pub struct UniqueId(String);
112112

113113
impl UniqueId {
114+
#[must_use]
114115
pub fn to_file_name(&self) -> String {
115116
format!("{self}.md")
116117
}
@@ -124,7 +125,7 @@ impl<T: AsRef<str>> From<T> for UniqueId {
124125
.filter_map(|c| {
125126
if c.is_ascii_alphanumeric() {
126127
Some(c.to_ascii_lowercase())
127-
} else if c == ' ' {
128+
} else if c == ' ' || c == '_' || c == '-' {
128129
Some('_')
129130
} else {
130131
None
@@ -145,7 +146,7 @@ impl Display for UniqueId {
145146
#[test]
146147
fn test_create_unique_id() {
147148
assert_eq!(
148-
UniqueId::from("`[i carry your heart with me(i carry it in]`").to_string(),
149+
UniqueId::from("`[i carry your_heart with-me(i carry it in]`").to_string(),
149150
"i_carry_your_heart_with_mei_carry_it_in"
150151
);
151152
}

tests/change.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
use changesets::{Change, ChangeType, Versioning};
1+
use changesets::{Change, ChangeType, UniqueId, Versioning};
22
use tempfile::tempdir;
33

44
#[test]
55
fn create_change() {
66
let basic_programmatic = Change {
7-
unique_id: String::from("basic_programmatic"),
7+
unique_id: UniqueId::from("basic_programmatic"),
88
versioning: Versioning::from(("my_package", ChangeType::Minor)),
99
summary: String::from("### This is a summary"),
1010
};
1111

1212
let multiple_packages = Change {
13-
unique_id: String::from("multiple_packages"),
13+
unique_id: UniqueId::from("multiple_packages"),
1414
versioning: Versioning::try_from_iter([
1515
("my_package", ChangeType::Minor),
1616
("my_other_package", ChangeType::Major),
@@ -54,7 +54,7 @@ fn load_change() {
5454

5555
let change = Change::from_file(&change_path).unwrap();
5656

57-
assert_eq!(change.unique_id, "a_change");
57+
assert_eq!(change.unique_id.to_string(), "a_change");
5858
assert_eq!(change.summary, "### This is a summary");
5959
assert_eq!(
6060
change.versioning,

tests/change_set.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ fn load_changeset() {
3737
assert_eq!(
3838
first_release.changes,
3939
vec![PackageChange {
40+
unique_id: first_change_name.into(),
4041
change_type: first_change_type,
4142
summary: first_change_summary.to_string()
4243
},]
@@ -47,10 +48,12 @@ fn load_changeset() {
4748
// Order of reading files is probably not guaranteed
4849
let first_variant = vec![
4950
PackageChange {
51+
unique_id: first_change_name.into(),
5052
change_type: second_package_type,
5153
summary: first_change_summary.to_string(),
5254
},
5355
PackageChange {
56+
unique_id: second_change_name.into(),
5457
change_type: second_change_type,
5558
summary: second_change_summary.to_string(),
5659
},

0 commit comments

Comments
 (0)