an http based roguelike rpg about jelqing
Blame: src/tests.rs
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1 | use std::{sync::Arc, time::Duration}; |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 2 | |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 3 | use axum::{ |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 4 | Router, |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 5 | body::{Body, to_bytes}, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 6 | http::{Method, Request, StatusCode, Version, header}, |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 7 | response::Response, |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 8 | }; |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 9 | use serde_json::Value; |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 10 | use tower::ServiceExt; |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 11 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 12 | use crate::{ |
782069860236 | atagen | 2026-10-10 12:44 UTC | 13 | AppState, Config, |
139164489032 | atagen | 2026-10-11 05:46 UTC | 14 | game::{ |
139164489032 | atagen | 2026-10-11 05:46 UTC | 15 | Floor, MumVisit, Run, Story, |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 16 | balance::{BRANCH_TURN, STORAGE_GIRTH, SUSPICION_LIMIT}, |
139164489032 | atagen | 2026-10-11 05:46 UTC | 17 | }, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 18 | router, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 19 | }; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 20 | |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 21 | async fn send( |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 22 | app: &Router, |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 23 | method: &str, |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 24 | uri: &str, |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 25 | headers: &[(&str, &str)], |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 26 | body: &str, |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 27 | ) -> Response { |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 28 | let mut request = Request::builder() |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 29 | .method(Method::from_bytes(method.as_bytes()).unwrap()) |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 30 | .uri(uri); |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 31 | for (name, value) in headers { |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 32 | request = request.header(*name, *value); |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 33 | } |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 34 | app.clone() |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 35 | .oneshot(request.body(Body::from(body.to_owned())).unwrap()) |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 36 | .await |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 37 | .unwrap() |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 38 | } |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 39 | |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 40 | async fn json(response: Response) -> Value { |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 41 | serde_json::from_slice(&to_bytes(response.into_body(), usize::MAX).await.unwrap()).unwrap() |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 42 | } |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 43 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 44 | async fn text(response: Response) -> String { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 45 | String::from_utf8( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 46 | to_bytes(response.into_body(), usize::MAX) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 47 | .await |
782069860236 | atagen | 2026-10-10 12:44 UTC | 48 | .unwrap() |
782069860236 | atagen | 2026-10-10 12:44 UTC | 49 | .to_vec(), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 50 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 51 | .unwrap() |
782069860236 | atagen | 2026-10-10 12:44 UTC | 52 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 53 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 54 | fn header<'a>(response: &'a Response, name: &str) -> &'a str { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 55 | response.headers()[name].to_str().unwrap() |
782069860236 | atagen | 2026-10-10 12:44 UTC | 56 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 57 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 58 | fn fixture() -> Run { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 59 | Run::new("cafebabe".into(), "cafe".into(), 69) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 60 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 61 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 62 | fn seeded_with(floor: Floor, setup: impl FnOnce(&mut Run)) -> Router { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 63 | let state = Arc::new(AppState::default()); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 64 | let mut run = fixture(); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 65 | run.floor = floor; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 66 | setup(&mut run); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 67 | state.insert(run); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 68 | router(state) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 69 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 70 | |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 71 | fn seeded(floor: Floor) -> (Router, String) { |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 72 | let state = Arc::new(AppState::default()); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 73 | let mut run = fixture(); |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 74 | run.floor = floor; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 75 | let etag = run.origin_etag(); |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 76 | state.insert(run); |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 77 | (router(state), etag) |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 78 | } |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 79 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 80 | fn app() -> Router { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 81 | crate::app(Config::default()) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 82 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 83 | |
9683736a2c5e | atagen | 2026-10-10 13:15 UTC | 84 | fn mum_at_the_door(run: &mut Run) { |
9683736a2c5e | atagen | 2026-10-10 13:15 UTC | 85 | run.mum = Some(MumVisit { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 86 | errand: "She heard a noise.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 87 | nonce: "abc".into(), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 88 | strikes: 0, |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 89 | knocked: false, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 90 | }); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 91 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 92 | |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 93 | #[tokio::test] |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 94 | async fn creating_a_run_returns_location_and_etag() { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 95 | let response = send(&app(), "POST", "/runs?seed=1", &[], "").await; |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 96 | assert_eq!(response.status(), StatusCode::CREATED); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 97 | assert!(header(&response, "location").starts_with("/runs/")); |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 98 | assert!(response.headers().contains_key(header::ETAG)); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 99 | assert_eq!(header(&response, "server"), "jelqd/0.6.9"); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 100 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 101 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 102 | #[tokio::test] |
782069860236 | atagen | 2026-10-10 12:44 UTC | 103 | async fn bodies_do_not_repeat_the_headers() { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 104 | let (app, _) = seeded(Floor::Bedroom); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 105 | let response = send(&app, "GET", "/runs/cafebabe", &[], "").await; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 106 | assert!(response.headers().contains_key("x-eq")); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 107 | let body = json(response).await; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 108 | for stat in [ |
782069860236 | atagen | 2026-10-10 12:44 UTC | 109 | "eq", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 110 | "girth", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 111 | "foreskin", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 112 | "stamina", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 113 | "cash", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 114 | "self_reported_length", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 115 | ] { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 116 | assert!(body.get(stat).is_none(), "{stat} is already a header"); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 117 | } |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 118 | } |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 119 | |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 120 | #[tokio::test] |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 121 | async fn jelqing_cold_fails_the_precondition() { |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 122 | let (app, _) = seeded(Floor::Bedroom); |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 123 | let response = send(&app, "JELQ", "/runs/cafebabe?technique=stretch", &[], "").await; |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 124 | assert_eq!(response.status(), StatusCode::PRECONDITION_FAILED); |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 125 | assert_eq!( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 126 | header(&response, "content-type"), |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 127 | "application/problem+json" |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 128 | ); |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 129 | } |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 130 | |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 131 | #[tokio::test] |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 132 | async fn wet_without_lube_is_unsupported_media() { |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 133 | let (app, _) = seeded(Floor::Bedroom); |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 134 | send(&app, "JELQ", "/runs/cafebabe?technique=warmup", &[], "").await; |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 135 | let response = send(&app, "JELQ", "/runs/cafebabe?technique=wet", &[], "").await; |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 136 | assert_eq!(response.status(), StatusCode::UNSUPPORTED_MEDIA_TYPE); |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 137 | let images = send( |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 138 | &app, |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 139 | "JELQ", |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 140 | "/runs/cafebabe?technique=wet", |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 141 | &[("content-type", "image/jpeg")], |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 142 | "", |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 143 | ) |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 144 | .await; |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 145 | assert_eq!(json(images).await["detail"], "No."); |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 146 | } |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 147 | |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 148 | #[tokio::test] |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 149 | async fn unknown_methods_are_not_implemented() { |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 150 | let (app, _) = seeded(Floor::Bedroom); |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 151 | let response = send(&app, "MILK", "/runs/cafebabe", &[], "").await; |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 152 | assert_eq!(response.status(), StatusCode::NOT_IMPLEMENTED); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 153 | let teapot = send(&app, "BREW", "/runs/cafebabe", &[], "").await; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 154 | assert_eq!(teapot.status(), StatusCode::IM_A_TEAPOT); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 155 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 156 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 157 | #[tokio::test] |
782069860236 | atagen | 2026-10-10 12:44 UTC | 158 | async fn the_clinic_does_not_advertise_jelq() { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 159 | let (app, _) = seeded(Floor::Clinic); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 160 | let options = send(&app, "OPTIONS", "/runs/cafebabe", &[], "").await; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 161 | assert!(!header(&options, "allow").contains("JELQ")); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 162 | let jelq = send(&app, "JELQ", "/runs/cafebabe?technique=wet", &[], "").await; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 163 | assert_eq!(jelq.status(), StatusCode::METHOD_NOT_ALLOWED); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 164 | assert!(!header(&jelq, "allow").contains("JELQ")); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 165 | let (bedroom, _) = seeded(Floor::Bedroom); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 166 | let options = send(&bedroom, "OPTIONS", "/runs/cafebabe", &[], "").await; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 167 | assert!(header(&options, "allow").contains("JELQ")); |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 168 | } |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 169 | |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 170 | #[tokio::test] |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 171 | async fn patch_only_accepts_the_truth() { |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 172 | let (app, _) = seeded(Floor::Bedroom); |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 173 | let patch = [("content-type", "application/json-patch+json")]; |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 174 | let replace = send( |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 175 | &app, |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 176 | "PATCH", |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 177 | "/runs/cafebabe", |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 178 | &patch, |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 179 | r#"[{"op":"replace","path":"/length","value":12}]"#, |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 180 | ) |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 181 | .await; |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 182 | assert_eq!(replace.status(), StatusCode::UNPROCESSABLE_ENTITY); |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 183 | let lie = send( |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 184 | &app, |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 185 | "PATCH", |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 186 | "/runs/cafebabe", |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 187 | &patch, |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 188 | r#"[{"op":"test","path":"/length","value":40}]"#, |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 189 | ) |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 190 | .await; |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 191 | assert_eq!( |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 192 | json(lie).await["type"], |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 193 | "https://jelq.dev/problems/exaggeration" |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 194 | ); |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 195 | } |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 196 | |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 197 | #[tokio::test] |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 198 | async fn deleting_the_foreskin_requires_certainty() { |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 199 | let (app, _) = seeded(Floor::Bedroom); |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 200 | let response = send(&app, "DELETE", "/runs/cafebabe/foreskin", &[], "").await; |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 201 | assert_eq!(response.status(), StatusCode::PRECONDITION_REQUIRED); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 202 | let look = send(&app, "GET", "/runs/cafebabe/foreskin", &[], "").await; |
ec6fd4bb5b60 | atagen | 2026-10-11 04:34 UTC | 203 | assert_eq!(look.status(), StatusCode::OK); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 204 | let etag = header(&look, "etag").to_owned(); |
ec6fd4bb5b60 | atagen | 2026-10-11 04:34 UTC | 205 | assert!(text(look).await.contains('~')); |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 206 | let response = send( |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 207 | &app, |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 208 | "DELETE", |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 209 | "/runs/cafebabe/foreskin", |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 210 | &[("if-match", &etag)], |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 211 | "", |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 212 | ) |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 213 | .await; |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 214 | assert_eq!(response.status(), StatusCode::NO_CONTENT); |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 215 | let response = send(&app, "GET", "/runs/cafebabe/foreskin", &[], "").await; |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 216 | assert_eq!(response.status(), StatusCode::GONE); |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 217 | } |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 218 | |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 219 | #[tokio::test] |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 220 | async fn length_is_chunked_until_the_ruler() { |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 221 | let (app, _) = seeded(Floor::Bedroom); |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 222 | let lie = send(&app, "GET", "/runs/cafebabe/length", &[], "").await; |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 223 | assert!(!lie.headers().contains_key(header::CONTENT_LENGTH)); |
ad00e0e051a1 | atagen | 2026-10-10 14:00 UTC | 224 | let app = seeded_with(Floor::Bedroom, |run| run.items.ruler = true); |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 225 | let truth = send(&app, "GET", "/runs/cafebabe/length", &[], "").await; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 226 | let declared: usize = header(&truth, "content-length").parse().unwrap(); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 227 | let body = text(truth).await; |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 228 | assert_eq!(body.len(), declared); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 229 | assert!(body.starts_with("8=") && body.ends_with('D')); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 230 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 231 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 232 | #[tokio::test] |
782069860236 | atagen | 2026-10-10 12:44 UTC | 233 | async fn length_supports_inch_ranges() { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 234 | let (app, _) = seeded(Floor::Bedroom); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 235 | let response = send( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 236 | &app, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 237 | "GET", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 238 | "/runs/cafebabe/length", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 239 | &[("range", "inches=0-1")], |
782069860236 | atagen | 2026-10-10 12:44 UTC | 240 | "", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 241 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 242 | .await; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 243 | assert_eq!(response.status(), StatusCode::PARTIAL_CONTENT); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 244 | assert!(header(&response, "content-range").starts_with("inches 0.00-1.00/")); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 245 | assert_eq!(text(response).await.len(), 25); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 246 | let absurd = send( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 247 | &app, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 248 | "GET", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 249 | "/runs/cafebabe/length", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 250 | &[("range", "inches=40-50")], |
782069860236 | atagen | 2026-10-10 12:44 UTC | 251 | "", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 252 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 253 | .await; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 254 | assert_eq!(absurd.status(), StatusCode::RANGE_NOT_SATISFIABLE); |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 255 | let malformed = send( |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 256 | &app, |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 257 | "GET", |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 258 | "/runs/cafebabe/length", |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 259 | &[("range", "inches=6.17")], |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 260 | "", |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 261 | ) |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 262 | .await; |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 263 | assert_eq!(malformed.status(), StatusCode::OK); |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 264 | let suffix = send( |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 265 | &app, |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 266 | "GET", |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 267 | "/runs/cafebabe/length", |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 268 | &[("range", "inches=-1")], |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 269 | "", |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 270 | ) |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 271 | .await; |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 272 | assert_eq!(suffix.status(), StatusCode::PARTIAL_CONTENT); |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 273 | assert!(text(suffix).await.ends_with('D')); |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 274 | for (range, status) in [ |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 275 | ("inches=1-", StatusCode::PARTIAL_CONTENT), |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 276 | ("inches=40-", StatusCode::RANGE_NOT_SATISFIABLE), |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 277 | ("inches=-0", StatusCode::RANGE_NOT_SATISFIABLE), |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 278 | ("inches=2-1", StatusCode::OK), |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 279 | ("inches=NaN-2", StatusCode::OK), |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 280 | ("inches=0-inf", StatusCode::OK), |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 281 | ] { |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 282 | let response = send( |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 283 | &app, |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 284 | "GET", |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 285 | "/runs/cafebabe/length", |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 286 | &[("range", range)], |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 287 | "", |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 288 | ) |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 289 | .await; |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 290 | assert_eq!(response.status(), status, "{range}"); |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 291 | } |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 292 | } |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 293 | |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 294 | #[tokio::test] |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 295 | async fn the_clinic_escalates_toward_honesty() { |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 296 | let (app, _) = seeded(Floor::Clinic); |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 297 | let mut hints = Vec::new(); |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 298 | for _ in 0..3 { |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 299 | let response = send( |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 300 | &app, |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 301 | "GET", |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 302 | "/runs/cafebabe/diagnosis", |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 303 | &[("authorization", "Excuse \"changing\"")], |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 304 | "", |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 305 | ) |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 306 | .await; |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 307 | assert_eq!(response.status(), StatusCode::UNAUTHORIZED); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 308 | hints.push(header(&response, "www-authenticate").to_owned()); |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 309 | } |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 310 | assert!(hints[2].contains("Be honest.")); |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 311 | } |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 312 | |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 313 | #[tokio::test] |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 314 | async fn the_true_ending_is_not_modified() { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 315 | let (early, _) = seeded(Floor::Bedroom); |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 316 | let response = send(&early, "GET", "/runs/cafebabe/diagnosis", &[], "").await; |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 317 | assert_eq!(response.status(), StatusCode::TOO_EARLY); |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 318 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 319 | let (app, etag) = seeded(Floor::Clinic); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 320 | assert!( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 321 | !etag.contains("cafebabe"), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 322 | "the origin ETag must not be derivable from the id" |
782069860236 | atagen | 2026-10-10 12:44 UTC | 323 | ); |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 324 | let response = send( |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 325 | &app, |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 326 | "GET", |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 327 | "/runs/cafebabe/diagnosis", |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 328 | &[ |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 329 | ("authorization", "Bearer honesty"), |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 330 | ("if-none-match", &etag), |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 331 | ], |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 332 | "", |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 333 | ) |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 334 | .await; |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 335 | assert_eq!(response.status(), StatusCode::NOT_MODIFIED); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 336 | assert_eq!(header(&response, "x-diagnosis"), "normal"); |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 337 | } |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 338 | |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 339 | #[tokio::test] |
9683736a2c5e | atagen | 2026-10-10 13:15 UTC | 340 | async fn mum_accepts_a_known_excuse() { |
9683736a2c5e | atagen | 2026-10-10 13:15 UTC | 341 | let app = seeded_with(Floor::Bedroom, mum_at_the_door); |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 342 | let response = send(&app, "GET", "/runs/cafebabe", &[], "").await; |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 343 | assert_eq!(response.status(), StatusCode::UNAUTHORIZED); |
9683736a2c5e | atagen | 2026-10-10 13:15 UTC | 344 | assert_eq!(header(&response, "via"), "1.1 mum"); |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 345 | let response = send( |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 346 | &app, |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 347 | "GET", |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 348 | "/runs/cafebabe", |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 349 | &[("authorization", "Excuse \"homework\"")], |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 350 | "", |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 351 | ) |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 352 | .await; |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 353 | assert_eq!(response.status(), StatusCode::OK); |
a9b016e4b248 | atagen | 2026-10-10 08:12 UTC | 354 | } |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 355 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 356 | #[tokio::test] |
9683736a2c5e | atagen | 2026-10-10 13:15 UTC | 357 | async fn mum_runs_out_of_patience() { |
9683736a2c5e | atagen | 2026-10-10 13:15 UTC | 358 | let app = seeded_with(Floor::Bedroom, mum_at_the_door); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 359 | let lie = [("authorization", "Excuse \"it is for science\"")]; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 360 | for _ in 0..2 { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 361 | let response = send(&app, "GET", "/runs/cafebabe", &lie, "").await; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 362 | assert_eq!(response.status(), StatusCode::UNAUTHORIZED); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 363 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 364 | let caught = send(&app, "GET", "/runs/cafebabe", &lie, "").await; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 365 | assert_eq!(caught.status(), StatusCode::GONE); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 366 | assert_eq!( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 367 | json(caught).await["type"], |
782069860236 | atagen | 2026-10-10 12:44 UTC | 368 | "https://jelq.dev/problems/caught" |
782069860236 | atagen | 2026-10-10 12:44 UTC | 369 | ); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 370 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 371 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 372 | #[tokio::test] |
9683736a2c5e | atagen | 2026-10-10 13:15 UTC | 373 | async fn mum_remembers_excuses_by_christmas() { |
9683736a2c5e | atagen | 2026-10-10 13:15 UTC | 374 | let app = seeded_with(Floor::Nans, |run| { |
9683736a2c5e | atagen | 2026-10-10 13:15 UTC | 375 | mum_at_the_door(run); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 376 | run.heard.push("homework".into()); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 377 | }); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 378 | let basic = send( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 379 | &app, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 380 | "GET", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 381 | "/runs/cafebabe", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 382 | &[("authorization", "Excuse \"changing\"")], |
782069860236 | atagen | 2026-10-10 12:44 UTC | 383 | "", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 384 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 385 | .await; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 386 | assert_eq!(basic.status(), StatusCode::UNAUTHORIZED); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 387 | assert!(header(&basic, "www-authenticate").starts_with("Digest")); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 388 | let replay = send( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 389 | &app, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 390 | "GET", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 391 | "/runs/cafebabe", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 392 | &[( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 393 | "authorization", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 394 | "Digest username=\"homework\", nonce=\"abc\"", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 395 | )], |
782069860236 | atagen | 2026-10-10 12:44 UTC | 396 | "", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 397 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 398 | .await; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 399 | assert_eq!( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 400 | json(replay).await["type"], |
782069860236 | atagen | 2026-10-10 12:44 UTC | 401 | "https://jelq.dev/problems/excuse-replayed" |
782069860236 | atagen | 2026-10-10 12:44 UTC | 402 | ); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 403 | let fresh = send( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 404 | &app, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 405 | "GET", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 406 | "/runs/cafebabe", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 407 | &[( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 408 | "authorization", |
9683736a2c5e | atagen | 2026-10-10 13:15 UTC | 409 | "Digest username=\"wrapping presents\", nonce=\"abc\"", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 410 | )], |
782069860236 | atagen | 2026-10-10 12:44 UTC | 411 | "", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 412 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 413 | .await; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 414 | assert_eq!(fresh.status(), StatusCode::OK); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 415 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 416 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 417 | #[tokio::test] |
782069860236 | atagen | 2026-10-10 12:44 UTC | 418 | async fn a_pulled_muscle_is_a_true_excuse() { |
9683736a2c5e | atagen | 2026-10-10 13:15 UTC | 419 | let app = seeded_with(Floor::Nans, |run| { |
9683736a2c5e | atagen | 2026-10-10 13:15 UTC | 420 | mum_at_the_door(run); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 421 | run.conditions.pulled_muscle = true; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 422 | run.heard.push("pulled a muscle".into()); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 423 | }); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 424 | let response = send( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 425 | &app, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 426 | "GET", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 427 | "/runs/cafebabe", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 428 | &[( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 429 | "authorization", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 430 | "Digest username=\"pulled a muscle\", nonce=\"abc\"", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 431 | )], |
782069860236 | atagen | 2026-10-10 12:44 UTC | 432 | "", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 433 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 434 | .await; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 435 | assert_eq!(response.status(), StatusCode::OK); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 436 | assert!(header(&response, "x-stamina").ends_with("/7")); |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 437 | } |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 438 | |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 439 | #[tokio::test] |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 440 | async fn floors_end_when_they_end() { |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 441 | let app = seeded_with(Floor::Bedroom, |_| {}); |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 442 | let early = send(&app, "POST", "/runs/cafebabe/floor", &[], "").await; |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 443 | assert_eq!(early.status(), StatusCode::TOO_EARLY); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 444 | let app = seeded_with(Floor::Bedroom, |run| run.here.turns = 6); |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 445 | let next = send(&app, "POST", "/runs/cafebabe/floor", &[], "").await; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 446 | assert!( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 447 | next.status() == StatusCode::SEE_OTHER || next.status() == StatusCode::CONFLICT, |
9683736a2c5e | atagen | 2026-10-10 13:15 UTC | 448 | "either the floor changed or the zip did" |
782069860236 | atagen | 2026-10-10 12:44 UTC | 449 | ); |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 450 | } |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 451 | |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 452 | #[tokio::test] |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 453 | async fn pump_bro_upsells() { |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 454 | let closed = seeded_with(Floor::Bedroom, |_| {}); |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 455 | let response = send(&closed, "GET", "/runs/cafebabe/shop", &[], "").await; |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 456 | assert_eq!(response.status(), StatusCode::NOT_FOUND); |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 457 | |
9683736a2c5e | atagen | 2026-10-10 13:15 UTC | 458 | let app = seeded_with(Floor::ChangingRoom, |_| {}); |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 459 | let pump = send(&app, "POST", "/runs/cafebabe/shop/pump", &[], "").await; |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 460 | assert_eq!(pump.status(), StatusCode::UPGRADE_REQUIRED); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 461 | assert_eq!(header(&pump, "upgrade"), "pump-pro/2.0"); |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 462 | let pro = send(&app, "POST", "/runs/cafebabe/shop/pump-pro", &[], "").await; |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 463 | assert_eq!(pro.status(), StatusCode::CREATED); |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 464 | let broke = send(&app, "POST", "/runs/cafebabe/shop/extender", &[], "").await; |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 465 | assert_eq!(broke.status(), StatusCode::PAYMENT_REQUIRED); |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 466 | } |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 467 | |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 468 | #[tokio::test] |
782069860236 | atagen | 2026-10-10 12:44 UTC | 469 | async fn only_the_key_opens_the_cage() { |
9683736a2c5e | atagen | 2026-10-10 13:15 UTC | 470 | let app = seeded_with(Floor::ChangingRoom, |run| run.items.cage = true); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 471 | send(&app, "POST", "/runs/cafebabe/shop/ice-pack", &[], "").await; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 472 | let still = send( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 473 | &app, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 474 | "GET", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 475 | "/runs/cafebabe/inventory/chastity-cage", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 476 | &[], |
782069860236 | atagen | 2026-10-10 12:44 UTC | 477 | "", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 478 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 479 | .await; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 480 | assert_eq!(still.status(), StatusCode::OK); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 481 | send(&app, "POST", "/runs/cafebabe/shop/cage-key", &[], "").await; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 482 | let gone = send( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 483 | &app, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 484 | "GET", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 485 | "/runs/cafebabe/inventory/chastity-cage", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 486 | &[], |
782069860236 | atagen | 2026-10-10 12:44 UTC | 487 | "", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 488 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 489 | .await; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 490 | assert_eq!(gone.status(), StatusCode::NOT_FOUND); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 491 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 492 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 493 | #[tokio::test] |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 494 | async fn combos_are_multi_status_xml() { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 495 | let app = seeded_with(Floor::Bathroom, |run| { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 496 | run.foreskin = Some(1.0); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 497 | run.items.blinds = true; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 498 | }); |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 499 | send(&app, "JELQ", "/runs/cafebabe?technique=warmup", &[], "").await; |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 500 | let response = send( |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 501 | &app, |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 502 | "JELQ", |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 503 | "/runs/cafebabe?technique=wet,stretch", |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 504 | &[("content-type", "application/baby-oil")], |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 505 | "", |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 506 | ) |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 507 | .await; |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 508 | assert_eq!(response.status(), StatusCode::MULTI_STATUS); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 509 | assert!(text(response).await.contains("<D:multistatus")); |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 510 | } |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 511 | |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 512 | #[tokio::test] |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 513 | async fn the_elder_is_stale() { |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 514 | let app = seeded_with(Floor::Forum, |run| run.length = 5.0); |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 515 | let unverified = send(&app, "GET", "/runs/cafebabe/elder", &[], "").await; |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 516 | assert_eq!( |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 517 | unverified.status(), |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 518 | StatusCode::PROXY_AUTHENTICATION_REQUIRED |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 519 | ); |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 520 | let lie = send( |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 521 | &app, |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 522 | "GET", |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 523 | "/runs/cafebabe/elder", |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 524 | &[("proxy-authorization", "Ruler 9")], |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 525 | "", |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 526 | ) |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 527 | .await; |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 528 | assert_eq!(lie.status(), StatusCode::BAD_REQUEST); |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 529 | let csv = send( |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 530 | &app, |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 531 | "GET", |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 532 | "/runs/cafebabe/elder", |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 533 | &[("proxy-authorization", "Ruler 5.0")], |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 534 | "", |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 535 | ) |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 536 | .await; |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 537 | assert_eq!(csv.status(), StatusCode::OK); |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 538 | let stale = send( |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 539 | &app, |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 540 | "GET", |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 541 | "/runs/cafebabe/elder", |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 542 | &[("if-modified-since", "Mon, 15 Jun 2009 00:00:00 GMT")], |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 543 | "", |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 544 | ) |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 545 | .await; |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 546 | assert_eq!(stale.status(), StatusCode::NOT_MODIFIED); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 547 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 548 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 549 | #[tokio::test] |
782069860236 | atagen | 2026-10-10 12:44 UTC | 550 | async fn the_displayed_length_is_accepted_as_honest() { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 551 | let app = seeded_with(Floor::Forum, |run| run.length = 5.2496); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 552 | let response = send( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 553 | &app, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 554 | "GET", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 555 | "/runs/cafebabe/elder", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 556 | &[("proxy-authorization", "Ruler 5.25")], |
782069860236 | atagen | 2026-10-10 12:44 UTC | 557 | "", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 558 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 559 | .await; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 560 | assert_eq!(response.status(), StatusCode::OK); |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 561 | } |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 562 | |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 563 | #[tokio::test] |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 564 | async fn the_hotel_has_a_captive_portal() { |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 565 | let app = seeded_with(Floor::Hotel, |_| {}); |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 566 | let blocked = send(&app, "GET", "/runs/cafebabe", &[], "").await; |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 567 | assert_eq!( |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 568 | blocked.status(), |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 569 | StatusCode::NETWORK_AUTHENTICATION_REQUIRED |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 570 | ); |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 571 | let accepted = send(&app, "POST", "/runs/cafebabe/portal", &[], "").await; |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 572 | assert_eq!(accepted.status(), StatusCode::SEE_OTHER); |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 573 | let online = send(&app, "GET", "/runs/cafebabe", &[], "").await; |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 574 | assert_eq!(online.status(), StatusCode::OK); |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 575 | } |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 576 | |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 577 | #[tokio::test] |
782069860236 | atagen | 2026-10-10 12:44 UTC | 578 | async fn the_internet_never_forgets() { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 579 | let app = seeded_with(Floor::Bedroom, |run| { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 580 | run.filmed_at = Some(std::time::SystemTime::now()); |
dfa38cf4cd4b | atagen | 2026-10-10 09:17 UTC | 581 | }); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 582 | let footage = send(&app, "GET", "/runs/cafebabe/footage", &[], "").await; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 583 | assert_eq!(footage.status(), StatusCode::OK); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 584 | assert_eq!( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 585 | header(&footage, "cache-control"), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 586 | "public, max-age=31536000, immutable" |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 587 | ); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 588 | assert!(footage.headers().contains_key(header::AGE)); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 589 | let delete = send(&app, "DELETE", "/runs/cafebabe/footage", &[], "").await; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 590 | assert_eq!(delete.status(), StatusCode::METHOD_NOT_ALLOWED); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 591 | assert!(!header(&delete, "allow").contains("DELETE")); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 592 | } |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 593 | |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 594 | #[tokio::test] |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 595 | async fn forged_ruler_cookies_are_lies() { |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 596 | let forged = send( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 597 | &app(), |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 598 | "GET", |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 599 | "/leaderboard?sort=content-length", |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 600 | &[("cookie", "ruler=1")], |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 601 | "", |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 602 | ) |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 603 | .await; |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 604 | assert_eq!(forged.status(), StatusCode::BAD_REQUEST); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 605 | } |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 606 | |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 607 | #[tokio::test] |
782069860236 | atagen | 2026-10-10 12:44 UTC | 608 | async fn listings_never_reveal_the_private_id() { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 609 | let app = app(); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 610 | let created = send(&app, "POST", "/runs", &[], "").await; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 611 | let location = header(&created, "location").to_owned(); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 612 | let board = text(send(&app, "GET", "/leaderboard", &[], "").await).await; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 613 | let private = location.trim_start_matches("/runs/"); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 614 | assert!(!board.contains(private)); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 615 | let entry: Value = serde_json::from_str(&board).unwrap(); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 616 | let public = entry["entries"][0]["public_id"].as_str().unwrap(); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 617 | let guess = send(&app, "DELETE", &format!("/runs/{public}"), &[], "").await; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 618 | assert_eq!(guess.status(), StatusCode::NOT_FOUND); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 619 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 620 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 621 | #[tokio::test] |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 622 | async fn seeded_runs_are_unranked() { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 623 | let app = app(); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 624 | send(&app, "POST", "/runs?seed=7", &[], "").await; |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 625 | let board = json(send(&app, "GET", "/leaderboard", &[], "").await).await; |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 626 | assert_eq!(board["entries"].as_array().unwrap().len(), 0); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 627 | let all = json(send(&app, "GET", "/leaderboard?seeded=include", &[], "").await).await; |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 628 | assert_eq!(all["entries"][0]["ranked"], false); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 629 | } |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 630 | |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 631 | #[tokio::test] |
782069860236 | atagen | 2026-10-10 12:44 UTC | 632 | async fn idle_runs_are_evicted_and_the_server_has_a_limit() { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 633 | let forgetful = crate::app(Config { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 634 | idle_ttl: Duration::ZERO, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 635 | ..Config::default() |
782069860236 | atagen | 2026-10-10 12:44 UTC | 636 | }); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 637 | let first = send(&forgetful, "POST", "/runs", &[], "").await; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 638 | let location = header(&first, "location").to_owned(); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 639 | send(&forgetful, "POST", "/runs", &[], "").await; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 640 | let gone = send(&forgetful, "GET", &location, &[], "").await; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 641 | assert_eq!(gone.status(), StatusCode::NOT_FOUND); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 642 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 643 | let tiny = crate::app(Config { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 644 | max_runs: 1, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 645 | ..Config::default() |
782069860236 | atagen | 2026-10-10 12:44 UTC | 646 | }); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 647 | send(&tiny, "POST", "/runs", &[], "").await; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 648 | let full = send(&tiny, "POST", "/runs", &[], "").await; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 649 | assert_eq!(full.status(), StatusCode::SERVICE_UNAVAILABLE); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 650 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 651 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 652 | #[tokio::test] |
782069860236 | atagen | 2026-10-10 12:44 UTC | 653 | async fn shame_from_two_runs_adds_up() { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 654 | let state = Arc::new(AppState::default()); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 655 | state.insert(fixture()); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 656 | state.insert(Run::new("deadbeef".into(), "dead".into(), 7)); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 657 | let app = router(state); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 658 | let first = send(&app, "TRACE", "/runs/cafebabe", &[], "").await; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 659 | assert_eq!(header(&first, "x-shame"), "1"); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 660 | let cookie = header(&first, "set-cookie") |
782069860236 | atagen | 2026-10-10 12:44 UTC | 661 | .split(';') |
782069860236 | atagen | 2026-10-10 12:44 UTC | 662 | .next() |
782069860236 | atagen | 2026-10-10 12:44 UTC | 663 | .unwrap() |
782069860236 | atagen | 2026-10-10 12:44 UTC | 664 | .to_owned(); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 665 | let second = send(&app, "TRACE", "/runs/deadbeef", &[("cookie", &cookie)], "").await; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 666 | assert_eq!(header(&second, "x-shame"), "2"); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 667 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 668 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 669 | #[tokio::test] |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 670 | async fn the_root_negotiates() { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 671 | let app = app(); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 672 | let browser = send(&app, "GET", "/", &[("accept", "text/html,*/*")], "").await; |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 673 | assert_eq!(browser.status(), StatusCode::SEE_OTHER); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 674 | assert_eq!(header(&browser, "location"), "/ui/"); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 675 | let curl = send(&app, "GET", "/", &[("accept", "*/*")], "").await; |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 676 | assert_eq!(json(curl).await["ui"], "/ui/"); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 677 | let page = send(&app, "GET", "/ui/", &[], "").await; |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 678 | assert_eq!(page.status(), StatusCode::OK); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 679 | } |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 680 | |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 681 | #[tokio::test] |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 682 | async fn the_ui_replays_what_browsers_cannot_send() { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 683 | let app = app(); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 684 | let envelope = |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 685 | r#"{"method": "TRACE", "path": "/graveyard", "headers": [["X-Confession", "I did it"]]}"#; |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 686 | let traced = json(send(&app, "POST", "/ui/send", &[], envelope).await).await; |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 687 | assert_eq!(traced["status"], 405); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 688 | let envelope = r#"{"method": "GET", "path": "/", "headers": [["Accept", "text/html"]]}"#; |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 689 | let redirected = json(send(&app, "POST", "/ui/send", &[], envelope).await).await; |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 690 | assert_eq!(redirected["status"], 303); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 691 | assert_eq!(redirected["reason"], "See Other"); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 692 | } |
c3e0c27cf8fd | atagen | 2026-10-10 11:28 UTC | 693 | |
c3e0c27cf8fd | atagen | 2026-10-10 11:28 UTC | 694 | #[tokio::test] |
ba879f96510d | atagen | 2026-10-10 12:03 UTC | 695 | async fn the_ui_decodes_gzip_for_display() { |
ba879f96510d | atagen | 2026-10-10 12:03 UTC | 696 | let app = seeded_with(Floor::Bedroom, |run| run.items.ring = true); |
ba879f96510d | atagen | 2026-10-10 12:03 UTC | 697 | let envelope = |
ba879f96510d | atagen | 2026-10-10 12:03 UTC | 698 | r#"{"method": "GET", "path": "/runs/cafebabe", "headers": [["Accept-Encoding", "gzip"]]}"#; |
ba879f96510d | atagen | 2026-10-10 12:03 UTC | 699 | let shown = json(send(&app, "POST", "/ui/send", &[], envelope).await).await; |
ba879f96510d | atagen | 2026-10-10 12:03 UTC | 700 | assert!( |
ba879f96510d | atagen | 2026-10-10 12:03 UTC | 701 | shown["body"] |
ba879f96510d | atagen | 2026-10-10 12:03 UTC | 702 | .as_str() |
ba879f96510d | atagen | 2026-10-10 12:03 UTC | 703 | .unwrap() |
782069860236 | atagen | 2026-10-10 12:44 UTC | 704 | .contains("\"public_id\":\"cafe\"") |
ba879f96510d | atagen | 2026-10-10 12:03 UTC | 705 | ); |
ba879f96510d | atagen | 2026-10-10 12:03 UTC | 706 | let encoding = shown["headers"] |
ba879f96510d | atagen | 2026-10-10 12:03 UTC | 707 | .as_array() |
ba879f96510d | atagen | 2026-10-10 12:03 UTC | 708 | .unwrap() |
ba879f96510d | atagen | 2026-10-10 12:03 UTC | 709 | .iter() |
ba879f96510d | atagen | 2026-10-10 12:03 UTC | 710 | .any(|h| h[0] == "content-encoding" && h[1] == "gzip"); |
ba879f96510d | atagen | 2026-10-10 12:03 UTC | 711 | assert!(encoding); |
ba879f96510d | atagen | 2026-10-10 12:03 UTC | 712 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 713 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 714 | #[tokio::test] |
782069860236 | atagen | 2026-10-10 12:44 UTC | 715 | async fn http_1_0_gets_the_pdf_treatment() { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 716 | let request = Request::builder() |
782069860236 | atagen | 2026-10-10 12:44 UTC | 717 | .uri("/graveyard") |
782069860236 | atagen | 2026-10-10 12:44 UTC | 718 | .version(Version::HTTP_10) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 719 | .body(Body::empty()) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 720 | .unwrap(); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 721 | let response = app().oneshot(request).await.unwrap(); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 722 | assert_eq!(response.status(), StatusCode::HTTP_VERSION_NOT_SUPPORTED); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 723 | } |
ef7d6dee5976 | atagen | 2026-10-10 13:23 UTC | 724 | |
ef7d6dee5976 | atagen | 2026-10-10 13:23 UTC | 725 | #[tokio::test] |
ef7d6dee5976 | atagen | 2026-10-10 13:23 UTC | 726 | async fn mom_speaks_american() { |
ef7d6dee5976 | atagen | 2026-10-10 13:23 UTC | 727 | let app = seeded_with(Floor::Nans, mum_at_the_door); |
ef7d6dee5976 | atagen | 2026-10-10 13:23 UTC | 728 | let us = [("accept-language", "en-US")]; |
ef7d6dee5976 | atagen | 2026-10-10 13:23 UTC | 729 | let knock = send(&app, "GET", "/runs/cafebabe", &us, "").await; |
ef7d6dee5976 | atagen | 2026-10-10 13:23 UTC | 730 | assert_eq!(header(&knock, "content-language"), "en-US"); |
ef7d6dee5976 | atagen | 2026-10-10 13:23 UTC | 731 | assert_eq!(header(&knock, "via"), "1.1 mom"); |
ef7d6dee5976 | atagen | 2026-10-10 13:23 UTC | 732 | assert!( |
ef7d6dee5976 | atagen | 2026-10-10 13:23 UTC | 733 | json(knock).await["detail"] |
ef7d6dee5976 | atagen | 2026-10-10 13:23 UTC | 734 | .as_str() |
ef7d6dee5976 | atagen | 2026-10-10 13:23 UTC | 735 | .unwrap() |
ef7d6dee5976 | atagen | 2026-10-10 13:23 UTC | 736 | .contains("Someone is at the door.") |
ef7d6dee5976 | atagen | 2026-10-10 13:23 UTC | 737 | ); |
ef7d6dee5976 | atagen | 2026-10-10 13:23 UTC | 738 | let excuse = [ |
ef7d6dee5976 | atagen | 2026-10-10 13:23 UTC | 739 | ("accept-language", "en-US"), |
ef7d6dee5976 | atagen | 2026-10-10 13:23 UTC | 740 | ( |
ef7d6dee5976 | atagen | 2026-10-10 13:23 UTC | 741 | "authorization", |
ef7d6dee5976 | atagen | 2026-10-10 13:23 UTC | 742 | "Digest username=\"carving the turkey\", nonce=\"abc\"", |
ef7d6dee5976 | atagen | 2026-10-10 13:23 UTC | 743 | ), |
ef7d6dee5976 | atagen | 2026-10-10 13:23 UTC | 744 | ]; |
ef7d6dee5976 | atagen | 2026-10-10 13:23 UTC | 745 | let answered = send(&app, "GET", "/runs/cafebabe", &excuse, "").await; |
ef7d6dee5976 | atagen | 2026-10-10 13:23 UTC | 746 | assert_eq!(answered.status(), StatusCode::OK); |
ef7d6dee5976 | atagen | 2026-10-10 13:23 UTC | 747 | let floor = json(send(&app, "GET", "/runs/cafebabe/floor", &us, "").await).await; |
ef7d6dee5976 | atagen | 2026-10-10 13:23 UTC | 748 | assert_eq!(floor["name"], "Grandma's house for Thanksgiving"); |
ef7d6dee5976 | atagen | 2026-10-10 13:23 UTC | 749 | } |
ef7d6dee5976 | atagen | 2026-10-10 13:23 UTC | 750 | |
ef7d6dee5976 | atagen | 2026-10-10 13:23 UTC | 751 | #[tokio::test] |
ef7d6dee5976 | atagen | 2026-10-10 13:23 UTC | 752 | async fn the_default_locale_is_british() { |
ef7d6dee5976 | atagen | 2026-10-10 13:23 UTC | 753 | let (app, _) = seeded(Floor::Nans); |
ef7d6dee5976 | atagen | 2026-10-10 13:23 UTC | 754 | let floor = send(&app, "GET", "/runs/cafebabe/floor", &[], "").await; |
ef7d6dee5976 | atagen | 2026-10-10 13:23 UTC | 755 | assert_eq!(header(&floor, "content-language"), "en-GB"); |
ef7d6dee5976 | atagen | 2026-10-10 13:23 UTC | 756 | assert!(header(&floor, "vary").contains("Accept-Language")); |
ef7d6dee5976 | atagen | 2026-10-10 13:23 UTC | 757 | assert_eq!(json(floor).await["name"], "Nan's house at Christmas"); |
ef7d6dee5976 | atagen | 2026-10-10 13:23 UTC | 758 | } |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 759 | |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 760 | fn advertised(response: &Response) -> Vec<String> { |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 761 | header(response, "link") |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 762 | .split(", <") |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 763 | .filter(|entry| entry.contains("rels/technique")) |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 764 | .filter_map(|entry| { |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 765 | entry |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 766 | .split("title=\"") |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 767 | .nth(1)? |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 768 | .split('"') |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 769 | .next() |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 770 | .map(str::to_owned) |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 771 | }) |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 772 | .collect() |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 773 | } |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 774 | |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 775 | #[tokio::test] |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 776 | async fn links_offer_only_usable_techniques() { |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 777 | let app = seeded_with(Floor::Bedroom, |run| run.foreskin = Some(1.0)); |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 778 | let cold = send(&app, "GET", "/runs/cafebabe", &[], "").await; |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 779 | assert_eq!(advertised(&cold), ["warmup", "ice", "meditate"]); |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 780 | let warm = send(&app, "JELQ", "/runs/cafebabe?technique=warmup", &[], "").await; |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 781 | let usable = advertised(&warm); |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 782 | assert!(usable.contains(&"wet".to_owned()) && usable.contains(&"dry".to_owned())); |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 783 | assert!(!usable.contains(&"uli".to_owned()), "uli needs the forum"); |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 784 | assert!(!usable.contains(&"pump".to_owned()), "pump needs a pump"); |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 785 | assert!( |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 786 | header(&warm, "link").contains("title=\"wet\"; allow=\"JELQ\"; lubricant=\"required\"") |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 787 | ); |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 788 | |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 789 | let (forum, _) = seeded(Floor::Forum); |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 790 | let response = send(&forum, "GET", "/runs/cafebabe", &[], "").await; |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 791 | assert!(advertised(&response).is_empty()); |
58e1fb3943e6 | atagen | 2026-10-10 13:30 UTC | 792 | } |
d604371299fb | atagen | 2026-10-10 13:54 UTC | 793 | |
d604371299fb | atagen | 2026-10-10 13:54 UTC | 794 | fn linked_rels(response: &Response) -> Vec<String> { |
d604371299fb | atagen | 2026-10-10 13:54 UTC | 795 | header(response, "link") |
d604371299fb | atagen | 2026-10-10 13:54 UTC | 796 | .split(", <") |
d604371299fb | atagen | 2026-10-10 13:54 UTC | 797 | .filter_map(|entry| { |
d604371299fb | atagen | 2026-10-10 13:54 UTC | 798 | entry |
d604371299fb | atagen | 2026-10-10 13:54 UTC | 799 | .split("rels/") |
d604371299fb | atagen | 2026-10-10 13:54 UTC | 800 | .nth(1)? |
d604371299fb | atagen | 2026-10-10 13:54 UTC | 801 | .split('"') |
d604371299fb | atagen | 2026-10-10 13:54 UTC | 802 | .next() |
d604371299fb | atagen | 2026-10-10 13:54 UTC | 803 | .map(str::to_owned) |
d604371299fb | atagen | 2026-10-10 13:54 UTC | 804 | }) |
d604371299fb | atagen | 2026-10-10 13:54 UTC | 805 | .filter(|rel| rel != "technique") |
d604371299fb | atagen | 2026-10-10 13:54 UTC | 806 | .collect() |
d604371299fb | atagen | 2026-10-10 13:54 UTC | 807 | } |
d604371299fb | atagen | 2026-10-10 13:54 UTC | 808 | |
d604371299fb | atagen | 2026-10-10 13:54 UTC | 809 | #[tokio::test] |
d604371299fb | atagen | 2026-10-10 13:54 UTC | 810 | async fn links_hide_resources_that_would_do_nothing() { |
d604371299fb | atagen | 2026-10-10 13:54 UTC | 811 | let (bedroom, _) = seeded(Floor::Bedroom); |
d604371299fb | atagen | 2026-10-10 13:54 UTC | 812 | let before = linked_rels(&send(&bedroom, "GET", "/runs/cafebabe", &[], "").await); |
d604371299fb | atagen | 2026-10-10 13:54 UTC | 813 | assert!(before.contains(&"drawer".to_owned())); |
d604371299fb | atagen | 2026-10-10 13:54 UTC | 814 | assert!(!before.contains(&"diagnosis".to_owned())); |
d604371299fb | atagen | 2026-10-10 13:54 UTC | 815 | assert!(!before.contains(&"thread".to_owned())); |
d604371299fb | atagen | 2026-10-10 13:54 UTC | 816 | let searched = send(&bedroom, "POST", "/runs/cafebabe/drawer", &[], "").await; |
d604371299fb | atagen | 2026-10-10 13:54 UTC | 817 | assert!(!linked_rels(&searched).contains(&"drawer".to_owned())); |
d604371299fb | atagen | 2026-10-10 13:54 UTC | 818 | |
d604371299fb | atagen | 2026-10-10 13:54 UTC | 819 | let (clinic, _) = seeded(Floor::Clinic); |
d604371299fb | atagen | 2026-10-10 13:54 UTC | 820 | let rels = linked_rels(&send(&clinic, "GET", "/runs/cafebabe", &[], "").await); |
d604371299fb | atagen | 2026-10-10 13:54 UTC | 821 | assert!(rels.contains(&"diagnosis".to_owned()) && rels.contains(&"thread".to_owned())); |
d604371299fb | atagen | 2026-10-10 13:54 UTC | 822 | } |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 823 | |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 824 | #[tokio::test] |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 825 | async fn ignoring_mum_has_consequences() { |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 826 | let app = seeded_with(Floor::Bedroom, |run| { |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 827 | mum_at_the_door(run); |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 828 | run.here.turns = 6; |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 829 | }); |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 830 | let knock = send(&app, "GET", "/runs/cafebabe", &[], "").await; |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 831 | assert_eq!( |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 832 | json(knock).await["type"], |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 833 | "https://jelq.dev/problems/someone-at-the-door" |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 834 | ); |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 835 | let leave = send(&app, "POST", "/runs/cafebabe/floor", &[], "").await; |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 836 | assert_eq!( |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 837 | leave.status(), |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 838 | StatusCode::UNAUTHORIZED, |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 839 | "no leaving with Mum at the door" |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 840 | ); |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 841 | send(&app, "GET", "/runs/cafebabe", &[], "").await; |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 842 | let opened = send(&app, "GET", "/runs/cafebabe", &[], "").await; |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 843 | assert_eq!(opened.status(), StatusCode::GONE); |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 844 | assert_eq!( |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 845 | json(opened).await["type"], |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 846 | "https://jelq.dev/problems/opened" |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 847 | ); |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 848 | } |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 849 | |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 850 | #[tokio::test] |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 851 | async fn caged_drawers_are_noisy_and_eventually_give_up_the_key() { |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 852 | let app = seeded_with(Floor::ChangingRoom, |run| run.items.cage = true); |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 853 | let mut statuses = Vec::new(); |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 854 | for _ in 0..12 { |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 855 | let response = send(&app, "POST", "/runs/cafebabe/drawer", &[], "").await; |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 856 | statuses.push(response.status()); |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 857 | if response.status() == StatusCode::OK { |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 858 | break; |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 859 | } |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 860 | } |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 861 | assert_eq!(statuses.last(), Some(&StatusCode::OK), "{statuses:?}"); |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 862 | assert!( |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 863 | statuses[..statuses.len() - 1] |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 864 | .iter() |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 865 | .all(|s| *s == StatusCode::NO_CONTENT) |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 866 | ); |
0d604ee39751 | atagen | 2026-10-10 14:15 UTC | 867 | } |
f39b10e20a0b | atagen | 2026-10-10 14:33 UTC | 868 | |
f39b10e20a0b | atagen | 2026-10-10 14:33 UTC | 869 | #[tokio::test] |
f39b10e20a0b | atagen | 2026-10-10 14:33 UTC | 870 | async fn the_ruler_replaces_the_self_report() { |
f39b10e20a0b | atagen | 2026-10-10 14:33 UTC | 871 | let app = seeded_with(Floor::Bedroom, |_| {}); |
f39b10e20a0b | atagen | 2026-10-10 14:33 UTC | 872 | let before = send(&app, "GET", "/runs/cafebabe", &[], "").await; |
f39b10e20a0b | atagen | 2026-10-10 14:33 UTC | 873 | assert!(before.headers().contains_key("x-self-reported-length")); |
f39b10e20a0b | atagen | 2026-10-10 14:33 UTC | 874 | assert!(!before.headers().contains_key("x-length")); |
f39b10e20a0b | atagen | 2026-10-10 14:33 UTC | 875 | |
f39b10e20a0b | atagen | 2026-10-10 14:33 UTC | 876 | let app = seeded_with(Floor::Bedroom, |run| run.items.ruler = true); |
f39b10e20a0b | atagen | 2026-10-10 14:33 UTC | 877 | let after = send(&app, "GET", "/runs/cafebabe", &[], "").await; |
f39b10e20a0b | atagen | 2026-10-10 14:33 UTC | 878 | assert!(!after.headers().contains_key("x-self-reported-length")); |
f39b10e20a0b | atagen | 2026-10-10 14:33 UTC | 879 | assert!(after.headers().contains_key("x-length")); |
f39b10e20a0b | atagen | 2026-10-10 14:33 UTC | 880 | } |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 881 | |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 882 | #[tokio::test] |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 883 | async fn an_open_tab_is_linked_and_jelq_still_answers_with_choices() { |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 884 | let app = seeded_with(Floor::Bathroom, |run| { |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 885 | run.story = Story::Pending; |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 886 | run.warmed_up = true; |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 887 | }); |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 888 | let response = send(&app, "GET", "/runs/cafebabe", &[], "").await; |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 889 | let links = header(&response, "link"); |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 890 | assert!(links.contains("/branches/forum>; rel=\"https://jelq.dev/rels/branch\"")); |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 891 | assert!(links.contains("/branches/close-tab>; rel=\"https://jelq.dev/rels/branch\"")); |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 892 | assert!(links.contains("?technique=wet>")); |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 893 | let jelq = send(&app, "JELQ", "/runs/cafebabe?technique=edge", &[], "").await; |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 894 | assert_eq!(jelq.status(), StatusCode::MULTIPLE_CHOICES); |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 895 | } |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 896 | |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 897 | #[tokio::test] |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 898 | async fn either_story_choice_is_reachable_during_cooldown() { |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 899 | for choice in ["forum", "close-tab"] { |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 900 | let app = seeded_with(Floor::Bathroom, |run| { |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 901 | run.turn = 9; |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 902 | run.warmed_up = true; |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 903 | run.eq = 45; |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 904 | run.stamina = 1; |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 905 | run.items.door_locks = 1; |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 906 | }); |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 907 | let tenth = send(&app, "JELQ", "/runs/cafebabe?technique=edge", &[], "").await; |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 908 | assert_eq!(tenth.status(), StatusCode::OK); |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 909 | let response = send(&app, "GET", "/runs/cafebabe", &[], "").await; |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 910 | assert!(!header(&response, "link").contains("?technique=")); |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 911 | let path = format!("/runs/cafebabe/branches/{choice}"); |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 912 | assert!( |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 913 | header(&response, "link") |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 914 | .contains(&format!("<{path}>; rel=\"https://jelq.dev/rels/branch\"")) |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 915 | ); |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 916 | let chosen = send(&app, "POST", &path, &[], "").await; |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 917 | assert_eq!(chosen.status(), StatusCode::SEE_OTHER); |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 918 | assert!(!header(&chosen, "link").contains("/branches/")); |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 919 | let repeated = send(&app, "POST", &path, &[], "").await; |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 920 | assert_eq!(repeated.status(), StatusCode::CONFLICT); |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 921 | } |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 922 | } |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 923 | |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 924 | #[tokio::test] |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 925 | async fn a_door_lock_says_when_it_was_used() { |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 926 | let app = seeded_with(Floor::Bathroom, |run| { |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 927 | run.items.door_locks = 1; |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 928 | run.suspicion = SUSPICION_LIMIT; |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 929 | run.warmed_up = true; |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 930 | }); |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 931 | let response = send(&app, "JELQ", "/runs/cafebabe?technique=dry", &[], "").await; |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 932 | assert_ne!(response.status(), StatusCode::CONFLICT); |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 933 | assert!( |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 934 | response |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 935 | .headers() |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 936 | .get_all("warning") |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 937 | .iter() |
7d3fb63208bf | atagen | 2026-10-11 04:38 UTC | 938 | .any(|w| w.to_str().unwrap().contains("your brother tried the door")) |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 939 | ); |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 940 | } |
7d3fb63208bf | atagen | 2026-10-11 04:38 UTC | 941 | |
7d3fb63208bf | atagen | 2026-10-11 04:38 UTC | 942 | #[tokio::test] |
7d3fb63208bf | atagen | 2026-10-11 04:38 UTC | 943 | async fn shopping_survives_browsing_but_not_jelqing() { |
7d3fb63208bf | atagen | 2026-10-11 04:38 UTC | 944 | let app = seeded_with(Floor::ChangingRoom, |run| run.cash = 50); |
7d3fb63208bf | atagen | 2026-10-11 04:38 UTC | 945 | send(&app, "GET", "/runs/cafebabe/shop", &[], "").await; |
7d3fb63208bf | atagen | 2026-10-11 04:38 UTC | 946 | let view = send(&app, "GET", "/runs/cafebabe", &[], "").await; |
7d3fb63208bf | atagen | 2026-10-11 04:38 UTC | 947 | assert!(header(&view, "link").contains("shop-item")); |
7d3fb63208bf | atagen | 2026-10-11 04:38 UTC | 948 | let jelq = send(&app, "JELQ", "/runs/cafebabe?technique=warmup", &[], "").await; |
7d3fb63208bf | atagen | 2026-10-11 04:38 UTC | 949 | assert_ne!(jelq.status(), StatusCode::METHOD_NOT_ALLOWED); |
7d3fb63208bf | atagen | 2026-10-11 04:38 UTC | 950 | let after = send(&app, "GET", "/runs/cafebabe", &[], "").await; |
7d3fb63208bf | atagen | 2026-10-11 04:38 UTC | 951 | assert!(!header(&after, "link").contains("shop-item")); |
7d3fb63208bf | atagen | 2026-10-11 04:38 UTC | 952 | } |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 953 | |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 954 | #[tokio::test] |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 955 | async fn the_thread_announces_itself_at_the_branch() { |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 956 | let app = seeded_with(Floor::Bathroom, |run| { |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 957 | run.turn = 8; |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 958 | run.warmed_up = true; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 959 | run.items.baby_oil = 9; |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 960 | }); |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 961 | send( |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 962 | &app, |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 963 | "JELQ", |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 964 | "/runs/cafebabe?technique=wet", |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 965 | &[("content-type", "application/baby-oil")], |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 966 | "", |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 967 | ) |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 968 | .await; |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 969 | let ninth = send(&app, "GET", "/runs/cafebabe", &[], "").await; |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 970 | assert!(!header(&ninth, "link").contains("/forum/threads/2009")); |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 971 | let tenth = send( |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 972 | &app, |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 973 | "JELQ", |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 974 | "/runs/cafebabe?technique=wet", |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 975 | &[("content-type", "application/baby-oil")], |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 976 | "", |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 977 | ) |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 978 | .await; |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 979 | assert!( |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 980 | tenth |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 981 | .headers() |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 982 | .get_all("warning") |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 983 | .iter() |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 984 | .any(|w| w.to_str().unwrap().contains("a forum thread from 2009")) |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 985 | ); |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 986 | assert!(header(&tenth, "link").contains("/forum/threads/2009")); |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 987 | let announced = send(&app, "GET", "/runs/cafebabe", &[], "").await; |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 988 | assert!(header(&announced, "link").contains("/forum/threads/2009")); |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 989 | } |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 990 | |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 991 | #[tokio::test] |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 992 | async fn rereading_the_thread_teaches_uli() { |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 993 | let mut taught_runs = 0; |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 994 | for seed in 0..100u64 { |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 995 | let app = app_with(Floor::Bedroom, seed, |run| { |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 996 | run.turn = BRANCH_TURN; |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 997 | run.warmed_up = true; |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 998 | run.story = Story::ClosedTab; |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 999 | }); |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1000 | let mut taught = false; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1001 | for _ in 0..2 { |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1002 | let read = send(&app, "POST", "/runs/cafebabe/re-read", &[], "").await; |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1003 | match read.status() { |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1004 | StatusCode::NOT_MODIFIED => { |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1005 | assert!(header(&read, "warning").contains("2009")); |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1006 | } |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1007 | StatusCode::OK => { |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1008 | assert!(header(&read, "location").contains("/techniques")); |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1009 | taught = true; |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1010 | break; |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1011 | } |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1012 | other => panic!("seed {seed} read the thread into {other}"), |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1013 | } |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1014 | } |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1015 | let state = send(&app, "GET", "/runs/cafebabe", &[], "").await; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1016 | assert_eq!(header(&state, "x-stamina"), "10/10", "reading is free"); |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1017 | if taught { |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1018 | taught_runs += 1; |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1019 | let jelq = send(&app, "JELQ", "/runs/cafebabe?technique=uli", &[], "").await; |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1020 | assert_ne!(jelq.status(), StatusCode::FORBIDDEN); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1021 | } else { |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1022 | let cached = send(&app, "POST", "/runs/cafebabe/re-read", &[], "").await; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1023 | assert_eq!(cached.status(), StatusCode::OK); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1024 | assert!(header(&cached, "warning").starts_with("112")); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1025 | assert!(header(&cached, "age").parse::<u64>().unwrap() > 0); |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1026 | } |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1027 | } |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 1028 | assert!( |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1029 | (30..=58).contains(&taught_runs), |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1030 | "{taught_runs}/100 learned uli in two reads" |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 1031 | ); |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 1032 | } |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 1033 | |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 1034 | #[tokio::test] |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 1035 | async fn meditation_is_free_but_only_once_per_floor() { |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1036 | let app = seeded_with(Floor::Bedroom, |_| {}); |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 1037 | let response = send(&app, "JELQ", "/runs/cafebabe?technique=meditate", &[], "").await; |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 1038 | assert_eq!(response.status(), StatusCode::OK); |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 1039 | assert_eq!(header(&response, "x-eq"), "10"); |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 1040 | assert_eq!(header(&response, "x-stamina"), "10/10"); |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 1041 | let again = send(&app, "JELQ", "/runs/cafebabe?technique=meditate", &[], "").await; |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 1042 | assert_eq!(again.status(), StatusCode::CONFLICT); |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 1043 | } |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 1044 | |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 1045 | #[tokio::test] |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1046 | async fn meditation_is_listed_from_the_start() { |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 1047 | let app = seeded_with(Floor::Bedroom, |_| {}); |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 1048 | let view = send(&app, "GET", "/runs/cafebabe", &[], "").await; |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1049 | assert!(header(&view, "link").contains("technique=meditate")); |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 1050 | let jelq = send(&app, "JELQ", "/runs/cafebabe?technique=meditate", &[], "").await; |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1051 | assert_eq!(jelq.status(), StatusCode::OK); |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 1052 | } |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1053 | |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1054 | fn app_with(floor: Floor, seed: u64, setup: impl FnOnce(&mut Run)) -> Router { |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1055 | let state = Arc::new(AppState::default()); |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1056 | let mut run = Run::new("cafebabe".into(), "cafe".into(), seed); |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1057 | run.floor = floor; |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1058 | setup(&mut run); |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1059 | state.insert(run); |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1060 | router(state) |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1061 | } |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1062 | |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1063 | #[tokio::test] |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1064 | async fn hold_is_offered_only_at_the_edges() { |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1065 | let calm = seeded_with(Floor::Bedroom, |_| {}); |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1066 | let refused = send(&calm, "HOLD", "/runs/cafebabe", &[], "").await; |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1067 | assert_eq!(refused.status(), StatusCode::METHOD_NOT_ALLOWED); |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1068 | assert!(!header(&refused, "allow").contains("HOLD")); |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1069 | let view = send(&calm, "GET", "/runs/cafebabe", &[], "").await; |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1070 | assert!(!header(&view, "link").contains("HOLD")); |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1071 | let options = send(&calm, "OPTIONS", "/runs/cafebabe", &[], "").await; |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1072 | assert!(!header(&options, "allow").contains("HOLD")); |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1073 | |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1074 | let winded = seeded_with(Floor::Bedroom, |run| run.stamina = 2); |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1075 | let listed = send(&winded, "GET", "/runs/cafebabe", &[], "").await; |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1076 | assert!(header(&listed, "link").contains("HOLD")); |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1077 | let options = send(&winded, "OPTIONS", "/runs/cafebabe", &[], "").await; |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1078 | assert!(header(&options, "allow").contains("HOLD")); |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1079 | |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1080 | let hot = seeded_with(Floor::Bedroom, |run| { |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1081 | run.eq = 75; |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1082 | run.warmed_up = true; |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1083 | }); |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1084 | let held = send(&hot, "HOLD", "/runs/cafebabe", &[], "").await; |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1085 | assert_eq!(held.status(), StatusCode::NO_CONTENT); |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1086 | assert_eq!(header(&held, "x-stamina"), "10/10"); |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1087 | } |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1088 | |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1089 | #[tokio::test] |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1090 | async fn holding_calms_and_sometimes_reflects() { |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1091 | let mut calmed = 0; |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1092 | let mut reflected = 0; |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1093 | let mut ruptured = 0; |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1094 | for seed in 0..120u64 { |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1095 | let mut run = Run::new("cafebabe".into(), "cafe".into(), seed); |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1096 | run.eq = 75; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1097 | match run.hold() { |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1098 | Ok(_) if run.eq == 0 => reflected += 1, |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1099 | Ok(_) => calmed += 1, |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1100 | Err(_) => ruptured += 1, |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1101 | } |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1102 | } |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1103 | assert!( |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1104 | calmed > 100 && reflected > 0, |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1105 | "one HOLD in twelve should reflect, got {calmed} calm and {reflected} reflective of 120" |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1106 | ); |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1107 | assert!( |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1108 | calmed + reflected + ruptured == 120 && ruptured <= 4, |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1109 | "the flat 1 in 250 ruptured {ruptured} of 120 holds" |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1110 | ); |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1111 | } |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1112 | |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1113 | #[tokio::test] |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1114 | async fn leaving_the_band_warms_the_next_floor() { |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1115 | let app = seeded_with(Floor::Bedroom, |run| { |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1116 | run.eq = 60; |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1117 | run.warmed_up = true; |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1118 | run.here.turns = 6; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1119 | run.items.baby_oil = 9; |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1120 | }); |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1121 | let left = send(&app, "POST", "/runs/cafebabe/floor", &[], "").await; |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1122 | assert_eq!(left.status(), StatusCode::SEE_OTHER); |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1123 | let detail = json(left).await["detail"].as_str().unwrap().to_owned(); |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1124 | assert!(detail.contains("the warmth came with you")); |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1125 | |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1126 | let lube = [("content-type", "application/baby-oil")]; |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1127 | send(&app, "JELQ", "/runs/cafebabe?technique=warmup", &[], "").await; |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1128 | // The shower is a +35 warm-up, so EQ lands in the band and the band bonus rides along. |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1129 | // The arrival bonus is the one point the second jelq loses. |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1130 | let first = send(&app, "JELQ", "/runs/cafebabe?technique=wet", &lube, "").await; |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1131 | assert!( |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1132 | header(&first, "server-timing").contains("d20+4"), |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1133 | "the first jelq of a warm arrival rolls with +1, got {}", |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1134 | header(&first, "server-timing") |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1135 | ); |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1136 | let second = send(&app, "JELQ", "/runs/cafebabe?technique=wet", &lube, "").await; |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1137 | assert!(header(&second, "server-timing").contains("d20+3")); |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1138 | } |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1139 | |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1140 | #[tokio::test] |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1141 | async fn greed_multiplies_gains_above_the_band() { |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1142 | let lube = [("content-type", "application/baby-oil")]; |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1143 | for seed in 0..60u64 { |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1144 | let app = app_with(Floor::Bedroom, seed, |run| { |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1145 | run.eq = 60; |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1146 | run.warmed_up = true; |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1147 | }); |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1148 | let in_band = send(&app, "JELQ", "/runs/cafebabe?technique=wet", &lube, "").await; |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1149 | let app = app_with(Floor::Bedroom, seed, |run| { |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1150 | run.eq = 75; |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1151 | run.warmed_up = true; |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1152 | }); |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1153 | let greedy = send(&app, "JELQ", "/runs/cafebabe?technique=wet", &lube, "").await; |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1154 | if in_band.status() != StatusCode::OK || greedy.status() != StatusCode::OK { |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1155 | continue; |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1156 | } |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1157 | let steady = json(in_band).await["length"].as_f64().unwrap(); |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1158 | let eager = json(greedy).await["length"].as_f64().unwrap(); |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1159 | assert!( |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1160 | (eager - steady * 1.5).abs() < 1e-9, |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1161 | "seed {seed} gained {eager} above the band against {steady} inside it" |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1162 | ); |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1163 | return; |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1164 | } |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1165 | panic!("no seed in 60 produced two clean rolls to compare"); |
4347977b8192 | atagen | 2026-10-11 04:56 UTC | 1166 | } |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1167 | |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1168 | #[tokio::test] |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1169 | async fn the_kitchen_is_only_on_the_home_floors() { |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1170 | let absent = seeded_with(Floor::Bathroom, |_| {}); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1171 | let no_kitchen = send(&absent, "POST", "/runs/cafebabe/kitchen", &[], "").await; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1172 | assert_eq!(no_kitchen.status(), StatusCode::NOT_FOUND); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1173 | let view = send(&absent, "GET", "/runs/cafebabe", &[], "").await; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1174 | assert!(!header(&view, "link").contains("/kitchen")); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1175 | |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1176 | let app = seeded_with(Floor::Bedroom, |_| {}); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1177 | let view = send(&app, "GET", "/runs/cafebabe", &[], "").await; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1178 | assert!(header(&view, "link").contains("/kitchen")); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1179 | let raid = send(&app, "POST", "/runs/cafebabe/kitchen", &[], "").await; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1180 | assert_ne!(raid.status(), StatusCode::NOT_FOUND); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1181 | } |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1182 | |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1183 | #[tokio::test] |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1184 | async fn raids_cost_the_turn_and_the_fridge_pays_out_sometimes() { |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1185 | let mut bounties = std::collections::BTreeSet::new(); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1186 | let mut told = 0; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1187 | for seed in 0..80u64 { |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1188 | let mut run = Run::new("cafebabe".into(), "cafe".into(), seed); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1189 | let Ok(outcome) = run.raid_kitchen() else { |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1190 | panic!("the first raid should never fail"); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1191 | }; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1192 | assert_eq!(run.turn, 1, "a raid costs the floor turn"); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1193 | assert!(!run.here.melon_offered, "no melon at starting EQ"); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1194 | if outcome.status == StatusCode::NO_CONTENT { |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1195 | bounties.insert("empty"); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1196 | } else { |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1197 | bounties.insert("loot"); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1198 | } |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1199 | told += u32::from(run.kitchen_tellings); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1200 | } |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1201 | assert!(bounties.contains("loot") && bounties.contains("empty")); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1202 | assert!( |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1203 | (0..80).any(|seed| { |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1204 | let mut run = Run::new("cafebabe".into(), "cafe".into(), seed); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1205 | run.raid_kitchen().is_ok() && run.kitchen_tellings == 0 |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1206 | }), |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1207 | "most raids go unremarked" |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1208 | ); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1209 | assert!(told > 0, "someone should have been told across 80 raids"); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1210 | } |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1211 | |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1212 | #[tokio::test] |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1213 | async fn the_watermelon_offers_itself_above_ninety() { |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1214 | let mut offered = 0; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1215 | let mut caught = 0; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1216 | let mut survived = 0; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1217 | for seed in 0..120u64 { |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1218 | let mut run = Run::new("cafebabe".into(), "cafe".into(), seed); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1219 | run.eq = 95; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1220 | let Ok(outcome) = run.raid_kitchen() else { |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1221 | continue; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1222 | }; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1223 | if outcome.status != StatusCode::MULTIPLE_CHOICES { |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1224 | continue; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1225 | } |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1226 | offered += 1; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1227 | let gains = run.length; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1228 | let disgrace = run.shame; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1229 | if run.commit_melon().is_err() { |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1230 | caught += 1; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1231 | assert_eq!(run.ended.as_ref().unwrap().cause.slug(), "watermelon"); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1232 | } else { |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1233 | survived += 1; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1234 | assert_eq!(run.eq, 0); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1235 | assert_eq!(run.shame, disgrace + 5); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1236 | assert_eq!(run.length, gains, "the gains are kept"); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1237 | } |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1238 | } |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1239 | assert!( |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1240 | offered > 20, |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1241 | "the melon should appear in two fifths of raids" |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1242 | ); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1243 | assert!(caught > 0 && survived > 0, "caught is one in three"); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1244 | } |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1245 | |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1246 | #[tokio::test] |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1247 | async fn a_melon_offer_does_not_survive_a_non_kitchen_turn() { |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1248 | for seed in 0..60u64 { |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1249 | let jelq_app = app_with(Floor::Bedroom, seed, |run| { |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1250 | run.warmed_up = true; |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1251 | run.here.melon_offered = true; |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1252 | }); |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1253 | let stroked = send( |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1254 | &jelq_app, |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1255 | "JELQ", |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1256 | "/runs/cafebabe?technique=wet&intensity=2", |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1257 | &[], |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1258 | "", |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1259 | ) |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1260 | .await; |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1261 | if stroked.status() != StatusCode::OK && stroked.status() != StatusCode::PARTIAL_CONTENT { |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1262 | continue; |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1263 | } |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1264 | let bite = send( |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1265 | &jelq_app, |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1266 | "POST", |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1267 | "/runs/cafebabe/kitchen/watermelon", |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1268 | &[], |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1269 | "", |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1270 | ) |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1271 | .await; |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1272 | assert_eq!( |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1273 | bite.status(), |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1274 | StatusCode::CONFLICT, |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1275 | "seed {seed} kept the melon through a jelq" |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1276 | ); |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1277 | |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1278 | let hold_app = app_with(Floor::Bedroom, seed, |run| { |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1279 | run.stamina = 2; |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1280 | run.here.melon_offered = true; |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1281 | }); |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1282 | let held = send(&hold_app, "HOLD", "/runs/cafebabe", &[], "").await; |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1283 | if held.status() != StatusCode::NO_CONTENT { |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1284 | continue; |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1285 | } |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1286 | let bite = send( |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1287 | &hold_app, |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1288 | "POST", |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1289 | "/runs/cafebabe/kitchen/watermelon", |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1290 | &[], |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1291 | "", |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1292 | ) |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1293 | .await; |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1294 | assert_eq!( |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1295 | bite.status(), |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1296 | StatusCode::CONFLICT, |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1297 | "seed {seed} kept the melon through a hold" |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1298 | ); |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1299 | |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1300 | let read_app = app_with(Floor::Bedroom, seed, |run| { |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1301 | run.story = Story::ClosedTab; |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1302 | run.here.melon_offered = true; |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1303 | }); |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1304 | let read = send(&read_app, "POST", "/runs/cafebabe/re-read", &[], "").await; |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1305 | if read.status() == StatusCode::INTERNAL_SERVER_ERROR { |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1306 | continue; |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1307 | } |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1308 | let bite = send( |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1309 | &read_app, |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1310 | "POST", |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1311 | "/runs/cafebabe/kitchen/watermelon", |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1312 | &[], |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1313 | "", |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1314 | ) |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1315 | .await; |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1316 | assert_eq!( |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1317 | bite.status(), |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1318 | StatusCode::CONFLICT, |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1319 | "seed {seed} kept the melon through a re-read" |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1320 | ); |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1321 | } |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1322 | |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1323 | let mut stood = 0; |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1324 | for seed in 0..60u64 { |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1325 | let mut run = Run::new("cafebabe".into(), "cafe".into(), seed); |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1326 | run.eq = 95; |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1327 | run.here.melon_offered = true; |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1328 | if run.raid_kitchen().is_err() { |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1329 | continue; |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1330 | } |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1331 | stood += 1; |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1332 | assert!( |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1333 | run.here.melon_offered, |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1334 | "seed {seed} lost the melon to another raid" |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1335 | ); |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1336 | } |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1337 | assert!(stood > 40, "raids at eq 95 rarely rupture"); |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1338 | } |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1339 | |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 1340 | #[tokio::test] |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1341 | async fn the_kitchen_closes_after_two_tellings() { |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1342 | let mut closed = None; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1343 | for seed in 0..300u64 { |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1344 | let mut run = Run::new("cafebabe".into(), "cafe".into(), seed); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1345 | let first = run.raid_kitchen(); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1346 | let second = run.raid_kitchen(); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1347 | if second.is_err() && first.is_ok() { |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1348 | assert_eq!(run.kitchen_tellings, 2); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1349 | let Err(third) = run.raid_kitchen() else { |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1350 | panic!("the kitchen should be gone"); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1351 | }; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1352 | assert_eq!(third.status(), StatusCode::GONE); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1353 | closed = Some(seed); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1354 | break; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1355 | } |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1356 | } |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1357 | assert!( |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1358 | closed.is_some(), |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1359 | "two tellings should occur within 300 seeds" |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1360 | ); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1361 | } |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1362 | |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1363 | #[tokio::test] |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1364 | async fn lubes_run_out_but_spit_never_does() { |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1365 | let app = seeded_with(Floor::Bedroom, |run| { |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1366 | run.warmed_up = true; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1367 | run.items.baby_oil = 1; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1368 | }); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1369 | let lube = [("content-type", "application/baby-oil")]; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1370 | let first = send(&app, "JELQ", "/runs/cafebabe?technique=wet", &lube, "").await; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1371 | assert_ne!(first.status(), StatusCode::PRECONDITION_FAILED); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1372 | let second = send(&app, "JELQ", "/runs/cafebabe?technique=wet", &lube, "").await; |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1373 | assert_eq!(second.status(), StatusCode::UNSUPPORTED_MEDIA_TYPE); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1374 | |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1375 | let spit = [("content-type", "text/plain; charset=spit")]; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1376 | for _ in 0..3 { |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1377 | let wet = send(&app, "JELQ", "/runs/cafebabe?technique=wet", &spit, "").await; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1378 | assert_ne!(wet.status(), StatusCode::PRECONDITION_FAILED); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1379 | } |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1380 | } |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1381 | |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1382 | #[tokio::test] |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1383 | async fn energy_drinks_add_three_stamina() { |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1384 | let app = seeded_with(Floor::Bedroom, |run| { |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1385 | run.stamina = 2; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1386 | run.items.energy_drinks = 1; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1387 | }); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1388 | let view = send(&app, "GET", "/runs/cafebabe", &[], "").await; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1389 | assert!(header(&view, "link").contains("technique=energy")); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1390 | let drink = send(&app, "JELQ", "/runs/cafebabe?technique=energy", &[], "").await; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1391 | assert_eq!(drink.status(), StatusCode::OK); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1392 | let view = send(&app, "GET", "/runs/cafebabe", &[], "").await; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1393 | assert_eq!(header(&view, "x-stamina"), "5/10"); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1394 | let again = send(&app, "JELQ", "/runs/cafebabe?technique=energy", &[], "").await; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1395 | assert_eq!(again.status(), StatusCode::FAILED_DEPENDENCY); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1396 | } |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1397 | |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1398 | #[tokio::test] |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1399 | async fn the_working_supplement_resets_stamina() { |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1400 | let mut worked = 0; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1401 | let mut bunk = 0; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1402 | for seed in 0..60u64 { |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1403 | let app = app_with(Floor::Bedroom, seed, |run| { |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1404 | run.stamina = 1; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1405 | run.items.supplements = 1; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1406 | }); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1407 | let taken = send(&app, "JELQ", "/runs/cafebabe?technique=supplement", &[], "").await; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1408 | if taken.status() == StatusCode::OK { |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1409 | worked += 1; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1410 | let view = send(&app, "GET", "/runs/cafebabe", &[], "").await; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1411 | assert_eq!(header(&view, "x-stamina"), "10/10"); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1412 | } else { |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1413 | assert_eq!(taken.status(), StatusCode::BAD_GATEWAY); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1414 | bunk += 1; |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1415 | } |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1416 | } |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1417 | assert!(worked > 0 && bunk > 0, "one in five should work too well"); |
0a0bfee8329e | atagen | 2026-10-11 05:11 UTC | 1418 | } |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1419 | |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1420 | #[tokio::test] |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1421 | async fn dry_jelqs_build_friction_and_real_lube_does_not() { |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1422 | let app = seeded_with(Floor::Bedroom, |run| { |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1423 | run.warmed_up = true; |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1424 | run.foreskin = Some(0.9); |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1425 | }); |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1426 | let dry = send(&app, "JELQ", "/runs/cafebabe?technique=dry", &[], "").await; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1427 | assert_eq!(header(&dry, "x-friction"), "2/10"); |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1428 | let lube = [("content-type", "application/baby-oil")]; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1429 | let wet = send( |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1430 | &app, |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1431 | "JELQ", |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1432 | "/runs/cafebabe?technique=wet&intensity=5", |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1433 | &lube, |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1434 | "", |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1435 | ) |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1436 | .await; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1437 | assert_eq!(header(&wet, "x-friction"), "2/10"); |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1438 | let spit = [("content-type", "text/plain; charset=spit")]; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1439 | let glisten = send( |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1440 | &app, |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1441 | "JELQ", |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1442 | "/runs/cafebabe?technique=wet&intensity=5", |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1443 | &spit, |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1444 | "", |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1445 | ) |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1446 | .await; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1447 | assert_eq!(header(&glisten, "x-friction"), "3/10"); |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1448 | } |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1449 | |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1450 | #[tokio::test] |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1451 | async fn switching_grips_makes_the_friction_cheaper() { |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1452 | let app = seeded_with(Floor::Bedroom, |run| { |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1453 | run.warmed_up = true; |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1454 | run.foreskin = Some(0.9); |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1455 | }); |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1456 | let dry = send(&app, "JELQ", "/runs/cafebabe?technique=dry", &[], "").await; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1457 | assert_eq!(header(&dry, "x-friction"), "2/10"); |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1458 | send( |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1459 | &app, |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1460 | "GET", |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1461 | "/runs/cafebabe/grip", |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1462 | &[("upgrade", "underhand"), ("connection", "upgrade")], |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1463 | "", |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1464 | ) |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1465 | .await; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1466 | let switched = send(&app, "JELQ", "/runs/cafebabe?technique=dry", &[], "").await; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1467 | assert_eq!(header(&switched, "x-friction"), "3/10"); |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1468 | let settled = send(&app, "JELQ", "/runs/cafebabe?technique=dry", &[], "").await; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1469 | assert_eq!(header(&settled, "x-friction"), "5/10"); |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1470 | } |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1471 | |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1472 | #[tokio::test] |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1473 | async fn holding_and_meditating_shed_friction() { |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1474 | let app = seeded_with(Floor::Bedroom, |run| { |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1475 | run.eq = 80; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1476 | run.friction = 5; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1477 | }); |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1478 | let held = send(&app, "HOLD", "/runs/cafebabe", &[], "").await; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1479 | assert_eq!(held.status(), StatusCode::NO_CONTENT); |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1480 | let view = send(&app, "GET", "/runs/cafebabe", &[], "").await; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1481 | assert_eq!(header(&view, "x-friction"), "3/10"); |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1482 | |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1483 | let taught = seeded_with(Floor::Bedroom, |run| { |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1484 | run.friction = 5; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1485 | }); |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1486 | let calmed = send( |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1487 | &taught, |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1488 | "JELQ", |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1489 | "/runs/cafebabe?technique=meditate", |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1490 | &[], |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1491 | "", |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1492 | ) |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1493 | .await; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1494 | assert_eq!(calmed.status(), StatusCode::OK); |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1495 | let view = send(&taught, "GET", "/runs/cafebabe", &[], "").await; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1496 | assert_eq!(header(&view, "x-friction"), "3/10"); |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1497 | } |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1498 | |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1499 | #[tokio::test] |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1500 | async fn a_friction_burn_halves_the_gains() { |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1501 | let lube = [("content-type", "application/baby-oil")]; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1502 | let path = "/runs/cafebabe?technique=wet&intensity=5"; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1503 | for seed in 0..60u64 { |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1504 | let steady = app_with(Floor::Bedroom, seed, |run| { |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1505 | run.warmed_up = true; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1506 | run.eq = 60; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1507 | run.items.baby_oil = 9; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1508 | }); |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1509 | let hurt_app = app_with(Floor::Bedroom, seed, |run| { |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1510 | run.warmed_up = true; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1511 | run.eq = 60; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1512 | run.items.baby_oil = 9; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1513 | run.conditions.friction_burn = true; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1514 | }); |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1515 | let calm = send(&steady, "JELQ", path, &lube, "").await; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1516 | let hurt = send(&hurt_app, "JELQ", path, &lube, "").await; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1517 | if calm.status() != StatusCode::OK || hurt.status() != StatusCode::OK { |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1518 | continue; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1519 | } |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1520 | let calm_gain = json(calm).await["length"].as_f64().unwrap(); |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1521 | let hurt_gain = json(hurt).await["length"].as_f64().unwrap(); |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1522 | assert!( |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1523 | (hurt_gain * 2.0 - calm_gain).abs() < 1e-9, |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1524 | "seed {seed} burned {hurt_gain} against {calm_gain}" |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1525 | ); |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1526 | return; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1527 | } |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1528 | panic!("no seed in 60 produced two clean rolls to compare"); |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1529 | } |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1530 | |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1531 | #[tokio::test] |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1532 | async fn the_burn_warns_and_the_ice_treats_it() { |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1533 | let app = seeded_with(Floor::Bedroom, |run| { |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1534 | run.warmed_up = true; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1535 | run.eq = 60; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1536 | run.items.baby_oil = 9; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1537 | run.friction = 7; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1538 | run.conditions.friction_burn = true; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1539 | }); |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1540 | let lube = [("content-type", "application/baby-oil")]; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1541 | let jelq = send( |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1542 | &app, |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1543 | "JELQ", |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1544 | "/runs/cafebabe?technique=wet&intensity=5", |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1545 | &lube, |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1546 | "", |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1547 | ) |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1548 | .await; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1549 | let warnings: Vec<_> = jelq |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1550 | .headers() |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1551 | .get_all("warning") |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1552 | .iter() |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1553 | .filter_map(|w| w.to_str().ok()) |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1554 | .collect(); |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1555 | assert!(warnings.contains(&"199 - \"friction burn\"")); |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1556 | send(&app, "JELQ", "/runs/cafebabe?technique=ice", &[], "").await; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1557 | let view = send(&app, "GET", "/runs/cafebabe", &[], "").await; |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1558 | let warnings: Vec<_> = view |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1559 | .headers() |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1560 | .get_all("warning") |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1561 | .iter() |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1562 | .filter_map(|w| w.to_str().ok()) |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1563 | .collect(); |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1564 | assert!(!warnings.contains(&"199 - \"friction burn\"")); |
5dfebcc0ac43 | atagen | 2026-10-11 05:28 UTC | 1565 | } |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1566 | |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1567 | #[tokio::test] |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1568 | async fn the_burn_shifts_the_rupture_tiers() { |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1569 | async fn ruptures(burned: bool) -> u32 { |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1570 | let mut gone = 0; |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1571 | for seed in 0..400u64 { |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1572 | let app = app_with(Floor::Bedroom, seed, |run| { |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1573 | run.warmed_up = true; |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1574 | run.eq = 60; |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1575 | run.items.baby_oil = 9; |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1576 | run.conditions.friction_burn = burned; |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1577 | }); |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1578 | let lube = [("content-type", "application/baby-oil")]; |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1579 | let jelq = send( |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1580 | &app, |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1581 | "JELQ", |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1582 | "/runs/cafebabe?technique=wet&intensity=5", |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1583 | &lube, |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1584 | "", |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1585 | ) |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1586 | .await; |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1587 | if jelq.status() == StatusCode::INTERNAL_SERVER_ERROR { |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1588 | gone += 1; |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1589 | } |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1590 | } |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1591 | gone |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1592 | } |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1593 | let burned = ruptures(true).await; |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1594 | let calm = ruptures(false).await; |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1595 | assert!( |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1596 | burned >= 8 && calm <= 4, |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1597 | "burned {burned} ruptures against {calm}" |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1598 | ); |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1599 | } |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1600 | |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1601 | #[tokio::test] |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1602 | async fn meditation_respects_the_priapism_floor() { |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1603 | let app = seeded_with(Floor::Bedroom, |run| { |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1604 | run.eq = 80; |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1605 | run.conditions.priapism_turns = 3; |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1606 | }); |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1607 | let calmed = send(&app, "JELQ", "/runs/cafebabe?technique=meditate", &[], "").await; |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1608 | assert_eq!(calmed.status(), StatusCode::OK); |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1609 | let view = send(&app, "GET", "/runs/cafebabe", &[], "").await; |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1610 | assert_eq!(header(&view, "x-eq"), "75"); |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1611 | } |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1612 | |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1613 | #[tokio::test] |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1614 | async fn the_kitchen_pays_out_at_the_documented_odds() { |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1615 | let mut oil = 0; |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1616 | let mut drinks = 0; |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1617 | let mut packs = 0; |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1618 | for seed in 0..600u64 { |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1619 | let mut run = Run::new("cafebabe".into(), "cafe".into(), seed); |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1620 | run.kitchen_tellings = 0; |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1621 | let held = ( |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1622 | run.items.coconut_oil, |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1623 | run.items.energy_drinks, |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1624 | run.items.ice_packs, |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1625 | ); |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1626 | let _ = run.raid_kitchen(); |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1627 | oil += u32::from(run.items.coconut_oil > held.0); |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1628 | drinks += u32::from(run.items.energy_drinks > held.1); |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1629 | packs += u32::from(run.items.ice_packs > held.2); |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1630 | } |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1631 | assert!((170..=230).contains(&oil), "coconut {oil} in 600"); |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1632 | assert!((90..=150).contains(&drinks), "energy {drinks} in 600"); |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1633 | assert!((45..=105).contains(&packs), "ice {packs} in 600"); |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1634 | } |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1635 | |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1636 | #[tokio::test] |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1637 | async fn a_refused_jelq_leaves_the_lube_alone() { |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1638 | let app = seeded_with(Floor::Bedroom, |run| { |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1639 | run.warmed_up = true; |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1640 | run.items.extender = true; |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1641 | run.girth = STORAGE_GIRTH + 1.0; |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1642 | }); |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1643 | let lube = [("content-type", "application/baby-oil")]; |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1644 | let full = send( |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1645 | &app, |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1646 | "JELQ", |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1647 | "/runs/cafebabe?technique=wet&intensity=5", |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1648 | &lube, |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1649 | "", |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1650 | ) |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1651 | .await; |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1652 | assert_eq!(full.status(), StatusCode::INSUFFICIENT_STORAGE); |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1653 | let inv = send(&app, "GET", "/runs/cafebabe/inventory", &[], "").await; |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1654 | let body = json(inv).await; |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1655 | let held = body["items"].as_array().unwrap(); |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1656 | assert!(held.iter().any(|i| i["name"] == "baby-oil")); |
139164489032 | atagen | 2026-10-11 05:46 UTC | 1657 | } |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1658 | |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1659 | #[tokio::test] |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1660 | async fn an_empty_bottle_is_declined_before_the_enemy_stirs() { |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1661 | let control = seeded_with(Floor::ChangingRoom, |run| { |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1662 | run.warmed_up = true; |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1663 | run.suspicion = SUSPICION_LIMIT; |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1664 | }); |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1665 | let lube = [("content-type", "application/baby-oil")]; |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1666 | let caught = send( |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1667 | &control, |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1668 | "JELQ", |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1669 | "/runs/cafebabe?technique=wet&intensity=5", |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1670 | &lube, |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1671 | "", |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1672 | ) |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1673 | .await; |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1674 | assert_eq!(caught.status(), StatusCode::UNAVAILABLE_FOR_LEGAL_REASONS); |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1675 | |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1676 | let app = seeded_with(Floor::ChangingRoom, |run| { |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1677 | run.warmed_up = true; |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1678 | run.suspicion = SUSPICION_LIMIT; |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1679 | run.items.baby_oil = 0; |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1680 | }); |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1681 | let refused = send( |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1682 | &app, |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1683 | "JELQ", |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1684 | "/runs/cafebabe?technique=wet&intensity=5", |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1685 | &lube, |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1686 | "", |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1687 | ) |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1688 | .await; |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1689 | assert_eq!(refused.status(), StatusCode::UNSUPPORTED_MEDIA_TYPE); |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1690 | let view = send(&app, "GET", "/runs/cafebabe", &[], "").await; |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1691 | assert_eq!(header(&view, "x-suspicion"), "5/5"); |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1692 | assert_eq!(header(&view, "x-shame"), "0"); |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1693 | } |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1694 | |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1695 | #[tokio::test] |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1696 | async fn the_top_tier_rolls_a_single_third() { |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1697 | let mut ruptures = 0; |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1698 | let mut early = 0; |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1699 | for seed in 0..400u64 { |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1700 | let app = app_with(Floor::Bedroom, seed, |run| { |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1701 | run.warmed_up = true; |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1702 | run.eq = 96; |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1703 | run.items.baby_oil = 9; |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1704 | run.items.blinds = true; |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1705 | }); |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1706 | let lube = [("content-type", "application/baby-oil")]; |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1707 | let jelq = send( |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1708 | &app, |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1709 | "JELQ", |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1710 | "/runs/cafebabe?technique=wet&intensity=5", |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1711 | &lube, |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1712 | "", |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1713 | ) |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1714 | .await; |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1715 | match jelq.status() { |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1716 | StatusCode::INTERNAL_SERVER_ERROR => ruptures += 1, |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1717 | StatusCode::TOO_EARLY => early += 1, |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1718 | other => panic!("seed {seed} ended in {other}"), |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1719 | } |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1720 | } |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1721 | assert!( |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1722 | (90..=175).contains(&ruptures), |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1723 | "ruptures {ruptures} of 400 against {early} early" |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1724 | ); |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1725 | assert!( |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1726 | (225..=310).contains(&early), |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1727 | "early {early} of 400 against {ruptures} ruptures" |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1728 | ); |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1729 | } |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1730 | |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1731 | #[tokio::test] |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1732 | async fn priapism_holds_the_floor_through_every_reset() { |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1733 | let exit = seeded_with(Floor::Bedroom, |run| { |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1734 | run.warmed_up = true; |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1735 | run.eq = 90; |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1736 | run.here.turns = 99; |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1737 | run.conditions.priapism_turns = 3; |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1738 | }); |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1739 | let out = send(&exit, "POST", "/runs/cafebabe/floor", &[], "").await; |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1740 | assert_eq!(out.status(), StatusCode::SEE_OTHER); |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1741 | let view = send(&exit, "GET", "/runs/cafebabe", &[], "").await; |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1742 | assert_eq!(header(&view, "x-eq"), "75"); |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1743 | |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1744 | let melon = seeded_with(Floor::Bedroom, |run| { |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1745 | run.eq = 95; |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1746 | run.here.melon_offered = true; |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1747 | run.conditions.priapism_turns = 2; |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1748 | }); |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1749 | let bite = send(&melon, "POST", "/runs/cafebabe/kitchen/watermelon", &[], "").await; |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1750 | assert_eq!(bite.status(), StatusCode::OK); |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1751 | let view = send(&melon, "GET", "/runs/cafebabe", &[], "").await; |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1752 | assert_eq!(header(&view, "x-eq"), "75"); |
14de3e1e8dc2 | atagen | 2026-10-11 06:19 UTC | 1753 | } |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1754 | |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1755 | #[tokio::test] |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1756 | async fn holding_rolls_a_flat_rupture_chance() { |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1757 | async fn ruptures(eq: i32, stamina: i32) -> u32 { |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1758 | let mut gone = 0; |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1759 | for seed in 0..600u64 { |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1760 | let app = app_with(Floor::Bedroom, seed, |run| { |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1761 | run.warmed_up = true; |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1762 | run.eq = eq; |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1763 | run.stamina = stamina; |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1764 | }); |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1765 | let held = send(&app, "HOLD", "/runs/cafebabe", &[], "").await; |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1766 | if held.status() == StatusCode::INTERNAL_SERVER_ERROR { |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1767 | gone += 1; |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1768 | } |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1769 | } |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1770 | gone |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1771 | } |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1772 | let high = ruptures(90, 10).await; |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1773 | let low = ruptures(30, 2).await; |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1774 | assert!((0..=9).contains(&high), "high holds ruptured {high}/600"); |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1775 | assert!((0..=9).contains(&low), "low holds ruptured {low}/600"); |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1776 | } |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1777 | |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1778 | #[tokio::test] |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1779 | async fn the_kitchen_rolls_the_normal_tiers() { |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1780 | async fn ruptures(eq: i32) -> u32 { |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1781 | let mut gone = 0; |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1782 | for seed in 0..600u64 { |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1783 | let app = app_with(Floor::Bedroom, seed, |run| run.eq = eq); |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1784 | let raid = send(&app, "POST", "/runs/cafebabe/kitchen", &[], "").await; |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1785 | if raid.status() == StatusCode::INTERNAL_SERVER_ERROR { |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1786 | gone += 1; |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1787 | } |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1788 | } |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1789 | gone |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1790 | } |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1791 | let hot = ruptures(96).await; |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1792 | let cool = ruptures(40).await; |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1793 | assert!((40..=80).contains(&hot), "hot kitchen ruptured {hot}/600"); |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1794 | assert!((0..=9).contains(&cool), "cool kitchen ruptured {cool}/600"); |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 1795 | } |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1796 | |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1797 | #[tokio::test] |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1798 | async fn the_thread_cannot_be_reread_before_anyone_mentions_it() { |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1799 | let app = seeded_with(Floor::Bedroom, |run| run.warmed_up = true); |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1800 | let read = send(&app, "POST", "/runs/cafebabe/re-read", &[], "").await; |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1801 | assert_eq!(read.status(), StatusCode::NOT_FOUND); |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1802 | let after = send(&app, "GET", "/runs/cafebabe", &[], "").await; |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1803 | assert_eq!(header(&after, "x-floor"), "1"); |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1804 | assert!(!header(&after, "link").contains("/re-read")); |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1805 | } |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1806 | |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1807 | #[tokio::test] |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1808 | async fn any_other_action_takes_the_melon_off_the_table() { |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1809 | for (method, uri) in [ |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1810 | ("JELQ", "/runs/cafebabe?technique=warmup"), |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1811 | ("POST", "/runs/cafebabe/drawer"), |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1812 | ] { |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1813 | let app = seeded_with(Floor::Bedroom, |run| { |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1814 | run.eq = 95; |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1815 | run.here.melon_offered = true; |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1816 | }); |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1817 | send(&app, method, uri, &[], "").await; |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1818 | let melon = send(&app, "POST", "/runs/cafebabe/kitchen/watermelon", &[], "").await; |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1819 | assert_eq!(melon.status(), StatusCode::CONFLICT, "{method} {uri}"); |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1820 | } |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1821 | } |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1822 | |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1823 | #[tokio::test] |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1824 | async fn a_refused_jelq_does_not_break_the_edging_streak() { |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1825 | let app = seeded_with(Floor::ChangingRoom, |run| { |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1826 | run.warmed_up = true; |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1827 | run.eq = 45; |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1828 | run.here.edges = 2; |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1829 | }); |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1830 | let refused = send( |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1831 | &app, |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1832 | "JELQ", |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1833 | "/runs/cafebabe?technique=dry", |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1834 | &[("content-type", "application/baby-oil")], |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1835 | "", |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1836 | ) |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1837 | .await; |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1838 | assert_eq!(refused.status(), StatusCode::UNSUPPORTED_MEDIA_TYPE); |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1839 | let third = send(&app, "JELQ", "/runs/cafebabe?technique=edge", &[], "").await; |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1840 | assert_eq!(third.status(), StatusCode::LOOP_DETECTED); |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1841 | } |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1842 | |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1843 | #[tokio::test] |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1844 | async fn an_interrupted_edge_keeps_no_gains() { |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1845 | let app = seeded_with(Floor::ChangingRoom, |run| { |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1846 | run.warmed_up = true; |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1847 | run.eq = 10; |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1848 | }); |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1849 | let before = send(&app, "GET", "/runs/cafebabe", &[], "").await; |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1850 | let girth = header(&before, "x-girth").to_owned(); |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1851 | let edge = send(&app, "JELQ", "/runs/cafebabe?technique=edge", &[], "").await; |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1852 | assert_eq!(edge.status(), StatusCode::NOT_FOUND); |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1853 | assert_eq!(header(&edge, "x-girth"), girth); |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1854 | } |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1855 | |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1856 | #[tokio::test] |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1857 | async fn rummaging_for_the_key_leaves_the_drawer_unsearched() { |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1858 | let mut found = 0; |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1859 | for seed in 0..20u64 { |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1860 | let app = app_with(Floor::Hotel, seed, |run| { |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1861 | run.here.wifi_accepted = true; |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1862 | run.items.cage = true; |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1863 | }); |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1864 | for _ in 0..30 { |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1865 | let rummage = send(&app, "POST", "/runs/cafebabe/drawer", &[], "").await; |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1866 | if rummage.status() == StatusCode::OK { |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1867 | break; |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1868 | } |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1869 | } |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1870 | let search = send(&app, "POST", "/runs/cafebabe/drawer", &[], "").await; |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1871 | if search.status() == StatusCode::FOUND { |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1872 | assert!(header(&search, "location").ends_with("/inventory/do-not-disturb-sign")); |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1873 | found += 1; |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1874 | } |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1875 | } |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1876 | assert!( |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1877 | found >= 18, |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1878 | "only {found} of 20 hotel drawers survived the rummage" |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1879 | ); |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1880 | } |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1881 | |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1882 | #[tokio::test] |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1883 | async fn a_full_server_buries_the_dead_to_make_room() { |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1884 | let app = crate::app(Config { |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1885 | max_runs: 1, |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1886 | ..Config::default() |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1887 | }); |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1888 | let first = send(&app, "POST", "/runs", &[], "").await; |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1889 | let location = header(&first, "location").to_owned(); |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1890 | let full = send(&app, "POST", "/runs", &[], "").await; |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1891 | assert_eq!(full.status(), StatusCode::SERVICE_UNAVAILABLE); |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1892 | send(&app, "DELETE", &location, &[], "").await; |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1893 | let second = send(&app, "POST", "/runs", &[], "").await; |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1894 | assert_eq!(second.status(), StatusCode::CREATED); |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 1895 | } |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1896 | |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1897 | #[tokio::test] |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1898 | async fn the_towel_warms_once_until_the_kettle_boils() { |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1899 | let app = seeded_with(Floor::Bedroom, |_| {}); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1900 | let warm = send(&app, "JELQ", "/runs/cafebabe?technique=warmup", &[], "").await; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1901 | assert_eq!(warm.status(), StatusCode::OK); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1902 | let again = send(&app, "JELQ", "/runs/cafebabe?technique=warmup", &[], "").await; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1903 | assert_eq!(again.status(), StatusCode::CONFLICT); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1904 | |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1905 | let app = seeded_with(Floor::Bedroom, |run| { |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1906 | run.warmed_up = true; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1907 | run.here.kettle_boiled = true; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1908 | }); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1909 | let reheated = send(&app, "JELQ", "/runs/cafebabe?technique=warmup", &[], "").await; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1910 | assert_eq!(reheated.status(), StatusCode::OK); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1911 | let cold = send(&app, "JELQ", "/runs/cafebabe?technique=warmup", &[], "").await; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1912 | assert_eq!(cold.status(), StatusCode::CONFLICT); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1913 | } |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1914 | |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1915 | #[tokio::test] |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1916 | async fn the_refractory_period_is_the_next_hold() { |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1917 | let app = seeded_with(Floor::Hotel, |run| { |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1918 | run.here.wifi_accepted = true; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1919 | run.warmed_up = true; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1920 | run.eq = 60; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1921 | run.stamina = 0; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1922 | run.exhausted = true; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1923 | }); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1924 | let tired = send(&app, "JELQ", "/runs/cafebabe?technique=edge", &[], "").await; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1925 | assert_eq!(tired.status(), StatusCode::TOO_MANY_REQUESTS); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1926 | let hold = send(&app, "HOLD", "/runs/cafebabe", &[], "").await; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1927 | assert_eq!(hold.status(), StatusCode::OK); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1928 | assert_eq!(header(&hold, "x-stamina"), "10/10"); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1929 | let cold = send(&app, "JELQ", "/runs/cafebabe?technique=edge", &[], "").await; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1930 | assert_eq!(cold.status(), StatusCode::PRECONDITION_FAILED); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1931 | } |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1932 | |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1933 | #[tokio::test] |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1934 | async fn friction_rises_with_vigour_and_edging_chafes() { |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1935 | let spit = [("content-type", "text/plain; charset=spit")]; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1936 | for (intensity, friction) in [(5, "1/10"), (7, "2/10"), (10, "3/10")] { |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1937 | let app = seeded_with(Floor::Hotel, |run| { |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1938 | run.here.wifi_accepted = true; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1939 | run.warmed_up = true; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1940 | run.eq = 55; |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1941 | run.foreskin = Some(0.5); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1942 | }); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1943 | let uri = format!("/runs/cafebabe?technique=wet&intensity={intensity}"); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1944 | let jelq = send(&app, "JELQ", &uri, &spit, "").await; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1945 | assert_eq!( |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1946 | header(&jelq, "x-friction"), |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1947 | friction, |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1948 | "intensity {intensity}" |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1949 | ); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1950 | } |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1951 | let app = seeded_with(Floor::Hotel, |run| { |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1952 | run.here.wifi_accepted = true; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1953 | run.warmed_up = true; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1954 | run.eq = 55; |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1955 | run.foreskin = Some(0.5); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1956 | }); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1957 | let edge = send(&app, "JELQ", "/runs/cafebabe?technique=edge", &[], "").await; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1958 | assert_eq!(header(&edge, "x-friction"), "2/10"); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1959 | } |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1960 | |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1961 | #[tokio::test] |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1962 | async fn the_body_changes_how_the_skin_takes_it() { |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1963 | let spit = [("content-type", "text/plain; charset=spit")]; |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1964 | for (foreskin, girth, friction) in [(0.5, 4.5, "1/10"), (1.2, 4.5, "0/10"), (0.5, 5.8, "2/10")] |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1965 | { |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1966 | let app = seeded_with(Floor::Hotel, |run| { |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1967 | run.here.wifi_accepted = true; |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1968 | run.warmed_up = true; |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1969 | run.eq = 55; |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1970 | run.foreskin = Some(foreskin); |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1971 | run.girth = girth; |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1972 | }); |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1973 | let jelq = send(&app, "JELQ", "/runs/cafebabe?technique=wet", &spit, "").await; |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1974 | assert_eq!(header(&jelq, "x-friction"), friction, "{foreskin} {girth}"); |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1975 | } |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1976 | } |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1977 | |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1978 | #[tokio::test] |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1979 | async fn a_thick_girth_outgrows_the_underhand_grip() { |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1980 | let app = seeded_with(Floor::Bedroom, |run| run.girth = 5.8); |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1981 | let grip = send( |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1982 | &app, |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1983 | "GET", |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1984 | "/runs/cafebabe/grip", |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1985 | &[("upgrade", "underhand"), ("connection", "upgrade")], |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1986 | "", |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1987 | ) |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1988 | .await; |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1989 | assert_eq!(grip.status(), StatusCode::PAYLOAD_TOO_LARGE); |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1990 | } |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1991 | |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1992 | #[tokio::test] |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1993 | async fn respectable_girth_waves_off_the_gym_staff() { |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1994 | for (girth, status) in [ |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1995 | (4.5, StatusCode::UNAVAILABLE_FOR_LEGAL_REASONS), |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1996 | (5.2, StatusCode::OK), |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1997 | ] { |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1998 | let app = seeded_with(Floor::ChangingRoom, |run| { |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 1999 | run.warmed_up = true; |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2000 | run.eq = 45; |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2001 | run.girth = girth; |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2002 | run.suspicion = SUSPICION_LIMIT; |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2003 | }); |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2004 | let edge = send(&app, "JELQ", "/runs/cafebabe?technique=edge", &[], "").await; |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2005 | if girth > 5.0 { |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2006 | assert_ne!(edge.status(), StatusCode::UNAVAILABLE_FOR_LEGAL_REASONS); |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2007 | assert!(header(&edge, "warning").contains("gym staff")); |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2008 | } else { |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2009 | assert_eq!(edge.status(), status); |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2010 | } |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2011 | } |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2012 | } |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2013 | |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2014 | #[tokio::test] |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2015 | async fn kev_is_the_bar_in_the_changing_room() { |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2016 | for (length, shamed) in [(5.0, true), (7.0, false)] { |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2017 | let app = seeded_with(Floor::Bathroom, |run| { |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2018 | run.length = length; |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2019 | run.here.turns = 6; |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2020 | }); |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2021 | let left = send(&app, "POST", "/runs/cafebabe/floor", &[], "").await; |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2022 | assert_eq!(header(&left, "x-floor"), "3"); |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2023 | let warning = left |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2024 | .headers() |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2025 | .get("warning") |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2026 | .map(|w| w.to_str().unwrap().to_owned()); |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2027 | assert_eq!( |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2028 | warning.is_some_and(|w| w.contains("Kev")), |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2029 | shamed, |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2030 | "length {length}" |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2031 | ); |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2032 | } |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2033 | } |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2034 | |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2035 | #[tokio::test] |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2036 | async fn the_forum_respects_volume() { |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2037 | let state = Arc::new(AppState::default()); |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2038 | for (id, length, girth) in [("slim", 7.0, 4.0), ("stout", 5.0, 5.5)] { |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2039 | let mut run = Run::new(id.into(), id.into(), 1); |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2040 | run.length = length; |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2041 | run.girth = girth; |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2042 | state.insert(run); |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2043 | } |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2044 | let app = router(state); |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2045 | let board = json( |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2046 | send( |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2047 | &app, |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2048 | "GET", |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2049 | "/leaderboard?sort=volume&seeded=include", |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2050 | &[], |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2051 | "", |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2052 | ) |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2053 | .await, |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2054 | ) |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2055 | .await; |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2056 | assert_eq!(board["entries"][0]["public_id"], "stout"); |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2057 | assert!(board["entries"][0]["volume"].as_f64().unwrap() > 0.0); |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 2058 | } |