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:
Daniel Nephin
2018-03-06 15:54:24 -05:00
parent f21276575f
commit e15b208e96
47 changed files with 83 additions and 88 deletions

View File

@ -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) {

View File

@ -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))
}

View File

@ -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())
}
}
}

View File

@ -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)
})
}
}

View File

@ -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()))
}

View File

@ -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()))
}

View File

@ -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()))
}

View File

@ -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()))
}

View File

@ -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()))
}

View File

@ -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()))
}

View File

@ -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()))
}

View File

@ -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()))
}

View File

@ -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()))
}

View File

@ -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()))
}

View File

@ -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()))
}

View File

@ -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()))
}

View File

@ -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) {

View File

@ -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")
}

View File

@ -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")
}

View File

@ -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) {

View File

@ -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)
}
}

View File

@ -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)
}
}

View File

@ -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))
}

View File

@ -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) {

View File

@ -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) {

View File

@ -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()

View File

@ -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()))
}

View File

@ -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))

View File

@ -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) {

View File

@ -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)
}
}

View File

@ -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)
}
}

View File

@ -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")
}

View File

@ -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")
}

View File

@ -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) {

View File

@ -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()))
}

View File

@ -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"))