Skip to content

Commit

Permalink
fix test from timing out by resetting package variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Integralist committed Sep 2, 2021
1 parent c125fb5 commit 831d4f6
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions pkg/commands/compute/deploy_test.go
Expand Up @@ -74,6 +74,7 @@ func TestDeploy(t *testing.T) {
}
defer os.Chdir(pwd)

originalPackageSizeLimit := compute.PackageSizeLimit
args := testutil.Args
for _, testcase := range []struct {
api mock.API
Expand All @@ -93,13 +94,6 @@ func TestDeploy(t *testing.T) {
args: args("compute deploy"),
wantError: "no token provided",
},
{
name: "package size too large",
args: args("compute deploy -p pkg/package.tar.gz --token 123"),
reduceSizeLimit: true,
wantError: "package size is too large",
wantRemediationError: errors.PackageSizeRemediation,
},
{
name: "no fastly.toml manifest",
args: args("compute deploy --token 123"),
Expand Down Expand Up @@ -193,6 +187,13 @@ func TestDeploy(t *testing.T) {
},
wantError: fmt.Sprintf("error fetching service backends: %s", testutil.Err.Error()),
},
{
name: "package size too large",
args: args("compute deploy -p pkg/package.tar.gz --token 123"),
reduceSizeLimit: true,
wantError: "package size is too large",
wantRemediationError: errors.PackageSizeRemediation,
},
// The following test doesn't just validate the package API error behaviour
// but as a side effect it validates that when deleting the created
// service, the Service ID is also cleared out from the manifest.
Expand Down Expand Up @@ -913,6 +914,10 @@ func TestDeploy(t *testing.T) {

if testcase.reduceSizeLimit {
compute.PackageSizeLimit = 1000000 // 1mb (our test package should above this)
} else {
// As multiple test scenarios run within a single environment instance
// we need to ensure each scenario resets the package variable.
compute.PackageSizeLimit = originalPackageSizeLimit
}

if len(testcase.stdin) > 1 {
Expand Down

0 comments on commit 831d4f6

Please sign in to comment.