-
Notifications
You must be signed in to change notification settings - Fork 397
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update godo, regenerate mocks, add list app alerts and update app ale…
…rt destinations, and tests (#1016)
- Loading branch information
Showing
43 changed files
with
612 additions
and
222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,8 @@ func TestAppsCommand(t *testing.T) { | |
"propose", | ||
"spec", | ||
"tier", | ||
"list-alerts", | ||
"update-alert-destinations", | ||
) | ||
} | ||
|
||
|
@@ -71,6 +73,46 @@ var ( | |
TierUpgradeTo: "professional-xs", | ||
TierDowngradeTo: "basic-xxxs", | ||
} | ||
|
||
testAlerts = []*godo.AppAlert{ | ||
{ | ||
ID: "c586fc0d-e8e2-4c50-9bf6-6c0a6b2ed2a7", | ||
Spec: &godo.AppAlertSpec{ | ||
Rule: godo.AppAlertSpecRule_DeploymentFailed, | ||
}, | ||
Emails: []string{"[email protected]", "[email protected]"}, | ||
SlackWebhooks: []*godo.AppAlertSlackWebhook{ | ||
{ | ||
URL: "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX", | ||
Channel: "channel name", | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
testAlert = godo.AppAlert{ | ||
ID: "c586fc0d-e8e2-4c50-9bf6-6c0a6b2ed2a7", | ||
Spec: &godo.AppAlertSpec{ | ||
Rule: godo.AppAlertSpecRule_DeploymentFailed, | ||
}, | ||
Emails: []string{"[email protected]", "[email protected]"}, | ||
SlackWebhooks: []*godo.AppAlertSlackWebhook{ | ||
{ | ||
URL: "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX", | ||
Channel: "channel name", | ||
}, | ||
}, | ||
} | ||
|
||
testAlertUpdate = godo.AlertDestinationUpdateRequest{ | ||
Emails: []string{"[email protected]", "[email protected]"}, | ||
SlackWebhooks: []*godo.AppAlertSlackWebhook{ | ||
{ | ||
URL: "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX", | ||
Channel: "channel name", | ||
}, | ||
}, | ||
} | ||
) | ||
|
||
func TestRunAppsCreate(t *testing.T) { | ||
|
@@ -762,3 +804,35 @@ func TestRunAppsTierInstanceSizeGet(t *testing.T) { | |
require.NoError(t, err) | ||
}) | ||
} | ||
|
||
func TestRunAppsListAlerts(t *testing.T) { | ||
withTestClient(t, func(config *CmdConfig, tm *tcMocks) { | ||
appID := uuid.New().String() | ||
tm.apps.EXPECT().ListAlerts(appID).Times(1).Return(testAlerts, nil) | ||
|
||
config.Args = append(config.Args, appID) | ||
err := RunAppListAlerts(config) | ||
require.NoError(t, err) | ||
}) | ||
} | ||
|
||
func TestRunAppsUpdateAlertDestinations(t *testing.T) { | ||
withTestClient(t, func(config *CmdConfig, tm *tcMocks) { | ||
destinationsFile, err := ioutil.TempFile("", "dest") | ||
require.NoError(t, err) | ||
defer func() { | ||
os.Remove(destinationsFile.Name()) | ||
destinationsFile.Close() | ||
}() | ||
|
||
err = json.NewEncoder(destinationsFile).Encode(&testAlertUpdate) | ||
require.NoError(t, err) | ||
appID := uuid.New().String() | ||
tm.apps.EXPECT().UpdateAlertDestinations(appID, testAlert.ID, &testAlertUpdate).Times(1).Return(&testAlert, nil) | ||
|
||
config.Args = append(config.Args, appID, testAlert.ID) | ||
config.Doit.Set(config.NS, doctl.ArgAppAlertDestinations, destinationsFile.Name()) | ||
err = RunAppUpdateAlertDestinations(config) | ||
require.NoError(t, err) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.