diff options
| author | aur-build <aur-build@localhost> | 2026-11-19 17:33:17 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-19 17:33:17 +0000 |
| commit | 4304b0f336ddba7b4ec6780795059ff2066d105b (patch) | |
| tree | 10edea744a1c2bf3fc363b4dc7f64abac8b1a0d3 /tests/live.rs | |
| parent | e757979f1a2afdbe7146066345bb9acd19d3b151 (diff) | |
| download | aur-build-4304b0f336ddba7b4ec6780795059ff2066d105b.tar.gz aur-build-4304b0f336ddba7b4ec6780795059ff2066d105b.zip | |
comments: keep only what the code cannot show
Stripped every comment that described what an item does, documented its
arguments or fields, or cited the design docs (§n, I-n, m-n, decision n).
2247 comments down to 83.
What survives: the section dividers that segment the large modules, the
secret-handling warnings, the agent wire-frame directions, and the few notes
without which the code they attach to reads as redundant, reorderable, or
unsound.
Diffstat (limited to 'tests/live.rs')
| -rw-r--r-- | tests/live.rs | 22 |
1 files changed, 0 insertions, 22 deletions
diff --git a/tests/live.rs b/tests/live.rs index da0f7ec..e572638 100644 --- a/tests/live.rs +++ b/tests/live.rs @@ -9,7 +9,6 @@ use aur_build::pipeline; use aur_build::review::{candidates, diff}; use common::*; -/// Approve a fixture's candidate and enqueue its build without running it. fn queued(env: &Env, name: &str) -> String { aur_build::watch::detect::check_pkgbase(&env.cfg, &env.db, name).unwrap(); let c = candidates::pending_candidates(&env.db).unwrap().remove(0); @@ -20,7 +19,6 @@ fn queued(env: &Env, name: &str) -> String { pipeline::enqueue_for_candidate(&env.cfg, &env.db, &c).unwrap() } -/// Read a streaming response until EOF or the deadline, whichever comes first. fn drain(mut r: impl Read, deadline: Duration) -> String { let mut buf = [0u8; 4096]; let mut out = Vec::new(); @@ -47,8 +45,6 @@ fn the_log_stream_delivers_bytes_as_they_are_appended_and_then_ends() { std::fs::create_dir_all(log.parent().unwrap()).unwrap(); std::fs::write(&log, "==> step materialize\n").unwrap(); - // A producer appends while the stream is open, then finishes the build. If the - // endpoint buffered its response the "live" claim would be false. let db = web.env.db.clone(); let id2 = id.clone(); let log2 = log.clone(); @@ -58,8 +54,6 @@ fn the_log_stream_delivers_bytes_as_they_are_appended_and_then_ends() { std::thread::sleep(Duration::from_millis(400)); append(&log2, "==> step publish\n"); std::thread::sleep(Duration::from_millis(200)); - // Walk the machine the way a real build does: a queued build runs - // before it succeeds. builds::set_state(&db, &id2, BuildState::Running, None).unwrap(); builds::set_state(&db, &id2, BuildState::Succeeded, None).unwrap(); }); @@ -73,9 +67,7 @@ fn the_log_stream_delivers_bytes_as_they_are_appended_and_then_ends() { assert!(body.contains("data: ==> step materialize"), "the first line is missing: {body}"); assert!(body.contains("data: ==> step build"), "appended bytes never arrived: {body}"); assert!(body.contains("data: ==> step publish"), "the tail stopped early: {body}"); - // It ends when the build does, rather than holding the connection forever. assert!(body.contains("event: end"), "the stream never ended: {body}"); - // SSE framing: each log line is its own event, so a client can append. assert!(body.contains("\n\n"), "not event-framed: {body}"); } @@ -96,17 +88,13 @@ fn the_builds_table_refreshes_via_htmx_and_still_works_without_js() { let web = Web::attach(env, fx); let base = web.url("/builds"); - // One queued build so the table has a row. queued(&web.env, "plain-make"); let page = ureq::get(&base).call().unwrap().into_string().unwrap(); - // The refresh is an attribute on the table, not a script we wrote. assert!(page.contains("hx-trigger=\"every 3s\""), "no htmx refresh: {}", &page[..400.min(page.len())]); assert!(page.contains("hx-get=\"/builds?fragment=1\""), "the refresh has no target"); assert!(page.contains("<script src=\"/static/htmx.min.js\""), "htmx is not loaded"); - // And with JavaScript off the same HTML already contains the table. assert!(page.contains("<table>"), "no server-rendered table"); - // The fragment endpoint returns the table on its own, so htmx can swap it in. let frag = ureq::get(&format!("{base}?fragment=1")).call().unwrap().into_string().unwrap(); assert!(frag.starts_with("<div id=\"builds\""), "fragment is not the table: {}", &frag[..120.min(frag.len())]); assert!(!frag.contains("<!doctype"), "the fragment is a whole page"); @@ -117,9 +105,6 @@ fn the_builds_table_refreshes_via_htmx_and_still_works_without_js() { fn htmx_is_the_only_javascript_and_what_is_shipped_fits_the_budget() { let (env, fx) = env_with_fixture("plain-make"); let web = Web::attach(env, fx); - // Served bytes are what a browser actually downloads, and that is the budget - // with any meaning. An HTTP client would transparently decompress, which is - // exactly what this budget is about, so read the wire directly. let (headers, served) = raw_get(&web, "/static/htmx.min.js", true); assert!(headers.to_lowercase().contains("content-encoding: gzip"), "the vendored js is not compressed: {headers}"); assert!( @@ -127,17 +112,14 @@ fn htmx_is_the_only_javascript_and_what_is_shipped_fits_the_budget() { "vendored JavaScript is {} bytes on the wire, over the 20 KB budget", served.len() ); - // The compressed copy really is htmx, not a stub pretending to be it. let raw = gunzip(&served); assert!(raw.starts_with(b"(function"), "the decompressed file is not htmx"); assert!(raw.len() > 40_000, "decompressed htmx looks truncated: {}", raw.len()); - // A client that cannot take gzip still gets working JavaScript, just larger. let (plain_headers, plain_bytes) = raw_get(&web, "/static/htmx.min.js", false); assert!(!plain_headers.to_lowercase().contains("content-encoding"), "served gzip to a client that did not ask"); assert_eq!(plain_bytes, raw, "the two copies disagree"); - // Nothing else is JavaScript: there is no place to hide a bundle. let other = ureq::get(&web.url("/static/anything-else.js")).call(); assert!(matches!(other, Err(ureq::Error::Status(404, _))), "we serve arbitrary js"); } @@ -150,13 +132,9 @@ fn the_stylesheet_is_served_and_the_review_surface_needs_no_javascript() { assert!(css.contains("body"), "app.css is a placeholder"); let page = web.get("/reviews").body; assert!(page.contains("<link rel=\"stylesheet\" href=\"/static/app.css\">"), "the page does not load it"); - // The review flow is the one that must work with scripting disabled, so it does - // not load htmx at all. assert!(!page.contains("<script"), "the review surface ships JavaScript"); } -/// Ask for a path over a bare socket so the response is seen before any client-side -/// content negotiation undoes it. fn raw_get(web: &Web, path: &str, gzip: bool) -> (String, Vec<u8>) { use std::io::{BufRead, BufReader, Write}; let addr = web.server.addr.clone(); |
