Commit 3a0dabca authored by Janet Kuo's avatar Janet Kuo

Refactor function

parent 241f4fbc
......@@ -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)
}
......
......@@ -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
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment