Skip to content

Commit

Permalink
test(compute/deploy): add test to validate not deleting existing service
Browse files Browse the repository at this point in the history
  • Loading branch information
Integralist committed Jan 27, 2023
1 parent ee69ab9 commit 1ca874a
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion pkg/commands/compute/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ func TestDeploy(t *testing.T) {
},
},
// The following test validates that the undoStack is executed as expected
// e.g. the service is deleted.
// e.g. the service is deleted when there is an error during the flow.
// This only happens for new service flows.
{
name: "undo stack is executed",
Expand All @@ -401,6 +401,32 @@ func TestDeploy(t *testing.T) {
"Cleanup complete",
},
},
// The following test is the opposite to the above test.
// It validates that we don't delete an existing service on-error.
{
name: "undo stack is not executed for errors with existing services",
args: args("compute deploy --service-id 123 --token 123"),
api: mock.API{
ActivateVersionFn: activateVersionError,
CloneVersionFn: testutil.CloneVersionResult(4),
GetPackageFn: getPackageOk,
GetServiceFn: getServiceOK,
GetServiceDetailsFn: getServiceDetailsWasm,
ListDomainsFn: listDomainsOk,
ListVersionsFn: testutil.ListVersions,
UpdatePackageFn: updatePackageOk,
},
dontWantOutput: []string{
"Cleaning up service",
"Removing Service ID from fastly.toml",
"Cleanup complete",
},
wantError: "error activating version: test error",
wantOutput: []string{
"Uploading package...",
"Activating version...",
},
},
// The following test validates that if a package contains code that has
// not changed since the last deploy, then the deployment is skipped.
{
Expand Down Expand Up @@ -1621,6 +1647,10 @@ func getPackageIdentical(i *fastly.GetPackageInput) (*fastly.Package, error) {
}, nil
}

func activateVersionError(i *fastly.ActivateVersionInput) (*fastly.Version, error) {
return nil, testutil.Err
}

func listDomainsError(i *fastly.ListDomainsInput) ([]*fastly.Domain, error) {
return nil, testutil.Err
}
Expand Down

0 comments on commit 1ca874a

Please sign in to comment.