Skip to content

Commit

Permalink
fix(compute/deploy): tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Integralist committed Apr 18, 2024
1 parent 30443b4 commit 7c7dcae
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion pkg/commands/compute/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,47 @@ func TestDeploy(t *testing.T) {
},
stdin: []string{
"Y", // when prompted to create a new service
"", // when prompted for a service name use the default
"Y", // when prompted to approve the trial account setup
"", // this is so we generate a backend name using a built-in formula
"", // this stops prompting for backends
},
wantOutput: []string{
"INFO: You are creating a Compute trial service",
"INFO: By creating this Compute service,",
"you acknowledge that the service is a trial service",
"Deployed package (service 12345, version 1)",
},
},
{
// This test is the same as above but instead we don't configure a Y
// response to the prompt asking if they want to start the trial account.
// So this leads to an error.
name: "error when declining trial account setup",
args: args("compute deploy --token 123 -v --package pkg/package.tar.gz"),
api: mock.API{
ActivateVersionFn: activateVersionOk,
CreateBackendFn: createBackendOK,
CreateDomainFn: createDomainOK,
CreateServiceFn: createServiceOK,
GetPackageFn: getPackageOk,
ListDomainsFn: listDomainsOk,
UpdatePackageFn: updatePackageOk,
},
httpClientRes: []*http.Response{
{
Body: io.NopCloser(strings.NewReader(`{"has_access":false}`)),
Status: http.StatusText(http.StatusOK),
StatusCode: http.StatusOK,
},
},
httpClientErr: []error{
nil,
},
stdin: []string{
"Y", // when prompted to create a new service
},
wantError: "deploy stopped by user",
},
{
// This test validates what happens when the entitlement check fails.
name: "error checking compute entitlement",
Expand Down

0 comments on commit 7c7dcae

Please sign in to comment.