Replace fmt.Errorf() with errors.Errorf() in the cli

Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
Daniel Nephin
2017-03-24 16:58:07 -04:00
parent c1b2fad9aa
commit e9d6193dfd
99 changed files with 370 additions and 337 deletions
+12 -11
View File
@@ -10,6 +10,7 @@ import (
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/cli/internal/test"
"github.com/pkg/errors"
// Import builders to get the builder function as package function
. "github.com/docker/docker/cli/internal/test/builders"
"github.com/docker/docker/pkg/testutil/assert"
@@ -37,7 +38,7 @@ func TestSwarmUpdateErrors(t *testing.T) {
flagTaskHistoryLimit: "10",
},
swarmInspectFunc: func() (swarm.Swarm, error) {
return swarm.Swarm{}, fmt.Errorf("error inspecting the swarm")
return swarm.Swarm{}, errors.Errorf("error inspecting the swarm")
},
expectedError: "error inspecting the swarm",
},
@@ -47,7 +48,7 @@ func TestSwarmUpdateErrors(t *testing.T) {
flagTaskHistoryLimit: "10",
},
swarmUpdateFunc: func(swarm swarm.Spec, flags swarm.UpdateFlags) error {
return fmt.Errorf("error updating the swarm")
return errors.Errorf("error updating the swarm")
},
expectedError: "error updating the swarm",
},
@@ -60,7 +61,7 @@ func TestSwarmUpdateErrors(t *testing.T) {
return *Swarm(), nil
},
swarmGetUnlockKeyFunc: func() (types.SwarmUnlockKeyResponse, error) {
return types.SwarmUnlockKeyResponse{}, fmt.Errorf("error getting unlock key")
return types.SwarmUnlockKeyResponse{}, errors.Errorf("error getting unlock key")
},
expectedError: "error getting unlock key",
},
@@ -108,33 +109,33 @@ func TestSwarmUpdate(t *testing.T) {
},
swarmUpdateFunc: func(swarm swarm.Spec, flags swarm.UpdateFlags) error {
if *swarm.Orchestration.TaskHistoryRetentionLimit != 10 {
return fmt.Errorf("historyLimit not correctly set")
return errors.Errorf("historyLimit not correctly set")
}
heartbeatDuration, err := time.ParseDuration("10s")
if err != nil {
return err
}
if swarm.Dispatcher.HeartbeatPeriod != heartbeatDuration {
return fmt.Errorf("heartbeatPeriodLimit not correctly set")
return errors.Errorf("heartbeatPeriodLimit not correctly set")
}
certExpiryDuration, err := time.ParseDuration("20s")
if err != nil {
return err
}
if swarm.CAConfig.NodeCertExpiry != certExpiryDuration {
return fmt.Errorf("certExpiry not correctly set")
return errors.Errorf("certExpiry not correctly set")
}
if len(swarm.CAConfig.ExternalCAs) != 1 {
return fmt.Errorf("externalCA not correctly set")
return errors.Errorf("externalCA not correctly set")
}
if *swarm.Raft.KeepOldSnapshots != 10 {
return fmt.Errorf("keepOldSnapshots not correctly set")
return errors.Errorf("keepOldSnapshots not correctly set")
}
if swarm.Raft.SnapshotInterval != 100 {
return fmt.Errorf("snapshotInterval not correctly set")
return errors.Errorf("snapshotInterval not correctly set")
}
if !swarm.EncryptionConfig.AutoLockManagers {
return fmt.Errorf("autolock not correctly set")
return errors.Errorf("autolock not correctly set")
}
return nil
},
@@ -147,7 +148,7 @@ func TestSwarmUpdate(t *testing.T) {
},
swarmUpdateFunc: func(swarm swarm.Spec, flags swarm.UpdateFlags) error {
if *swarm.Orchestration.TaskHistoryRetentionLimit != 10 {
return fmt.Errorf("historyLimit not correctly set")
return errors.Errorf("historyLimit not correctly set")
}
return nil
},