dev: gate dogfood restarts with isolated smoke
This commit is contained in:
@@ -451,6 +451,11 @@ impl ResolvedWorkspaceBackendConfig {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_backend_base_url(mut self, base_url: impl Into<String>) -> Self {
|
||||
self.server.backend_base_url = Some(base_url.into().trim_end_matches('/').to_string());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_listen(mut self, listen: SocketAddr) -> Self {
|
||||
self.listen = listen;
|
||||
self
|
||||
@@ -579,6 +584,24 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn backend_base_url_is_explicit_and_normalized() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let listen = "127.0.0.1:48787".parse().unwrap();
|
||||
let resolved = WorkspaceBackendConfigFile::load_for_workspace(dir.path())
|
||||
.unwrap()
|
||||
.resolve(dir.path(), identity())
|
||||
.unwrap()
|
||||
.with_listen(listen)
|
||||
.with_backend_base_url("http://127.0.0.1:48787/");
|
||||
|
||||
assert_eq!(resolved.listen, listen);
|
||||
assert_eq!(
|
||||
resolved.server.backend_base_url.as_deref(),
|
||||
Some("http://127.0.0.1:48787")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rejects_unknown_fields() {
|
||||
let error = WorkspaceBackendConfigFile::parse_str("[server]\nunknown = true\n", "test")
|
||||
|
||||
@@ -571,11 +571,15 @@ async fn run_serve(options: ServeOptions) -> Result<(), Box<dyn std::error::Erro
|
||||
}
|
||||
|
||||
let listener = TcpListener::bind(resolved.listen).await?;
|
||||
let local_addr = listener.local_addr()?;
|
||||
if resolved.server.backend_base_url.is_none() {
|
||||
resolved = resolved.with_backend_base_url(format!("http://{local_addr}"));
|
||||
}
|
||||
eprintln!(
|
||||
"yoi-server: serving workspace `{}` from server DB `{}` on http://{}",
|
||||
workspace.workspace_id,
|
||||
database_path.display(),
|
||||
listener.local_addr()?
|
||||
local_addr
|
||||
);
|
||||
serve(resolved.server, store, listener).await?;
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user