Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Add a test that would have caught the bug last week (#38222)
Mikayla Maki9046091164b2
diff --git a/crates/auto_update/Cargo.toml b/crates/auto_update/Cargo.tomlindex 1a772710c98..35cef84f036 100644--- a/crates/auto_update/Cargo.toml+++ b/crates/auto_update/Cargo.toml@@ -32,3 +32,6 @@ workspace-hack.workspace = true[target.'cfg(not(target_os = "windows"))'.dependencies]which.workspace = true++[dev-dependencies]+gpui = { workspace = true, "features" = ["test-support"] }diff --git a/crates/auto_update/src/auto_update.rs b/crates/auto_update/src/auto_update.rsindex c1e318ee84f..ac5b03d40d6 100644--- a/crates/auto_update/src/auto_update.rs+++ b/crates/auto_update/src/auto_update.rs@@ -992,8 +992,27 @@ pub fn finalize_auto_update_on_quit() {#[cfg(test)]mod tests {+ use gpui::TestAppContext;+ use settings::default_settings;+use super::*;+ #[gpui::test]+ fn test_auto_update_defaults_to_true(cx: &mut TestAppContext) {+ cx.update(|cx| {+ let mut store = SettingsStore::new(cx);+ store+ .set_default_settings(&default_settings(), cx)+ .expect("Unable to set default settings");+ store+ .set_user_settings("{}", cx)+ .expect("Unable to set user settings");+ cx.set_global(store);+ AutoUpdateSetting::register(cx);+ assert!(AutoUpdateSetting::get_global(cx).0);+ });+ }+#[test]fn test_stable_does_not_update_when_fetched_version_is_not_higher() {let release_channel = ReleaseChannel::Stable;diff --git a/crates/project/src/direnv.rs b/crates/project/src/direnv.rsindex 9ba0ad10e31..32f4963fd19 100644--- a/crates/project/src/direnv.rs+++ b/crates/project/src/direnv.rs@@ -65,7 +65,7 @@ pub async fn load_direnv_environment(let output = String::from_utf8_lossy(&direnv_output.stdout);if output.is_empty() {// direnv outputs nothing when it has no changes to apply to environment variables- return Ok(HashMap::new());+ return Ok(HashMap::default());}match serde_json::from_str(&output) {