mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-02-02 05:41:10 -08:00
parent
e6e9d0a66b
commit
69a95bfb38
|
@ -40,7 +40,7 @@ func (a *Aws) Enabled() bool {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
displayDefaultUser := a.props.GetBool(properties.DisplayDefault, true)
|
displayDefaultUser := a.props.GetBool(properties.DisplayDefault, true)
|
||||||
a.Profile = getEnvFirstMatch("AWS_VAULT", "AWS_PROFILE")
|
a.Profile = getEnvFirstMatch("AWS_VAULT", "AWS_DEFAULT_PROFILE", "AWS_PROFILE")
|
||||||
if !displayDefaultUser && a.Profile == defaultUser {
|
if !displayDefaultUser && a.Profile == defaultUser {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ func TestAWSSegment(t *testing.T) {
|
||||||
ExpectedString string
|
ExpectedString string
|
||||||
ExpectedEnabled bool
|
ExpectedEnabled bool
|
||||||
Profile string
|
Profile string
|
||||||
|
DefaultProfile string
|
||||||
Vault string
|
Vault string
|
||||||
Region string
|
Region string
|
||||||
DefaultRegion string
|
DefaultRegion string
|
||||||
|
@ -26,6 +27,7 @@ func TestAWSSegment(t *testing.T) {
|
||||||
{Case: "disabled with default user", ExpectedString: "default@eu-west", Region: "eu-west", ExpectedEnabled: false, DisplayDefault: false},
|
{Case: "disabled with default user", ExpectedString: "default@eu-west", Region: "eu-west", ExpectedEnabled: false, DisplayDefault: false},
|
||||||
{Case: "disabled", ExpectedString: "", ExpectedEnabled: false},
|
{Case: "disabled", ExpectedString: "", ExpectedEnabled: false},
|
||||||
{Case: "enabled with default user", ExpectedString: "default@eu-west", Profile: "default", Region: "eu-west", ExpectedEnabled: true, DisplayDefault: true},
|
{Case: "enabled with default user", ExpectedString: "default@eu-west", Profile: "default", Region: "eu-west", ExpectedEnabled: true, DisplayDefault: true},
|
||||||
|
{Case: "enabled with default profile", ExpectedString: "default@eu-west", DefaultProfile: "default", Region: "eu-west", ExpectedEnabled: true, DisplayDefault: true},
|
||||||
{Case: "disabled with default user", ExpectedString: "default", Profile: "default", Region: "eu-west", ExpectedEnabled: false, DisplayDefault: false},
|
{Case: "disabled with default user", ExpectedString: "default", Profile: "default", Region: "eu-west", ExpectedEnabled: false, DisplayDefault: false},
|
||||||
{Case: "enabled no region", ExpectedString: "company", ExpectedEnabled: true, Profile: "company"},
|
{Case: "enabled no region", ExpectedString: "company", ExpectedEnabled: true, Profile: "company"},
|
||||||
{Case: "enabled with region", ExpectedString: "company@eu-west", ExpectedEnabled: true, Profile: "company", Region: "eu-west", DefaultRegion: "us-west"},
|
{Case: "enabled with region", ExpectedString: "company@eu-west", ExpectedEnabled: true, Profile: "company", Region: "eu-west", DefaultRegion: "us-west"},
|
||||||
|
@ -52,6 +54,7 @@ func TestAWSSegment(t *testing.T) {
|
||||||
env := new(mock.MockedEnvironment)
|
env := new(mock.MockedEnvironment)
|
||||||
env.On("Getenv", "AWS_VAULT").Return(tc.Vault)
|
env.On("Getenv", "AWS_VAULT").Return(tc.Vault)
|
||||||
env.On("Getenv", "AWS_PROFILE").Return(tc.Profile)
|
env.On("Getenv", "AWS_PROFILE").Return(tc.Profile)
|
||||||
|
env.On("Getenv", "AWS_DEFAULT_PROFILE").Return(tc.DefaultProfile)
|
||||||
env.On("Getenv", "AWS_REGION").Return(tc.Region)
|
env.On("Getenv", "AWS_REGION").Return(tc.Region)
|
||||||
env.On("Getenv", "AWS_DEFAULT_REGION").Return(tc.DefaultRegion)
|
env.On("Getenv", "AWS_DEFAULT_REGION").Return(tc.DefaultRegion)
|
||||||
env.On("Getenv", "AWS_CONFIG_FILE").Return(tc.ConfigFile)
|
env.On("Getenv", "AWS_CONFIG_FILE").Return(tc.ConfigFile)
|
||||||
|
|
Loading…
Reference in a new issue