From 831d4f620dfecb1c262b45edc4b90a40916df23d Mon Sep 17 00:00:00 2001 From: Mark McDonnell Date: Thu, 2 Sep 2021 12:47:40 +0100 Subject: [PATCH] fix test from timing out by resetting package variable --- pkg/commands/compute/deploy_test.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/pkg/commands/compute/deploy_test.go b/pkg/commands/compute/deploy_test.go index 5cbe01b9c..59ca6d14b 100644 --- a/pkg/commands/compute/deploy_test.go +++ b/pkg/commands/compute/deploy_test.go @@ -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 @@ -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"), @@ -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. @@ -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 {