mirror of https://github.com/docker/cli.git
Convert assert.Check(t, is.Error()) to assert.Error
git grep -l -P '^\s+assert\.Check\(t, is\.Error\(' | \ xargs perl -pi -e 's/^(\s+assert\.)Check\(t, is\.Error\((.*)\)$/\1Error(t, \2/' Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
f21276575f
commit
e15b208e96
|
@ -38,7 +38,7 @@ func TestLoadFileSyntaxError(t *testing.T) {
|
|||
}`)
|
||||
|
||||
_, err := LoadFile(reader)
|
||||
assert.Check(t, is.Error(err, "JSON syntax error at byte 37: invalid character 'u' looking for beginning of value"))
|
||||
assert.Error(t, err, "JSON syntax error at byte 37: invalid character 'u' looking for beginning of value")
|
||||
}
|
||||
|
||||
func TestLoadFileTypeError(t *testing.T) {
|
||||
|
@ -53,7 +53,7 @@ func TestLoadFileTypeError(t *testing.T) {
|
|||
}`)
|
||||
|
||||
_, err := LoadFile(reader)
|
||||
assert.Check(t, is.Error(err, "Unexpected type at byte 94. Expected []string but received string."))
|
||||
assert.Error(t, err, "Unexpected type at byte 94. Expected []string but received string.")
|
||||
}
|
||||
|
||||
func TestPrint(t *testing.T) {
|
||||
|
|
|
@ -74,6 +74,6 @@ func TestConfigRemoveContinueAfterError(t *testing.T) {
|
|||
cmd := newConfigRemoveCommand(cli)
|
||||
cmd.SetArgs(names)
|
||||
cmd.SetOutput(ioutil.Discard)
|
||||
assert.Check(t, is.Error(cmd.Execute(), "error removing config: foo"))
|
||||
assert.Error(t, cmd.Execute(), "error removing config: foo")
|
||||
assert.Check(t, is.DeepEqual(names, removedConfigs))
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ import (
|
|||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
|
@ -124,7 +123,7 @@ func TestGetExitStatus(t *testing.T) {
|
|||
if testcase.expectedError == nil {
|
||||
assert.NilError(t, err)
|
||||
} else {
|
||||
assert.Check(t, is.Error(err, testcase.expectedError.Error()))
|
||||
assert.Error(t, err, testcase.expectedError.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ func TestRunCopyWithInvalidArguments(t *testing.T) {
|
|||
for _, testcase := range testcases {
|
||||
t.Run(testcase.doc, func(t *testing.T) {
|
||||
err := runCopy(test.NewFakeCli(nil), testcase.options)
|
||||
assert.Check(t, is.Error(err, testcase.expectedErr))
|
||||
assert.Error(t, err, testcase.expectedErr)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -244,7 +244,7 @@ size: 0B
|
|||
testcase.context.Output = out
|
||||
err := ContainerWrite(testcase.context, containers)
|
||||
if err != nil {
|
||||
assert.Check(t, is.Error(err, testcase.expected))
|
||||
assert.Error(t, err, testcase.expected)
|
||||
} else {
|
||||
assert.Check(t, is.Equal(testcase.expected, out.String()))
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ D: /usr/app/old_app.js
|
|||
testcase.context.Output = out
|
||||
err := DiffWrite(testcase.context, diffs)
|
||||
if err != nil {
|
||||
assert.Check(t, is.Error(err, testcase.expected))
|
||||
assert.Error(t, err, testcase.expected)
|
||||
} else {
|
||||
assert.Check(t, is.Equal(testcase.expected, out.String()))
|
||||
}
|
||||
|
|
|
@ -294,7 +294,7 @@ image_id: imageID3
|
|||
testcase.context.Output = out
|
||||
err := ImageWrite(testcase.context, images)
|
||||
if err != nil {
|
||||
assert.Check(t, is.Error(err, testcase.expected))
|
||||
assert.Error(t, err, testcase.expected)
|
||||
} else {
|
||||
assert.Check(t, is.Equal(testcase.expected, out.String()))
|
||||
}
|
||||
|
|
|
@ -162,7 +162,7 @@ foobar_bar 2017-01-01 00:00:00 +0000 UTC
|
|||
testcase.context.Output = out
|
||||
err := NetworkWrite(testcase.context, networks)
|
||||
if err != nil {
|
||||
assert.Check(t, is.Error(err, testcase.expected))
|
||||
assert.Error(t, err, testcase.expected)
|
||||
} else {
|
||||
assert.Check(t, is.Equal(testcase.expected, out.String()))
|
||||
}
|
||||
|
|
|
@ -203,7 +203,7 @@ foobar_boo Unknown
|
|||
testcase.context.Output = out
|
||||
err := NodeWrite(testcase.context, nodes, types.Info{Swarm: swarm.Info{Cluster: &testcase.clusterInfo}})
|
||||
if err != nil {
|
||||
assert.Check(t, is.Error(err, testcase.expected))
|
||||
assert.Error(t, err, testcase.expected)
|
||||
} else {
|
||||
assert.Check(t, is.Equal(testcase.expected, out.String()))
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ foobar_bar
|
|||
testcase.context.Output = out
|
||||
err := PluginWrite(testcase.context, plugins)
|
||||
if err != nil {
|
||||
assert.Check(t, is.Error(err, testcase.expected))
|
||||
assert.Error(t, err, testcase.expected)
|
||||
} else {
|
||||
assert.Check(t, is.Equal(testcase.expected, out.String()))
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ id_rsa
|
|||
out := bytes.NewBufferString("")
|
||||
testcase.context.Output = out
|
||||
if err := SecretWrite(testcase.context, secrets); err != nil {
|
||||
assert.Check(t, is.Error(err, testcase.expected))
|
||||
assert.Error(t, err, testcase.expected)
|
||||
} else {
|
||||
assert.Check(t, is.Equal(testcase.expected, out.String()))
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ bar
|
|||
testcase.context.Output = out
|
||||
err := ServiceListWrite(testcase.context, services, info)
|
||||
if err != nil {
|
||||
assert.Check(t, is.Error(err, testcase.expected))
|
||||
assert.Error(t, err, testcase.expected)
|
||||
} else {
|
||||
assert.Check(t, is.Equal(testcase.expected, out.String()))
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ container2 --
|
|||
te.context.Output = &out
|
||||
err := ContainerStatsWrite(te.context, stats, "linux", false)
|
||||
if err != nil {
|
||||
assert.Check(t, is.Error(err, te.expected))
|
||||
assert.Error(t, err, te.expected)
|
||||
} else {
|
||||
assert.Check(t, is.Equal(te.expected, out.String()))
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ container2 -- --
|
|||
te.context.Output = &out
|
||||
err := ContainerStatsWrite(te.context, stats, "windows", false)
|
||||
if err != nil {
|
||||
assert.Check(t, is.Error(err, te.expected))
|
||||
assert.Error(t, err, te.expected)
|
||||
} else {
|
||||
assert.Check(t, is.Equal(te.expected, out.String()))
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ foobar_bar foo2
|
|||
testcase.context.Output = out
|
||||
err := TaskWrite(testcase.context, tasks, names, nodes)
|
||||
if err != nil {
|
||||
assert.Check(t, is.Error(err, testcase.expected))
|
||||
assert.Error(t, err, testcase.expected)
|
||||
} else {
|
||||
assert.Check(t, is.Equal(testcase.expected, out.String()))
|
||||
}
|
||||
|
|
|
@ -127,7 +127,7 @@ tag3 bbbbbbbb
|
|||
testcase.context.Output = out
|
||||
err := TrustTagWrite(testcase.context, signedTags)
|
||||
if err != nil {
|
||||
assert.Check(t, is.Error(err, testcase.expected))
|
||||
assert.Error(t, err, testcase.expected)
|
||||
} else {
|
||||
assert.Check(t, is.Equal(testcase.expected, out.String()))
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ eve foobarbazquxquux, key31, key32
|
|||
testcase.context.Output = out
|
||||
err := SignerInfoWrite(testcase.context, signerInfo)
|
||||
if err != nil {
|
||||
assert.Check(t, is.Error(err, testcase.expected))
|
||||
assert.Error(t, err, testcase.expected)
|
||||
} else {
|
||||
assert.Check(t, is.Equal(testcase.expected, out.String()))
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ foobar_bar
|
|||
testcase.context.Output = out
|
||||
err := VolumeWrite(testcase.context, volumes)
|
||||
if err != nil {
|
||||
assert.Check(t, is.Error(err, testcase.expected))
|
||||
assert.Error(t, err, testcase.expected)
|
||||
} else {
|
||||
assert.Check(t, is.Equal(testcase.expected, out.String()))
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ func TestResolveError(t *testing.T) {
|
|||
idResolver := New(cli, false)
|
||||
_, err := idResolver.Resolve(context.Background(), struct{}{}, "nodeID")
|
||||
|
||||
assert.Check(t, is.Error(err, "unsupported type"))
|
||||
assert.Error(t, err, "unsupported type")
|
||||
}
|
||||
|
||||
func TestResolveWithNoResolveOption(t *testing.T) {
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
registrytypes "github.com/docker/docker/api/types/registry"
|
||||
"github.com/docker/docker/registry"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"github.com/theupdateframework/notary/client"
|
||||
"github.com/theupdateframework/notary/passphrase"
|
||||
"github.com/theupdateframework/notary/trustpinning"
|
||||
|
@ -71,5 +70,5 @@ func TestAddTargetToAllSignableRolesError(t *testing.T) {
|
|||
assert.NilError(t, err)
|
||||
target := client.Target{}
|
||||
err = AddTargetToAllSignableRoles(notaryRepo, &target)
|
||||
assert.Check(t, is.Error(err, "client is offline"))
|
||||
assert.Error(t, err, "client is offline")
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ func TestManifestCreateRefuseAmend(t *testing.T) {
|
|||
cmd.SetArgs([]string{"example.com/list:v1", "example.com/alpine:3.0"})
|
||||
cmd.SetOutput(ioutil.Discard)
|
||||
err = cmd.Execute()
|
||||
assert.Check(t, is.Error(err, "refusing to amend an existing manifest list with no --amend flag"))
|
||||
assert.Error(t, err, "refusing to amend an existing manifest list with no --amend flag")
|
||||
}
|
||||
|
||||
// attempt to make a manifest list without valid images
|
||||
|
@ -112,5 +112,5 @@ func TestManifestCreateNoManifest(t *testing.T) {
|
|||
cmd.SetArgs([]string{"example.com/list:v1", "example.com/alpine:3.0"})
|
||||
cmd.SetOutput(ioutil.Discard)
|
||||
err := cmd.Execute()
|
||||
assert.Check(t, is.Error(err, "No such image: example.com/alpine:3.0"))
|
||||
assert.Error(t, err, "No such image: example.com/alpine:3.0")
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import (
|
|||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"github.com/gotestyourself/gotestyourself/golden"
|
||||
"github.com/opencontainers/go-digest"
|
||||
digest "github.com/opencontainers/go-digest"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
@ -65,7 +65,7 @@ func TestInspectCommandLocalManifestNotFound(t *testing.T) {
|
|||
cmd.SetOutput(ioutil.Discard)
|
||||
cmd.SetArgs([]string{"example.com/list:v1", "example.com/alpine:3.0"})
|
||||
err := cmd.Execute()
|
||||
assert.Check(t, is.Error(err, "No such manifest: example.com/alpine:3.0"))
|
||||
assert.Error(t, err, "No such manifest: example.com/alpine:3.0")
|
||||
}
|
||||
|
||||
func TestInspectCommandNotFound(t *testing.T) {
|
||||
|
@ -87,7 +87,7 @@ func TestInspectCommandNotFound(t *testing.T) {
|
|||
cmd.SetOutput(ioutil.Discard)
|
||||
cmd.SetArgs([]string{"example.com/alpine:3.0"})
|
||||
err := cmd.Execute()
|
||||
assert.Check(t, is.Error(err, "No such manifest: example.com/alpine:3.0"))
|
||||
assert.Error(t, err, "No such manifest: example.com/alpine:3.0")
|
||||
}
|
||||
|
||||
func TestInspectCommandLocalManifest(t *testing.T) {
|
||||
|
|
|
@ -49,7 +49,7 @@ func TestNodeListErrorOnAPIFailure(t *testing.T) {
|
|||
})
|
||||
cmd := newListCommand(cli)
|
||||
cmd.SetOutput(ioutil.Discard)
|
||||
assert.Check(t, is.Error(cmd.Execute(), tc.expectedError))
|
||||
assert.Error(t, cmd.Execute(), tc.expectedError)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ import (
|
|||
// Import builders to get the builder function as package function
|
||||
. "github.com/docker/cli/internal/test/builders"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"github.com/gotestyourself/gotestyourself/golden"
|
||||
)
|
||||
|
||||
|
@ -61,7 +60,7 @@ func TestNodePsErrors(t *testing.T) {
|
|||
cmd.Flags().Set(key, value)
|
||||
}
|
||||
cmd.SetOutput(ioutil.Discard)
|
||||
assert.Check(t, is.Error(cmd.Execute(), tc.expectedError))
|
||||
assert.Error(t, cmd.Execute(), tc.expectedError)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -74,6 +74,6 @@ func TestSecretRemoveContinueAfterError(t *testing.T) {
|
|||
cmd := newSecretRemoveCommand(cli)
|
||||
cmd.SetOutput(ioutil.Discard)
|
||||
cmd.SetArgs(names)
|
||||
assert.Check(t, is.Error(cmd.Execute(), "error removing secret: foo"))
|
||||
assert.Error(t, cmd.Execute(), "error removing secret: foo")
|
||||
assert.Check(t, is.DeepEqual(names, removedSecrets))
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ func TestHealthCheckOptionsToHealthConfigConflict(t *testing.T) {
|
|||
noHealthcheck: true,
|
||||
}
|
||||
_, err := opt.toHealthConfig()
|
||||
assert.Check(t, is.Error(err, "--no-healthcheck conflicts with --health-* options"))
|
||||
assert.Error(t, err, "--no-healthcheck conflicts with --health-* options")
|
||||
}
|
||||
|
||||
func TestResourceOptionsToResourceRequirements(t *testing.T) {
|
||||
|
|
|
@ -60,7 +60,7 @@ func TestCreateFilterWithAmbiguousIDPrefixError(t *testing.T) {
|
|||
filter: opts.NewFilterOpt(),
|
||||
}
|
||||
_, _, err := createFilter(context.Background(), client, options)
|
||||
assert.Check(t, is.Error(err, "multiple services found with provided prefix: aaa"))
|
||||
assert.Error(t, err, "multiple services found with provided prefix: aaa")
|
||||
}
|
||||
|
||||
func TestCreateFilterNoneFound(t *testing.T) {
|
||||
|
@ -70,7 +70,7 @@ func TestCreateFilterNoneFound(t *testing.T) {
|
|||
filter: opts.NewFilterOpt(),
|
||||
}
|
||||
_, _, err := createFilter(context.Background(), client, options)
|
||||
assert.Check(t, is.Error(err, "no such service: foo\nno such service: notfound"))
|
||||
assert.Error(t, err, "no such service: foo\nno such service: notfound")
|
||||
}
|
||||
|
||||
func TestRunPSWarnsOnNotFound(t *testing.T) {
|
||||
|
@ -89,7 +89,7 @@ func TestRunPSWarnsOnNotFound(t *testing.T) {
|
|||
format: "{{.ID}}",
|
||||
}
|
||||
err := runPS(cli, options)
|
||||
assert.Check(t, is.Error(err, "no such service: bar"))
|
||||
assert.Error(t, err, "no such service: bar")
|
||||
}
|
||||
|
||||
func TestRunPSQuiet(t *testing.T) {
|
||||
|
|
|
@ -344,7 +344,7 @@ func TestUpdateHealthcheckTable(t *testing.T) {
|
|||
}
|
||||
err := updateHealthcheck(flags, cspec)
|
||||
if c.err != "" {
|
||||
assert.Check(t, is.Error(err, c.err))
|
||||
assert.Error(t, err, c.err)
|
||||
} else {
|
||||
assert.NilError(t, err)
|
||||
if !reflect.DeepEqual(cspec.Healthcheck, c.expected) {
|
||||
|
@ -626,14 +626,14 @@ func TestUpdateNetworks(t *testing.T) {
|
|||
err = flags.Set(flagNetworkAdd, "aaa-network")
|
||||
assert.NilError(t, err)
|
||||
err = updateService(ctx, client, flags, &svc)
|
||||
assert.Check(t, is.Error(err, "service is already attached to network aaa-network"))
|
||||
assert.Error(t, err, "service is already attached to network aaa-network")
|
||||
assert.Check(t, is.DeepEqual([]swarm.NetworkAttachmentConfig{{Target: "id555"}, {Target: "id999"}}, svc.TaskTemplate.Networks))
|
||||
|
||||
flags = newUpdateCommand(nil).Flags()
|
||||
err = flags.Set(flagNetworkAdd, "id555")
|
||||
assert.NilError(t, err)
|
||||
err = updateService(ctx, client, flags, &svc)
|
||||
assert.Check(t, is.Error(err, "service is already attached to network id555"))
|
||||
assert.Error(t, err, "service is already attached to network id555")
|
||||
assert.Check(t, is.DeepEqual([]swarm.NetworkAttachmentConfig{{Target: "id555"}, {Target: "id999"}}, svc.TaskTemplate.Networks))
|
||||
|
||||
flags = newUpdateCommand(nil).Flags()
|
||||
|
|
|
@ -61,7 +61,7 @@ func TestStackPsEmptyStack(t *testing.T) {
|
|||
cmd.SetArgs([]string{"foo"})
|
||||
cmd.SetOutput(ioutil.Discard)
|
||||
|
||||
assert.Check(t, is.Error(cmd.Execute(), "nothing found in stack: foo"))
|
||||
assert.Error(t, cmd.Execute(), "nothing found in stack: foo")
|
||||
assert.Check(t, is.Equal("", fakeCli.OutBuffer().String()))
|
||||
}
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ func TestRemoveContinueAfterError(t *testing.T) {
|
|||
cmd.SetOutput(ioutil.Discard)
|
||||
cmd.SetArgs([]string{"foo", "bar"})
|
||||
|
||||
assert.Check(t, is.Error(cmd.Execute(), "Failed to remove some resources from stack: foo"))
|
||||
assert.Error(t, cmd.Execute(), "Failed to remove some resources from stack: foo")
|
||||
assert.Check(t, is.DeepEqual(allServiceIDs, removedServices))
|
||||
assert.Check(t, is.DeepEqual(allNetworkIDs, cli.removedNetworks))
|
||||
assert.Check(t, is.DeepEqual(allSecretIDs, cli.removedSecrets))
|
||||
|
|
|
@ -34,7 +34,7 @@ func swarmSpecWithFullCAConfig() *swarm.Spec {
|
|||
func TestDisplayTrustRootNoRoot(t *testing.T) {
|
||||
buffer := new(bytes.Buffer)
|
||||
err := displayTrustRoot(buffer, swarm.Swarm{})
|
||||
assert.Check(t, is.Error(err, "No CA information available"))
|
||||
assert.Error(t, err, "No CA information available")
|
||||
}
|
||||
|
||||
func TestDisplayTrustRootInvalidFlags(t *testing.T) {
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"github.com/gotestyourself/gotestyourself/golden"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
@ -75,7 +74,7 @@ func TestSwarmInitErrorOnAPIFailure(t *testing.T) {
|
|||
cmd.Flags().Set(key, value)
|
||||
}
|
||||
cmd.SetOutput(ioutil.Discard)
|
||||
assert.Check(t, is.Error(cmd.Execute(), tc.expectedError))
|
||||
assert.Error(t, cmd.Execute(), tc.expectedError)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ func TestNodeAddrOptionSetPortOnly(t *testing.T) {
|
|||
|
||||
func TestNodeAddrOptionSetInvalidFormat(t *testing.T) {
|
||||
opt := NewListenAddrOption()
|
||||
assert.Check(t, is.Error(opt.Set("http://localhost:4545"), "Invalid proto, expected tcp: http://localhost:4545"))
|
||||
assert.Error(t, opt.Set("http://localhost:4545"), "Invalid proto, expected tcp: http://localhost:4545")
|
||||
}
|
||||
|
||||
func TestExternalCAOptionErrors(t *testing.T) {
|
||||
|
@ -65,7 +65,7 @@ func TestExternalCAOptionErrors(t *testing.T) {
|
|||
}
|
||||
for _, tc := range testCases {
|
||||
opt := &ExternalCAOption{}
|
||||
assert.Check(t, is.Error(opt.Set(tc.externalCA), tc.expectedError))
|
||||
assert.Error(t, opt.Set(tc.externalCA), tc.expectedError)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||
"github.com/theupdateframework/notary/client"
|
||||
"github.com/theupdateframework/notary/passphrase"
|
||||
"github.com/theupdateframework/notary/trustpinning"
|
||||
|
@ -21,5 +20,5 @@ func TestGetOrGenerateNotaryKeyAndInitRepo(t *testing.T) {
|
|||
assert.NilError(t, err)
|
||||
|
||||
err = getOrGenerateRootKeyAndInitRepo(notaryRepo)
|
||||
assert.Check(t, is.Error(err, "client is offline"))
|
||||
assert.Error(t, err, "client is offline")
|
||||
}
|
||||
|
|
|
@ -143,5 +143,5 @@ func TestGetSignableRolesForTargetAndRemoveError(t *testing.T) {
|
|||
assert.NilError(t, err)
|
||||
target := client.Target{}
|
||||
err = getSignableRolesForTargetAndRemove(target, notaryRepo)
|
||||
assert.Check(t, is.Error(err, "client is offline"))
|
||||
assert.Error(t, err, "client is offline")
|
||||
}
|
||||
|
|
|
@ -220,7 +220,7 @@ func TestGetSignedManifestHashAndSize(t *testing.T) {
|
|||
assert.NilError(t, err)
|
||||
target := &client.Target{}
|
||||
target.Hashes, target.Length, err = getSignedManifestHashAndSize(notaryRepo, "test")
|
||||
assert.Check(t, is.Error(err, "client is offline"))
|
||||
assert.Error(t, err, "client is offline")
|
||||
}
|
||||
|
||||
func TestGetReleasedTargetHashAndSize(t *testing.T) {
|
||||
|
@ -231,7 +231,7 @@ func TestGetReleasedTargetHashAndSize(t *testing.T) {
|
|||
oneReleasedTgt = append(oneReleasedTgt, client.TargetSignedStruct{Role: mockDelegationRoleWithName(unreleasedRole), Target: unreleasedTgt})
|
||||
}
|
||||
_, _, err := getReleasedTargetHashAndSize(oneReleasedTgt, "unreleased")
|
||||
assert.Check(t, is.Error(err, "No valid trust data for unreleased"))
|
||||
assert.Error(t, err, "No valid trust data for unreleased")
|
||||
releasedTgt := client.Target{Name: "released", Hashes: data.Hashes{notary.SHA256: []byte("released-hash")}}
|
||||
oneReleasedTgt = append(oneReleasedTgt, client.TargetSignedStruct{Role: mockDelegationRoleWithName("targets/releases"), Target: releasedTgt})
|
||||
hash, _, _ := getReleasedTargetHashAndSize(oneReleasedTgt, "unreleased")
|
||||
|
@ -247,9 +247,9 @@ func TestCreateTarget(t *testing.T) {
|
|||
notaryRepo, err := client.NewFileCachedRepository(tmpDir, "gun", "https://localhost", nil, passphrase.ConstantRetriever(passwd), trustpinning.TrustPinConfig{})
|
||||
assert.NilError(t, err)
|
||||
_, err = createTarget(notaryRepo, "")
|
||||
assert.Check(t, is.Error(err, "No tag specified"))
|
||||
assert.Error(t, err, "No tag specified")
|
||||
_, err = createTarget(notaryRepo, "1")
|
||||
assert.Check(t, is.Error(err, "client is offline"))
|
||||
assert.Error(t, err, "client is offline")
|
||||
}
|
||||
|
||||
func TestGetExistingSignatureInfoForReleasedTag(t *testing.T) {
|
||||
|
@ -260,7 +260,7 @@ func TestGetExistingSignatureInfoForReleasedTag(t *testing.T) {
|
|||
notaryRepo, err := client.NewFileCachedRepository(tmpDir, "gun", "https://localhost", nil, passphrase.ConstantRetriever(passwd), trustpinning.TrustPinConfig{})
|
||||
assert.NilError(t, err)
|
||||
_, err = getExistingSignatureInfoForReleasedTag(notaryRepo, "test")
|
||||
assert.Check(t, is.Error(err, "client is offline"))
|
||||
assert.Error(t, err, "client is offline")
|
||||
}
|
||||
|
||||
func TestPrettyPrintExistingSignatureInfo(t *testing.T) {
|
||||
|
|
|
@ -81,7 +81,7 @@ func TestSignerAddCommandNoTargetsKey(t *testing.T) {
|
|||
cmd.SetArgs([]string{"--key", tmpfile.Name(), "alice", "alpine", "linuxkit/alpine"})
|
||||
|
||||
cmd.SetOutput(ioutil.Discard)
|
||||
assert.Check(t, is.Error(cmd.Execute(), fmt.Sprintf("could not parse public key from file: %s: no valid public key found", tmpfile.Name())))
|
||||
assert.Error(t, cmd.Execute(), fmt.Sprintf("could not parse public key from file: %s: no valid public key found", tmpfile.Name()))
|
||||
}
|
||||
|
||||
func TestSignerAddCommandBadKeyPath(t *testing.T) {
|
||||
|
@ -96,7 +96,7 @@ func TestSignerAddCommandBadKeyPath(t *testing.T) {
|
|||
cmd.SetArgs([]string{"--key", "/path/to/key.pem", "alice", "alpine"})
|
||||
|
||||
cmd.SetOutput(ioutil.Discard)
|
||||
assert.Check(t, is.Error(cmd.Execute(), "unable to read public key from file: open /path/to/key.pem: no such file or directory"))
|
||||
assert.Error(t, cmd.Execute(), "unable to read public key from file: open /path/to/key.pem: no such file or directory")
|
||||
}
|
||||
|
||||
func TestSignerAddCommandInvalidRepoName(t *testing.T) {
|
||||
|
@ -118,7 +118,7 @@ func TestSignerAddCommandInvalidRepoName(t *testing.T) {
|
|||
cmd.SetArgs([]string{"--key", pubKeyFilepath, "alice", imageName})
|
||||
|
||||
cmd.SetOutput(ioutil.Discard)
|
||||
assert.Check(t, is.Error(cmd.Execute(), "Failed to add signer to: 870d292919d01a0af7e7f056271dc78792c05f55f49b9b9012b6d89725bd9abd"))
|
||||
assert.Error(t, cmd.Execute(), "Failed to add signer to: 870d292919d01a0af7e7f056271dc78792c05f55f49b9b9012b6d89725bd9abd")
|
||||
expectedErr := fmt.Sprintf("invalid repository name (%s), cannot specify 64-byte hexadecimal strings\n\n", imageName)
|
||||
|
||||
assert.Check(t, is.Equal(expectedErr, cli.ErrBuffer().String()))
|
||||
|
@ -127,11 +127,11 @@ func TestSignerAddCommandInvalidRepoName(t *testing.T) {
|
|||
func TestIngestPublicKeys(t *testing.T) {
|
||||
// Call with a bad path
|
||||
_, err := ingestPublicKeys([]string{"foo", "bar"})
|
||||
assert.Check(t, is.Error(err, "unable to read public key from file: open foo: no such file or directory"))
|
||||
assert.Error(t, err, "unable to read public key from file: open foo: no such file or directory")
|
||||
// Call with real file path
|
||||
tmpfile, err := ioutil.TempFile("", "pemfile")
|
||||
assert.NilError(t, err)
|
||||
defer os.Remove(tmpfile.Name())
|
||||
_, err = ingestPublicKeys([]string{tmpfile.Name()})
|
||||
assert.Check(t, is.Error(err, fmt.Sprintf("could not parse public key from file: %s: no valid public key found", tmpfile.Name())))
|
||||
assert.Error(t, err, fmt.Sprintf("could not parse public key from file: %s: no valid public key found", tmpfile.Name()))
|
||||
}
|
||||
|
|
|
@ -71,16 +71,16 @@ func TestRemoveSingleSigner(t *testing.T) {
|
|||
cli := test.NewFakeCli(&fakeClient{})
|
||||
cli.SetNotaryClient(getLoadedNotaryRepository)
|
||||
err := removeSingleSigner(cli, "signed-repo", "test", true)
|
||||
assert.Check(t, is.Error(err, "No signer test for repository signed-repo"))
|
||||
assert.Error(t, err, "No signer test for repository signed-repo")
|
||||
err = removeSingleSigner(cli, "signed-repo", "releases", true)
|
||||
assert.Check(t, is.Error(err, "releases is a reserved keyword and cannot be removed"))
|
||||
assert.Error(t, err, "releases is a reserved keyword and cannot be removed")
|
||||
}
|
||||
|
||||
func TestRemoveMultipleSigners(t *testing.T) {
|
||||
cli := test.NewFakeCli(&fakeClient{})
|
||||
cli.SetNotaryClient(getLoadedNotaryRepository)
|
||||
err := removeSigner(cli, signerRemoveOptions{signer: "test", repos: []string{"signed-repo", "signed-repo"}, forceYes: true})
|
||||
assert.Check(t, is.Error(err, "Error removing signer from: signed-repo, signed-repo"))
|
||||
assert.Error(t, err, "Error removing signer from: signed-repo, signed-repo")
|
||||
assert.Check(t, is.Contains(cli.ErrBuffer().String(),
|
||||
"No signer test for repository signed-repo"))
|
||||
assert.Check(t, is.Contains(cli.OutBuffer().String(), "Removing signer \"test\" from signed-repo...\n"))
|
||||
|
|
|
@ -26,7 +26,7 @@ func TestConvertRestartPolicyFromNone(t *testing.T) {
|
|||
|
||||
func TestConvertRestartPolicyFromUnknown(t *testing.T) {
|
||||
_, err := convertRestartPolicy("unknown", nil)
|
||||
assert.Check(t, is.Error(err, "unknown restart policy: unknown"))
|
||||
assert.Error(t, err, "unknown restart policy: unknown")
|
||||
}
|
||||
|
||||
func TestConvertRestartPolicyFromAlways(t *testing.T) {
|
||||
|
@ -161,7 +161,7 @@ func TestConvertHealthcheckDisableWithTest(t *testing.T) {
|
|||
Test: []string{"EXEC", "touch"},
|
||||
}
|
||||
_, err := convertHealthcheck(source)
|
||||
assert.Check(t, is.Error(err, "test and disable can't be set at the same time"))
|
||||
assert.Error(t, err, "test and disable can't be set at the same time")
|
||||
}
|
||||
|
||||
func TestConvertEndpointSpec(t *testing.T) {
|
||||
|
|
|
@ -32,7 +32,7 @@ func TestConvertVolumeToMountAnonymousBind(t *testing.T) {
|
|||
},
|
||||
}
|
||||
_, err := convertVolumeToMount(config, volumes{}, NewNamespace("foo"))
|
||||
assert.Check(t, is.Error(err, "invalid bind source, source cannot be empty"))
|
||||
assert.Error(t, err, "invalid bind source, source cannot be empty")
|
||||
}
|
||||
|
||||
func TestConvertVolumeToMountUnapprovedType(t *testing.T) {
|
||||
|
@ -41,7 +41,7 @@ func TestConvertVolumeToMountUnapprovedType(t *testing.T) {
|
|||
Target: "/foo/bar",
|
||||
}
|
||||
_, err := convertVolumeToMount(config, volumes{}, NewNamespace("foo"))
|
||||
assert.Check(t, is.Error(err, "volume type must be volume, bind, or tmpfs"))
|
||||
assert.Error(t, err, "volume type must be volume, bind, or tmpfs")
|
||||
}
|
||||
|
||||
func TestConvertVolumeToMountConflictingOptionsBindInVolume(t *testing.T) {
|
||||
|
@ -56,7 +56,7 @@ func TestConvertVolumeToMountConflictingOptionsBindInVolume(t *testing.T) {
|
|||
},
|
||||
}
|
||||
_, err := convertVolumeToMount(config, volumes{}, namespace)
|
||||
assert.Check(t, is.Error(err, "bind options are incompatible with type volume"))
|
||||
assert.Error(t, err, "bind options are incompatible with type volume")
|
||||
}
|
||||
|
||||
func TestConvertVolumeToMountConflictingOptionsTmpfsInVolume(t *testing.T) {
|
||||
|
@ -71,7 +71,7 @@ func TestConvertVolumeToMountConflictingOptionsTmpfsInVolume(t *testing.T) {
|
|||
},
|
||||
}
|
||||
_, err := convertVolumeToMount(config, volumes{}, namespace)
|
||||
assert.Check(t, is.Error(err, "tmpfs options are incompatible with type volume"))
|
||||
assert.Error(t, err, "tmpfs options are incompatible with type volume")
|
||||
}
|
||||
|
||||
func TestConvertVolumeToMountConflictingOptionsVolumeInBind(t *testing.T) {
|
||||
|
@ -86,7 +86,7 @@ func TestConvertVolumeToMountConflictingOptionsVolumeInBind(t *testing.T) {
|
|||
},
|
||||
}
|
||||
_, err := convertVolumeToMount(config, volumes{}, namespace)
|
||||
assert.Check(t, is.Error(err, "volume options are incompatible with type bind"))
|
||||
assert.Error(t, err, "volume options are incompatible with type bind")
|
||||
}
|
||||
|
||||
func TestConvertVolumeToMountConflictingOptionsTmpfsInBind(t *testing.T) {
|
||||
|
@ -101,7 +101,7 @@ func TestConvertVolumeToMountConflictingOptionsTmpfsInBind(t *testing.T) {
|
|||
},
|
||||
}
|
||||
_, err := convertVolumeToMount(config, volumes{}, namespace)
|
||||
assert.Check(t, is.Error(err, "tmpfs options are incompatible with type bind"))
|
||||
assert.Error(t, err, "tmpfs options are incompatible with type bind")
|
||||
}
|
||||
|
||||
func TestConvertVolumeToMountConflictingOptionsBindInTmpfs(t *testing.T) {
|
||||
|
@ -115,7 +115,7 @@ func TestConvertVolumeToMountConflictingOptionsBindInTmpfs(t *testing.T) {
|
|||
},
|
||||
}
|
||||
_, err := convertVolumeToMount(config, volumes{}, namespace)
|
||||
assert.Check(t, is.Error(err, "bind options are incompatible with type tmpfs"))
|
||||
assert.Error(t, err, "bind options are incompatible with type tmpfs")
|
||||
}
|
||||
|
||||
func TestConvertVolumeToMountConflictingOptionsVolumeInTmpfs(t *testing.T) {
|
||||
|
@ -129,7 +129,7 @@ func TestConvertVolumeToMountConflictingOptionsVolumeInTmpfs(t *testing.T) {
|
|||
},
|
||||
}
|
||||
_, err := convertVolumeToMount(config, volumes{}, namespace)
|
||||
assert.Check(t, is.Error(err, "volume options are incompatible with type tmpfs"))
|
||||
assert.Error(t, err, "volume options are incompatible with type tmpfs")
|
||||
}
|
||||
|
||||
func TestConvertVolumeToMountNamedVolume(t *testing.T) {
|
||||
|
@ -309,7 +309,7 @@ func TestConvertVolumeToMountVolumeDoesNotExist(t *testing.T) {
|
|||
ReadOnly: true,
|
||||
}
|
||||
_, err := convertVolumeToMount(config, volumes{}, namespace)
|
||||
assert.Check(t, is.Error(err, "undefined volume \"unknown\""))
|
||||
assert.Error(t, err, "undefined volume \"unknown\"")
|
||||
}
|
||||
|
||||
func TestConvertTmpfsToMountVolume(t *testing.T) {
|
||||
|
@ -341,5 +341,5 @@ func TestConvertTmpfsToMountVolumeWithSource(t *testing.T) {
|
|||
}
|
||||
|
||||
_, err := convertVolumeToMount(config, volumes{}, NewNamespace("foo"))
|
||||
assert.Check(t, is.Error(err, "invalid tmpfs source, source must be empty"))
|
||||
assert.Error(t, err, "invalid tmpfs source, source must be empty")
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ func TestInvalidInterpolation(t *testing.T) {
|
|||
},
|
||||
}
|
||||
_, err := Interpolate(services, Options{LookupValue: defaultMapping})
|
||||
assert.Check(t, is.Error(err, `invalid interpolation format for servicea.image: "${". You may need to escape any $ with another $.`))
|
||||
assert.Error(t, err, `invalid interpolation format for servicea.image: "${". You may need to escape any $ with another $.`)
|
||||
}
|
||||
|
||||
func TestInterpolateWithDefaults(t *testing.T) {
|
||||
|
|
|
@ -29,7 +29,7 @@ func TestParseVolumeAnonymousVolumeWindows(t *testing.T) {
|
|||
|
||||
func TestParseVolumeTooManyColons(t *testing.T) {
|
||||
_, err := ParseVolume("/foo:/foo:ro:foo")
|
||||
assert.Check(t, is.Error(err, "invalid spec: /foo:/foo:ro:foo: too many colons"))
|
||||
assert.Error(t, err, "invalid spec: /foo:/foo:ro:foo: too many colons")
|
||||
}
|
||||
|
||||
func TestParseVolumeShortVolumes(t *testing.T) {
|
||||
|
|
|
@ -96,7 +96,7 @@ func TestStoreSaveAndGet(t *testing.T) {
|
|||
t.Run(testcase.manifestRef.String(), func(t *testing.T) {
|
||||
actual, err := store.Get(testcase.listRef, testcase.manifestRef)
|
||||
if testcase.expectedErr != "" {
|
||||
assert.Check(t, is.Error(err, testcase.expectedErr))
|
||||
assert.Error(t, err, testcase.expectedErr)
|
||||
assert.Check(t, IsNotFound(err))
|
||||
return
|
||||
}
|
||||
|
@ -131,6 +131,6 @@ func TestStoreGetListDoesNotExist(t *testing.T) {
|
|||
|
||||
listRef := ref("list")
|
||||
_, err := store.GetList(listRef)
|
||||
assert.Check(t, is.Error(err, "No such manifest: list"))
|
||||
assert.Error(t, err, "No such manifest: list")
|
||||
assert.Check(t, IsNotFound(err))
|
||||
}
|
||||
|
|
|
@ -57,5 +57,5 @@ func TestGetSignableRolesError(t *testing.T) {
|
|||
assert.NilError(t, err)
|
||||
target := client.Target{}
|
||||
_, err = GetSignableRoles(notaryRepo, &target)
|
||||
assert.Check(t, is.Error(err, "client is offline"))
|
||||
assert.Error(t, err, "client is offline")
|
||||
}
|
||||
|
|
|
@ -29,5 +29,5 @@ func TestExitStatusForInvalidSubcommandWithHelpFlag(t *testing.T) {
|
|||
cmd := newDockerCommand(command.NewDockerCli(os.Stdin, discard, discard))
|
||||
cmd.SetArgs([]string{"help", "invalid"})
|
||||
err := cmd.Execute()
|
||||
assert.Check(t, is.Error(err, "unknown help topic: invalid"))
|
||||
assert.Error(t, err, "unknown help topic: invalid")
|
||||
}
|
||||
|
|
|
@ -26,5 +26,5 @@ func TestPositiveDurationOptSetAndValue(t *testing.T) {
|
|||
var duration PositiveDurationOpt
|
||||
assert.NilError(t, duration.Set("300s"))
|
||||
assert.Check(t, is.Equal(time.Duration(300*10e8), *duration.Value()))
|
||||
assert.Check(t, is.Error(duration.Set("-300s"), "duration cannot be negative"))
|
||||
assert.Error(t, duration.Set("-300s"), "duration cannot be negative")
|
||||
}
|
||||
|
|
|
@ -82,23 +82,23 @@ func TestMountOptDefaultType(t *testing.T) {
|
|||
|
||||
func TestMountOptSetErrorNoTarget(t *testing.T) {
|
||||
var mount MountOpt
|
||||
assert.Check(t, is.Error(mount.Set("type=volume,source=/foo"), "target is required"))
|
||||
assert.Error(t, mount.Set("type=volume,source=/foo"), "target is required")
|
||||
}
|
||||
|
||||
func TestMountOptSetErrorInvalidKey(t *testing.T) {
|
||||
var mount MountOpt
|
||||
assert.Check(t, is.Error(mount.Set("type=volume,bogus=foo"), "unexpected key 'bogus' in 'bogus=foo'"))
|
||||
assert.Error(t, mount.Set("type=volume,bogus=foo"), "unexpected key 'bogus' in 'bogus=foo'")
|
||||
}
|
||||
|
||||
func TestMountOptSetErrorInvalidField(t *testing.T) {
|
||||
var mount MountOpt
|
||||
assert.Check(t, is.Error(mount.Set("type=volume,bogus"), "invalid field 'bogus' must be a key=value pair"))
|
||||
assert.Error(t, mount.Set("type=volume,bogus"), "invalid field 'bogus' must be a key=value pair")
|
||||
}
|
||||
|
||||
func TestMountOptSetErrorInvalidReadOnly(t *testing.T) {
|
||||
var mount MountOpt
|
||||
assert.Check(t, is.Error(mount.Set("type=volume,readonly=no"), "invalid value for readonly: no"))
|
||||
assert.Check(t, is.Error(mount.Set("type=volume,readonly=invalid"), "invalid value for readonly: invalid"))
|
||||
assert.Error(t, mount.Set("type=volume,readonly=no"), "invalid value for readonly: no")
|
||||
assert.Error(t, mount.Set("type=volume,readonly=invalid"), "invalid value for readonly: invalid")
|
||||
}
|
||||
|
||||
func TestMountOptDefaultEnableReadOnly(t *testing.T) {
|
||||
|
|
|
@ -278,7 +278,7 @@ func TestPortOptInvalidSimpleSyntax(t *testing.T) {
|
|||
}
|
||||
for _, tc := range testCases {
|
||||
var port PortOpt
|
||||
assert.Check(t, is.Error(port.Set(tc.value), tc.expectedError))
|
||||
assert.Error(t, port.Set(tc.value), tc.expectedError)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ func TestParseLogDetails(t *testing.T) {
|
|||
t.Run(testcase.line, func(t *testing.T) {
|
||||
actual, err := ParseLogDetails(testcase.line)
|
||||
if testcase.err != nil {
|
||||
assert.Check(t, is.Error(err, testcase.err.Error()))
|
||||
assert.Error(t, err, testcase.err.Error())
|
||||
return
|
||||
}
|
||||
assert.Check(t, is.DeepEqual(testcase.expected, actual))
|
||||
|
|
Loading…
Reference in New Issue