From 3a0dabcaeab738207b0a9881d77732cf1e74e1fa Mon Sep 17 00:00:00 2001 From: Janet Kuo Date: Fri, 22 Sep 2017 01:06:59 -0700 Subject: [PATCH] Refactor function --- .../integration/deployment/deployment_test.go | 6 +++--- test/integration/deployment/util.go | 20 ++++++++----------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/test/integration/deployment/deployment_test.go b/test/integration/deployment/deployment_test.go index 30330d6708..025ab734de 100644 --- a/test/integration/deployment/deployment_test.go +++ b/test/integration/deployment/deployment_test.go @@ -173,7 +173,7 @@ func TestPausedDeployment(t *testing.T) { } // Resume the deployment - tester.deployment, err = tester.updateDeployment(resumeFn()) + tester.deployment, err = tester.updateDeployment(resumeFn) if err != nil { t.Fatalf("failed to resume deployment %s: %v", tester.deployment.Name, err) } @@ -200,7 +200,7 @@ func TestPausedDeployment(t *testing.T) { // Pause the deployment. // The paused deployment shouldn't trigger a new rollout. - tester.deployment, err = tester.updateDeployment(pauseFn()) + tester.deployment, err = tester.updateDeployment(pauseFn) if err != nil { t.Fatalf("failed to pause deployment %s: %v", tester.deployment.Name, err) } @@ -283,7 +283,7 @@ func TestScalePausedDeployment(t *testing.T) { } // Pause the deployment. - tester.deployment, err = tester.updateDeployment(pauseFn()) + tester.deployment, err = tester.updateDeployment(pauseFn) if err != nil { t.Fatalf("failed to pause deployment %s: %v", tester.deployment.Name, err) } diff --git a/test/integration/deployment/util.go b/test/integration/deployment/util.go index e907cd496c..9cd60f2cc2 100644 --- a/test/integration/deployment/util.go +++ b/test/integration/deployment/util.go @@ -45,6 +45,14 @@ const ( fakeImage = "fakeimage" ) +var pauseFn = func(update *v1beta1.Deployment) { + update.Spec.Paused = true +} + +var resumeFn = func(update *v1beta1.Deployment) { + update.Spec.Paused = false +} + type deploymentTester struct { t *testing.T c clientset.Interface @@ -252,15 +260,3 @@ func (d *deploymentTester) expectNewReplicaSet() (*v1beta1.ReplicaSet, error) { func (d *deploymentTester) updateReplicaSet(name string, applyUpdate testutil.UpdateReplicaSetFunc) (*v1beta1.ReplicaSet, error) { return testutil.UpdateReplicaSetWithRetries(d.c, d.deployment.Namespace, name, applyUpdate, d.t.Logf) } - -func pauseFn() func(update *v1beta1.Deployment) { - return func(update *v1beta1.Deployment) { - update.Spec.Paused = true - } -} - -func resumeFn() func(update *v1beta1.Deployment) { - return func(update *v1beta1.Deployment) { - update.Spec.Paused = false - } -}