From 4d36d463b91a245a62c357de308cad3cdec48edf Mon Sep 17 00:00:00 2001 From: Iuliia Gracheva Date: Sat, 29 Jun 2024 23:00:07 +0200 Subject: [PATCH] feat(gcloud): Disabled gcloud module when active config hasn't been set (#6039) * disabled gcloud module when active config hasn't been set * added test case * updated config-schema --- src/modules/gcloud.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/modules/gcloud.rs b/src/modules/gcloud.rs index 692504c3..9a904254 100644 --- a/src/modules/gcloud.rs +++ b/src/modules/gcloud.rs @@ -89,6 +89,10 @@ pub fn module<'a>(context: &'a Context) -> Option> { } let (config_name, config_path) = get_current_config(context)?; + + if config_name == "NONE" { + return None; + } let gcloud_context = GcloudContext::new(&config_name, &config_path); let account: Lazy>, _> = Lazy::new(|| gcloud_context.get_account()); @@ -462,6 +466,16 @@ project = very-long-project-name dir.close() } + #[test] + fn no_active_config() { + let actual = ModuleRenderer::new("gcloud") + .env("CLOUDSDK_ACTIVE_CONFIG_NAME", "NONE") + .collect(); + let expected = None; + + assert_eq!(expected, actual); + } + #[test] fn active_config_manually_overridden() -> io::Result<()> { let dir = tempfile::tempdir()?;