mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-03-05 20:49:04 -08:00
parent
44ac09d356
commit
fb57ef18b6
|
@ -19,6 +19,11 @@ const (
|
|||
DisplaySubscriptionID Property = "display_id"
|
||||
// DisplaySubscriptionName hides or shows the subscription display name
|
||||
DisplaySubscriptionName Property = "display_name"
|
||||
|
||||
updateConsentNeeded = "Do you want to continue?"
|
||||
updateMessage = "AZ CLI: Update needed!"
|
||||
updateForeground = "#ffffff"
|
||||
updateBackground = "#ff5349"
|
||||
)
|
||||
|
||||
func (a *az) string() string {
|
||||
|
@ -68,6 +73,12 @@ func (a *az) getFromAzCli() (string, string, bool) {
|
|||
return "", "", false
|
||||
}
|
||||
|
||||
if strings.Contains(output, updateConsentNeeded) {
|
||||
a.props.foreground = updateForeground
|
||||
a.props.background = updateBackground
|
||||
return updateMessage, "", true
|
||||
}
|
||||
|
||||
splittedOutput := strings.Split(output, "\n")
|
||||
if len(splittedOutput) < 2 {
|
||||
return "", "", false
|
||||
|
|
|
@ -21,7 +21,8 @@ func TestAzSegment(t *testing.T) {
|
|||
DisplayID bool
|
||||
DisplayName bool
|
||||
}{
|
||||
{Case: "envvars present",
|
||||
{
|
||||
Case: "envvars present",
|
||||
ExpectedEnabled: true,
|
||||
ExpectedString: "foo$bar",
|
||||
EnvSubName: "foo",
|
||||
|
@ -29,78 +30,89 @@ func TestAzSegment(t *testing.T) {
|
|||
CliExists: false,
|
||||
InfoSeparator: "$",
|
||||
DisplayID: true,
|
||||
DisplayName: true},
|
||||
{Case: "envvar name present",
|
||||
DisplayName: true,
|
||||
},
|
||||
{
|
||||
Case: "envvar name present",
|
||||
ExpectedEnabled: true,
|
||||
ExpectedString: "foo$",
|
||||
EnvSubName: "foo",
|
||||
EnvSubID: "",
|
||||
CliExists: false,
|
||||
InfoSeparator: "$",
|
||||
DisplayID: true,
|
||||
DisplayName: true},
|
||||
{Case: "envvar id present",
|
||||
DisplayName: true,
|
||||
},
|
||||
{
|
||||
Case: "envvar id present",
|
||||
ExpectedEnabled: true,
|
||||
ExpectedString: "$bar",
|
||||
EnvSubName: "",
|
||||
EnvSubID: "bar",
|
||||
CliExists: false,
|
||||
InfoSeparator: "$",
|
||||
DisplayID: true,
|
||||
DisplayName: true},
|
||||
{Case: "cli not found",
|
||||
DisplayName: true,
|
||||
},
|
||||
{
|
||||
Case: "cli not found",
|
||||
ExpectedEnabled: false,
|
||||
ExpectedString: "$",
|
||||
EnvSubName: "",
|
||||
EnvSubID: "",
|
||||
CliExists: false,
|
||||
InfoSeparator: "$",
|
||||
DisplayID: true,
|
||||
DisplayName: true},
|
||||
{Case: "cli contains data",
|
||||
DisplayName: true,
|
||||
},
|
||||
{
|
||||
Case: "cli contains data",
|
||||
ExpectedEnabled: true,
|
||||
ExpectedString: "foo$bar",
|
||||
EnvSubName: "",
|
||||
EnvSubID: "",
|
||||
CliExists: true,
|
||||
CliSubName: "foo",
|
||||
CliSubID: "bar",
|
||||
InfoSeparator: "$",
|
||||
DisplayID: true,
|
||||
DisplayName: true},
|
||||
{Case: "print only name",
|
||||
DisplayName: true,
|
||||
},
|
||||
{
|
||||
Case: "print only name",
|
||||
ExpectedEnabled: true,
|
||||
ExpectedString: "foo",
|
||||
EnvSubName: "",
|
||||
EnvSubID: "",
|
||||
CliExists: true,
|
||||
CliSubName: "foo",
|
||||
CliSubID: "bar",
|
||||
InfoSeparator: "$",
|
||||
DisplayID: false,
|
||||
DisplayName: true},
|
||||
{Case: "print only id",
|
||||
DisplayName: true,
|
||||
},
|
||||
{
|
||||
Case: "print only id",
|
||||
ExpectedEnabled: true,
|
||||
ExpectedString: "bar",
|
||||
EnvSubName: "",
|
||||
EnvSubID: "",
|
||||
CliExists: true,
|
||||
CliSubName: "foo",
|
||||
CliSubID: "bar",
|
||||
InfoSeparator: "$",
|
||||
DisplayID: true,
|
||||
DisplayName: false},
|
||||
{Case: "print none",
|
||||
DisplayName: false,
|
||||
},
|
||||
{
|
||||
Case: "print none",
|
||||
ExpectedEnabled: false,
|
||||
ExpectedString: "",
|
||||
EnvSubName: "",
|
||||
EnvSubID: "",
|
||||
CliExists: true,
|
||||
CliSubName: "foo",
|
||||
CliSubID: "bar",
|
||||
InfoSeparator: "$",
|
||||
DisplayID: false,
|
||||
DisplayName: false},
|
||||
DisplayName: false,
|
||||
},
|
||||
{
|
||||
Case: "update needed",
|
||||
ExpectedEnabled: true,
|
||||
ExpectedString: updateMessage,
|
||||
CliExists: true,
|
||||
CliSubName: "Do you want to continue? (Y/n): Visual Studio Enterprise",
|
||||
DisplayID: false,
|
||||
DisplayName: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
|
|
Loading…
Reference in a new issue