diff options
Diffstat (limited to '')
| -rw-r--r-- | tests/server_core.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/server_core.rs b/tests/server_core.rs index 3f5dc9a..cab74a7 100644 --- a/tests/server_core.rs +++ b/tests/server_core.rs | |||
| @@ -137,6 +137,33 @@ fn a_malicious_username_cannot_change_another_balance() { | |||
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | #[test] | 139 | #[test] |
| 140 | fn plays_record_the_game_type_and_game_specific_details() { | ||
| 141 | let (mut core, path) = setup("details", WIN3); | ||
| 142 | let mut state = ConnectionState::default(); | ||
| 143 | register(&mut core, &mut state, "alice"); | ||
| 144 | login(&mut core, &mut state, "alice"); | ||
| 145 | |||
| 146 | let response = core.handle_message(&mut state, "PLAY_START slots 10"); | ||
| 147 | assert!(response.starts_with("GAME_RESULT"), "spin failed: {response}"); | ||
| 148 | |||
| 149 | let conn = Connection::open(&path).unwrap(); | ||
| 150 | let (game_type, details): (String, String) = conn | ||
| 151 | .query_row( | ||
| 152 | "SELECT game_type, details FROM plays WHERE username = 'alice'", | ||
| 153 | [], | ||
| 154 | |row| Ok((row.get(0)?, row.get(1)?)), | ||
| 155 | ) | ||
| 156 | .unwrap(); | ||
| 157 | |||
| 158 | assert_eq!(game_type, "slots"); | ||
| 159 | let details: serde_json::Value = serde_json::from_str(&details).unwrap(); | ||
| 160 | assert_eq!(details["reels"], "CCCCLLCLODGSDGS"); | ||
| 161 | assert_eq!(details["win_type"], "win"); | ||
| 162 | assert_eq!(details["win_lines"], "1"); | ||
| 163 | assert_eq!(details["win_cells"], "0,3,6"); | ||
| 164 | } | ||
| 165 | |||
| 166 | #[test] | ||
| 140 | fn a_failed_audit_insert_rolls_back_the_balance_change() { | 167 | fn a_failed_audit_insert_rolls_back_the_balance_change() { |
| 141 | let (mut core, path) = setup("rollback", LOSS); | 168 | let (mut core, path) = setup("rollback", LOSS); |
| 142 | let mut state = ConnectionState::default(); | 169 | let mut state = ConnectionState::default(); |
