Skip to content

Commit 9bfbc18

Browse files
committed
Update native test fixtures for retained installation and database checks
1 parent d0d983a commit 9bfbc18

4 files changed

Lines changed: 43 additions & 12 deletions

File tree

‎desktop/src-tauri/src/main.rs‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,10 @@ fn require_existing_encryption_key(
939939

940940
/// Write the `.env`, raise the containers, migrate, then start the three host processes.
941941
#[tauri::command]
942+
#[allow(
943+
clippy::too_many_arguments,
944+
reason = "These named fields preserve the existing Tauri IPC contract."
945+
)]
942946
async fn start_stack<R: tauri::Runtime>(
943947
app: tauri::AppHandle<R>,
944948
root: String,
@@ -966,6 +970,10 @@ async fn start_stack<R: tauri::Runtime>(
966970
.await
967971
}
968972

973+
#[allow(
974+
clippy::too_many_arguments,
975+
reason = "Mirror the command fields while testing startup with a resolved root."
976+
)]
969977
async fn start_stack_inner<R: tauri::Runtime>(
970978
app: tauri::AppHandle<R>,
971979
root: PathBuf,
@@ -5431,6 +5439,8 @@ fn main() {
54315439
["info","--format","{{.Host.ServiceIsRemote}}"] => println!("false"),
54325440
["compose","version"] => println!("Synthetic Compose"),
54335441
["compose","config","--environment"] => (),
5442+
["compose","config","--format","json"] => println!("{{\"services\":{{\"postgres\":{{\"volumes\":[{{\"type\":\"volume\",\"source\":\"postgres-data\",\"target\":\"/var/lib/postgresql/data\"}}]}}}},\"volumes\":{{\"postgres-data\":{{\"name\":\"fixture_postgres-data\"}}}}}}"),
5443+
["volume","ls","--format","{{.Name}}"] => (),
54345444
["compose","ps","--format",_] => (),
54355445
["compose","up",..] => {
54365446
fs::write(cwd.join("fixture-containers-running"),&identity).unwrap();

‎desktop/src-tauri/src/organization_auth.rs‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ pub fn session_destination(
403403
#[cfg(test)]
404404
mod tests {
405405
use super::*;
406+
use std::io::{BufRead, BufReader};
406407
#[test]
407408
fn cancellation_retires_a_finish_already_waiting_for_the_browser() {
408409
let root = PathBuf::from("organization-cancellation-fixture");
@@ -433,8 +434,17 @@ mod tests {
433434
let address = listener.local_addr().unwrap();
434435
let worker = std::thread::spawn(move || {
435436
let (mut stream, _) = listener.accept().unwrap();
436-
let mut request = [0; 4096];
437-
stream.read(&mut request).unwrap();
437+
let mut reader = BufReader::new(stream.try_clone().unwrap());
438+
let mut line = String::new();
439+
assert!(reader.read_line(&mut line).unwrap() > 0);
440+
assert_eq!(line, "GET /api/me HTTP/1.1\r\n");
441+
loop {
442+
line.clear();
443+
assert!(reader.read_line(&mut line).unwrap() > 0);
444+
if line == "\r\n" {
445+
break;
446+
}
447+
}
438448
write!(
439449
stream,
440450
"HTTP/1.1 {status}\r\nContent-Length: 0\r\nConnection: close\r\n\r\n"

‎desktop/src-tauri/src/stop_ipc_tests.rs‎

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -364,21 +364,20 @@ mod stop_ipc {
364364
let shell = fixture.app.state::<Shell>();
365365
assert!(last_failure(fixture.app.handle().clone()).is_none());
366366
assert!(!recovery_required(&shell, &fixture.root));
367-
assert!(
368-
configured().launch.is_none(),
369-
"Stop must survive setup reloading"
370-
);
367+
let stopped = configured();
368+
assert!(stopped.launch.is_some(), "Stop retains the installed setup");
369+
assert!(!stopped.auto_start, "Stop must survive setup reloading");
371370
let reopened = tauri::test::mock_builder()
372371
.manage(Shell::default())
373372
.build(tauri::test::mock_context(tauri::test::noop_assets()))
374373
.unwrap();
374+
let resumed = already_configured(
375+
reopened.handle().clone(),
376+
fixture.root.to_string_lossy().into_owned(),
377+
);
378+
assert!(resumed.launch.is_some());
375379
assert!(
376-
already_configured(
377-
reopened.handle().clone(),
378-
fixture.root.to_string_lossy().into_owned(),
379-
)
380-
.launch
381-
.is_some(),
380+
resumed.auto_start,
382381
"a fresh app session may resume the saved installation"
383382
);
384383
}

‎desktop/src-tauri/tests/fixtures/engine.rs‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,18 @@ fn main() {
4848
println!("Docker Compose version disposable-provider");
4949
return;
5050
}
51+
// Fresh startup checks the selected Compose database volume before generating a key.
52+
// These scenarios model an empty database; cleanup's explicit -f config stays separate.
53+
if joined == "compose config --format json" {
54+
println!(
55+
"{}",
56+
r#"{"services":{"postgres":{"volumes":[{"type":"volume","source":"postgres-data","target":"/var/lib/postgresql/data"}]}},"volumes":{"postgres-data":{"name":"fixture_postgres-data"}}}"#
57+
);
58+
return;
59+
}
60+
if joined == "volume ls --format {{.Name}}" {
61+
return;
62+
}
5163
if SCENARIO == "podman" {
5264
match joined.as_str() {
5365
"version --format {{.Server.APIVersion}}" => println!("1.44"),

0 commit comments

Comments
 (0)