mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-09-14 23:22:51 +00:00
Merge remote-tracking branch 'origin/main' into fabro/run/01KY7Y01REECZ24XXTMBZ3PPV9
This commit is contained in:
commit
000085cb52
2 changed files with 78 additions and 14 deletions
|
|
@ -338,10 +338,16 @@ fn keep_existing_settings_persists_secrets_without_rewriting_server_target() {
|
|||
let mut context = test_context!();
|
||||
let storage_dir = context.temp_dir.join("install-storage");
|
||||
context.manage_storage_dir(&storage_dir);
|
||||
let existing_web_url = unused_loopback_web_url();
|
||||
let requested_web_url = unused_loopback_web_url();
|
||||
write_http_install_settings(&context, &storage_dir, &existing_web_url, "keep-me");
|
||||
login_with_storage_dev_token(&context, &storage_dir, &existing_web_url);
|
||||
let socket_path = context.temp_dir.join("install-storage.sock");
|
||||
let existing_web_url = "https://existing.example.test".to_string();
|
||||
let requested_web_url = "https://requested.example.test".to_string();
|
||||
write_unix_install_settings(
|
||||
&context,
|
||||
&storage_dir,
|
||||
&socket_path,
|
||||
&existing_web_url,
|
||||
"keep-me",
|
||||
);
|
||||
|
||||
let path = fake_gh_path(&context, "ghp_keep_existing");
|
||||
let output = context
|
||||
|
|
@ -382,15 +388,19 @@ fn keep_existing_settings_persists_secrets_without_rewriting_server_target() {
|
|||
.and_then(toml::Value::as_str),
|
||||
Some(existing_web_url.as_str())
|
||||
);
|
||||
let target = parsed
|
||||
.get("cli")
|
||||
.and_then(toml::Value::as_table)
|
||||
.and_then(|cli| cli.get("target"))
|
||||
.and_then(toml::Value::as_table)
|
||||
.expect("cli.target should remain configured");
|
||||
assert_eq!(
|
||||
parsed
|
||||
.get("cli")
|
||||
.and_then(toml::Value::as_table)
|
||||
.and_then(|cli| cli.get("target"))
|
||||
.and_then(toml::Value::as_table)
|
||||
.and_then(|target| target.get("url"))
|
||||
.and_then(toml::Value::as_str),
|
||||
Some(existing_web_url.as_str())
|
||||
target.get("type").and_then(toml::Value::as_str),
|
||||
Some("unix")
|
||||
);
|
||||
assert_eq!(
|
||||
target.get("path").and_then(toml::Value::as_str),
|
||||
socket_path.to_str()
|
||||
);
|
||||
assert!(
|
||||
!settings.contains(&requested_web_url),
|
||||
|
|
@ -874,6 +884,53 @@ mode = "{}"
|
|||
);
|
||||
}
|
||||
|
||||
fn write_unix_install_settings(
|
||||
context: &fabro_test::TestContext,
|
||||
storage_dir: &std::path::Path,
|
||||
socket_path: &std::path::Path,
|
||||
web_url: &str,
|
||||
metadata_mode: &str,
|
||||
) {
|
||||
write_raw_home_settings(
|
||||
context,
|
||||
&format!(
|
||||
r#"
|
||||
_version = 1
|
||||
|
||||
[server.storage]
|
||||
root = "{}"
|
||||
|
||||
[server.api]
|
||||
url = "{}/api/v1"
|
||||
|
||||
[server.web]
|
||||
enabled = true
|
||||
url = "{}"
|
||||
|
||||
[server.auth]
|
||||
methods = ["dev-token"]
|
||||
|
||||
[server.listen]
|
||||
type = "unix"
|
||||
path = "{}"
|
||||
|
||||
[cli.target]
|
||||
type = "unix"
|
||||
path = "{}"
|
||||
|
||||
[project.metadata]
|
||||
mode = "{}"
|
||||
"#,
|
||||
storage_dir.display(),
|
||||
web_url,
|
||||
web_url,
|
||||
socket_path.display(),
|
||||
socket_path.display(),
|
||||
metadata_mode
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
fn login_with_storage_dev_token(
|
||||
context: &fabro_test::TestContext,
|
||||
storage_dir: &std::path::Path,
|
||||
|
|
|
|||
|
|
@ -497,8 +497,15 @@ fn with_session_lock<T>(root: &Path, f: impl FnOnce() -> T) -> T {
|
|||
// cleanup_session_root can remove_dir_all between the two calls.
|
||||
let deadline = std::time::Instant::now() + SESSION_LOCK_TIMEOUT;
|
||||
let lock_file = loop {
|
||||
std::fs::create_dir_all(root)
|
||||
.unwrap_or_else(|err| panic!("failed to create {}: {err}", root.display()));
|
||||
if let Err(err) = std::fs::create_dir_all(root) {
|
||||
assert!(
|
||||
std::time::Instant::now() < deadline,
|
||||
"failed to create {} after retries: {err}",
|
||||
root.display()
|
||||
);
|
||||
std::thread::sleep(Duration::from_millis(10));
|
||||
continue;
|
||||
}
|
||||
ensure_parent_dir(&lock_path);
|
||||
match File::create(&lock_path) {
|
||||
Ok(f) => break f,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue