Skip to content

Commit

Permalink
ci: Add internal tests
Browse files Browse the repository at this point in the history
  • Loading branch information
attakei committed Mar 30, 2024
1 parent 594579d commit 5a66b35
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,37 @@ impl WriteRule {
return output.join("\n");
}
}

#[cfg(test)]
mod tests {
use super::*;

use semver::Version;

#[test]
fn new_writer() {
let ctx = Context::new();
let writer = Writer::new(&ctx);
assert_eq!(writer.targets.len(), 0);
}

#[test]
fn dual_rule_in_single_file() {
let mut ctx = Context::new();
ctx.insert("current_version", &Version::new(0, 1, 0));
ctx.insert("new_version", &Version::new(0, 2, 0));
let mut writer = Writer::new(&ctx);
let filepath = PathBuf::from("dummy.txt");
writer.add_target(
&filepath,
&String::from("target-1"),
&String::from("replace-2"),
);
writer.add_target(
&filepath,
&String::from("target-2"),
&String::from("replace-2"),
);
assert_eq!(writer.targets.len(), 1);
}
}

0 comments on commit 5a66b35

Please sign in to comment.