Skip to content

Commit a3c4cdd

Browse files
committed
add boilerplate for tests + move template to a new file
1 parent 618531b commit a3c4cdd

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

cargo-aoc/src/app.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ pub fn execute_credentials(args: &Credentials) {
4141
/// Executes the "input" subcommand of the app
4242
pub fn execute_input(args: &Input) -> Result<(), Box<dyn Error>> {
4343
// Gets the token or exit if it's not referenced.
44-
let token = CredentialsManager::new().get_session_token().expect(
45-
"Error: you need to setup your AOC token using \"cargo aoc credentials {token}\"",
46-
);
44+
let token = CredentialsManager::new()
45+
.get_session_token()
46+
.expect("Error: you need to setup your AOC token using \"cargo aoc credentials {token}\"");
4747

4848
let pm = ProjectManager::new()?;
4949

cargo-aoc/template/src/day.rs.tpl

+11-4
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,25 @@ fn part2(input: &str) -> String {
1414
todo!()
1515
}
1616

17-
1817
#[cfg(test)]
1918
mod tests {
2019
use super::*;
2120
2221
#[test]
2322
fn part1_example() {
24-
assert_eq!(part1(&parse("<EXAMPLE>")), "<RESULT>");
23+
let input = "";
24+
let output = "";
25+
26+
let input = parse(input);
27+
assert_eq!(part1(input), output);
2528
}
2629

2730
#[test]
2831
fn part2_example() {
29-
assert_eq!(part2(&parse("<EXAMPLE>")), "<RESULT>");
32+
let input = "";
33+
let output = "";
34+
35+
let input = parse(input);
36+
assert_eq!(part2(input), output);
3037
}
31-
}
38+
}

0 commit comments

Comments
 (0)