1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2024-12-11 21:57:52 +00:00

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
This commit is contained in:
Iuliia Gracheva 2024-06-29 23:00:07 +02:00 committed by GitHub
parent 346d8acf3e
commit 4d36d463b9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -89,6 +89,10 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
}
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<Option<Account<'_>>, _> = 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()?;