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:
parent
346d8acf3e
commit
4d36d463b9
@ -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()?;
|
||||
|
Loading…
Reference in New Issue
Block a user