aboutsummaryrefslogtreecommitdiff
path: root/planetwars-matchrunner/tests
diff options
context:
space:
mode:
authorIlion Beyst <ilion.beyst@gmail.com>2022-09-27 07:14:47 +0200
committerIlion Beyst <ilion.beyst@gmail.com>2022-09-27 07:14:47 +0200
commitf777baa4f22df1fabedc82dfc5e4470f632a1dad (patch)
tree1cdbe9ee8d3dfed2eed90f088fd8f79ba5dd8765 /planetwars-matchrunner/tests
parent2a37b96da2c713f706ad541f81c56dc4ef822f5f (diff)
downloadplanetwars.dev-f777baa4f22df1fabedc82dfc5e4470f632a1dad.tar.xz
planetwars.dev-f777baa4f22df1fabedc82dfc5e4470f632a1dad.zip
test playeroutcomes
Diffstat (limited to 'planetwars-matchrunner/tests')
-rw-r--r--planetwars-matchrunner/tests/test_matchrunner.rs31
1 files changed, 29 insertions, 2 deletions
diff --git a/planetwars-matchrunner/tests/test_matchrunner.rs b/planetwars-matchrunner/tests/test_matchrunner.rs
index caa78c0..43afd85 100644
--- a/planetwars-matchrunner/tests/test_matchrunner.rs
+++ b/planetwars-matchrunner/tests/test_matchrunner.rs
@@ -35,7 +35,7 @@ async fn match_does_run() {
let log_file = tempfile::NamedTempFile::new().unwrap();
let config = MatchConfig {
- map_name: "hex".to_string(),
+ map_name: "abc".to_string(),
map_path: PathBuf::from("maps/abc.json"),
log_path: PathBuf::from(log_file.path()),
players: vec![
@@ -52,8 +52,35 @@ async fn match_does_run() {
let line_count = std::io::BufReader::new(log_file.as_file()).lines().count();
assert!(line_count > 0);
+}
+
+#[tokio::test]
+async fn player_results() {
+ let log_file = tempfile::NamedTempFile::new().unwrap();
+
+ let config = MatchConfig {
+ map_name: "abc".to_string(),
+ map_path: PathBuf::from("maps/abc.json"),
+ log_path: PathBuf::from(log_file.path()),
+ players: vec![
+ MatchPlayer {
+ bot_spec: Box::new(simple_python_docker_bot_spec(
+ "./bots/simplebot",
+ "simplebot.py",
+ )),
+ },
+ MatchPlayer {
+ bot_spec: Box::new(simple_python_docker_bot_spec("./bots", "crash_bot.py")),
+ },
+ ],
+ };
- tokio::time::sleep(Duration::from_secs(1)).await
+ let outcome = run_match(config).await;
+ assert_eq!(outcome.player_outcomes.len(), 2);
+ assert!(!outcome.player_outcomes[0].crashed);
+ assert!(!outcome.player_outcomes[0].had_errors);
+ assert!(outcome.player_outcomes[1].crashed);
+ assert!(!outcome.player_outcomes[1].had_errors);
}
/// creates a simple match ctx which only holds a single bot