Using:

  git grep -l '^\s\+assert\.Check(t, err)$' | \
    xargs sed -i -e 's/^\(\s\+assert\)\.Check(t, err)$/\1.NilError(t, err)/'

Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
Daniel Nephin 2018-03-06 14:44:13 -05:00
Родитель 0f11a310fd
Коммит baf65a5502
46 изменённых файлов: 173 добавлений и 173 удалений

Просмотреть файл

@ -26,7 +26,7 @@ func TestLoadFileV01Success(t *testing.T) {
}`)
bundle, err := LoadFile(reader)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.Equal("0.1", bundle.Version))
assert.Check(t, is.Len(bundle.Services, 2))
}

Просмотреть файл

@ -163,7 +163,7 @@ func TestExperimentalCLI(t *testing.T) {
cli := &DockerCli{client: apiclient, err: os.Stderr}
cliconfig.SetDir(dir.Path())
err := cli.Initialize(flags.NewClientOptions())
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.Equal(testcase.expectedExperimentalCLI, cli.ClientInfo().HasExperimental))
})
}
@ -266,7 +266,7 @@ func TestOrchestratorSwitch(t *testing.T) {
options.Common.Orchestrator = testcase.flagOrchestrator
}
err := cli.Initialize(options)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.Equal(testcase.expectedKubernetes, cli.ClientInfo().HasKubernetes()))
assert.Check(t, is.Equal(testcase.expectedOrchestrator, string(cli.ClientInfo().Orchestrator)))
})
@ -334,7 +334,7 @@ func TestGetClientWithPassword(t *testing.T) {
return
}
assert.Check(t, err)
assert.NilError(t, err)
})
}
}

Просмотреть файл

@ -83,7 +83,7 @@ func TestConfigCreateWithLabels(t *testing.T) {
name := "foo"
data, err := ioutil.ReadFile(filepath.Join("testdata", configDataFile))
assert.Check(t, err)
assert.NilError(t, err)
expected := swarm.ConfigSpec{
Annotations: swarm.Annotations{

Просмотреть файл

@ -122,7 +122,7 @@ func TestGetExitStatus(t *testing.T) {
}
err := getExitStatus(errC, resultC)
if testcase.expectedError == nil {
assert.Check(t, err)
assert.NilError(t, err)
} else {
assert.Check(t, is.Error(err, testcase.expectedError.Error()))
}

Просмотреть файл

@ -71,7 +71,7 @@ func parseMustError(t *testing.T, args string) {
func mustParse(t *testing.T, args string) (*container.Config, *container.HostConfig) {
config, hostConfig, _, err := parseRun(append(strings.Split(args, " "), "ubuntu", "bash"))
assert.Check(t, err)
assert.NilError(t, err)
return config, hostConfig
}

Просмотреть файл

@ -102,7 +102,7 @@ func TestBuildContainerListOptions(t *testing.T) {
for _, c := range contexts {
options, err := buildContainerListOptions(c.psOpts)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.Equal(c.expectedAll, options.All))
assert.Check(t, is.Equal(c.expectedSize, options.Size))

Просмотреть файл

@ -153,7 +153,7 @@ func TestTrustTagContextEmptyWrite(t *testing.T) {
out := bytes.NewBufferString("")
emptyCase.context.Output = out
err := TrustTagWrite(emptyCase.context, emptySignedTags)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.Equal(emptyCase.expected, out.String()))
}
@ -172,7 +172,7 @@ func TestSignerInfoContextEmptyWrite(t *testing.T) {
out := bytes.NewBufferString("")
emptyCase.context.Output = out
err := SignerInfoWrite(emptyCase.context, emptySignerInfo)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.Equal(emptyCase.expected, out.String()))
}

Просмотреть файл

@ -41,7 +41,7 @@ func TestResolveWithNoResolveOption(t *testing.T) {
idResolver := New(cli, true)
id, err := idResolver.Resolve(context.Background(), swarm.Node{}, "nodeID")
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.Equal("nodeID", id))
assert.Check(t, !resolved)
}
@ -60,7 +60,7 @@ func TestResolveWithCache(t *testing.T) {
ctx := context.Background()
for i := 0; i < 2; i++ {
id, err := idResolver.Resolve(ctx, swarm.Node{}, "nodeID")
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.Equal("node-foo", id))
}
@ -104,7 +104,7 @@ func TestResolveNode(t *testing.T) {
idResolver := New(cli, false)
id, err := idResolver.Resolve(ctx, swarm.Node{}, tc.nodeID)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.Equal(tc.expectedID, id))
}
}
@ -139,7 +139,7 @@ func TestResolveService(t *testing.T) {
idResolver := New(cli, false)
id, err := idResolver.Resolve(ctx, swarm.Service{}, tc.serviceID)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.Equal(tc.expectedID, id))
}
}

Просмотреть файл

@ -91,7 +91,7 @@ func TestNewHistoryCommandSuccess(t *testing.T) {
cmd.SetOutput(ioutil.Discard)
cmd.SetArgs(tc.args)
err := cmd.Execute()
assert.Check(t, err)
assert.NilError(t, err)
actual := cli.OutBuffer().String()
golden.Assert(t, actual, fmt.Sprintf("history-command-success.%s.golden", tc.name))
}

Просмотреть файл

@ -81,7 +81,7 @@ func TestNewInspectCommandSuccess(t *testing.T) {
cmd.SetOutput(ioutil.Discard)
cmd.SetArgs(tc.args)
err := cmd.Execute()
assert.Check(t, err)
assert.NilError(t, err)
golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("inspect-command-success.%s.golden", tc.name))
assert.Check(t, is.Equal(imageInspectInvocationCount, tc.imageCount))
}

Просмотреть файл

@ -85,7 +85,7 @@ func TestNewImagesCommandSuccess(t *testing.T) {
cmd.SetOutput(ioutil.Discard)
cmd.SetArgs(tc.args)
err := cmd.Execute()
assert.Check(t, err)
assert.NilError(t, err)
golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("list-command-success.%s.golden", tc.name))
}
}

Просмотреть файл

@ -95,7 +95,7 @@ func TestNewLoadCommandSuccess(t *testing.T) {
cmd.SetOutput(ioutil.Discard)
cmd.SetArgs(tc.args)
err := cmd.Execute()
assert.Check(t, err)
assert.NilError(t, err)
golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("load-command-success.%s.golden", tc.name))
}
}

Просмотреть файл

@ -88,7 +88,7 @@ func TestNewPruneCommandSuccess(t *testing.T) {
cmd.SetOutput(ioutil.Discard)
cmd.SetArgs(tc.args)
err := cmd.Execute()
assert.Check(t, err)
assert.NilError(t, err)
golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("prune-command-success.%s.golden", tc.name))
}
}

Просмотреть файл

@ -73,7 +73,7 @@ func TestNewPullCommandSuccess(t *testing.T) {
cmd.SetOutput(ioutil.Discard)
cmd.SetArgs(tc.args)
err := cmd.Execute()
assert.Check(t, err)
assert.NilError(t, err)
golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("pull-command-success.%s.golden", tc.name))
}
}

Просмотреть файл

@ -64,7 +64,7 @@ func TestNonOfficialTrustServer(t *testing.T) {
func TestAddTargetToAllSignableRolesError(t *testing.T) {
tmpDir, err := ioutil.TempDir("", "notary-test-")
assert.Check(t, err)
assert.NilError(t, err)
defer os.RemoveAll(tmpDir)
notaryRepo, err := client.NewFileCachedRepository(tmpDir, "gun", "https://localhost", nil, passphrase.ConstantRetriever("password"), trustpinning.TrustPinConfig{})

Просмотреть файл

@ -140,7 +140,7 @@ func TestGetDefaultAuthConfig(t *testing.T) {
assert.Check(t, err != nil)
assert.Check(t, is.Equal(tc.expectedErr, err.Error()))
} else {
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(tc.expectedAuthConfig, *authconfig))
}
}

Просмотреть файл

@ -52,7 +52,7 @@ func TestSecretCreateErrors(t *testing.T) {
func TestSecretCreateWithName(t *testing.T) {
name := "foo"
data, err := ioutil.ReadFile(filepath.Join("testdata", secretDataFile))
assert.Check(t, err)
assert.NilError(t, err)
expected := swarm.SecretSpec{
Annotations: swarm.Annotations{

Просмотреть файл

@ -18,6 +18,6 @@ func TestValidateSingleGenericResource(t *testing.T) {
for _, v := range correct {
_, err := ValidateSingleGenericResource(v)
assert.Check(t, err)
assert.NilError(t, err)
}
}

Просмотреть файл

@ -61,7 +61,7 @@ func TestHealthCheckOptionsToHealthConfig(t *testing.T) {
retries: 10,
}
config, err := opt.toHealthConfig()
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(&container.HealthConfig{
Test: []string{"CMD-SHELL", "curl"},
Interval: time.Second,
@ -76,7 +76,7 @@ func TestHealthCheckOptionsToHealthConfigNoHealthcheck(t *testing.T) {
noHealthcheck: true,
}
config, err := opt.toHealthConfig()
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(&container.HealthConfig{
Test: []string{"NONE"},
}, config))
@ -123,7 +123,7 @@ func TestResourceOptionsToResourceRequirements(t *testing.T) {
for _, opt := range correctOptions {
r, err := opt.ToResourceRequirements()
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.Len(r.Reservations.GenericResources, len(opt.resGenericResources)))
}

Просмотреть файл

@ -244,7 +244,7 @@ func TestUpdatePorts(t *testing.T) {
}
err := updatePorts(flags, &portConfigs)
assert.Check(t, err)
assert.NilError(t, err)
assert.Assert(t, is.Len(portConfigs, 2))
// Do a sort to have the order (might have changed by map)
targetPorts := []int{int(portConfigs[0].TargetPort), int(portConfigs[1].TargetPort)}
@ -268,7 +268,7 @@ func TestUpdatePortsDuplicate(t *testing.T) {
}
err := updatePorts(flags, &portConfigs)
assert.Check(t, err)
assert.NilError(t, err)
assert.Assert(t, is.Len(portConfigs, 1))
assert.Check(t, is.Equal(uint32(80), portConfigs[0].TargetPort))
}
@ -346,7 +346,7 @@ func TestUpdateHealthcheckTable(t *testing.T) {
if c.err != "" {
assert.Check(t, is.Error(err, c.err))
} else {
assert.Check(t, err)
assert.NilError(t, err)
if !reflect.DeepEqual(cspec.Healthcheck, c.expected) {
t.Errorf("incorrect result for test %d, expected health config:\n\t%#v\ngot:\n\t%#v", i, c.expected, cspec.Healthcheck)
}
@ -369,7 +369,7 @@ func TestUpdateHosts(t *testing.T) {
expected := []string{"1.2.3.4 example.com", "4.3.2.1 example.org", "2001:db8:abc8::1 ipv6.net"}
err := updateHosts(flags, &hosts)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(expected, hosts))
}
@ -381,7 +381,7 @@ func TestUpdateHostsPreservesOrder(t *testing.T) {
hosts := []string{}
err := updateHosts(flags, &hosts)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual([]string{"127.0.0.2 foobar", "127.0.0.1 foobar", "127.0.0.3 foobar"}, hosts))
}
@ -403,7 +403,7 @@ func TestUpdatePortsRmWithProtocol(t *testing.T) {
}
err := updatePorts(flags, &portConfigs)
assert.Check(t, err)
assert.NilError(t, err)
assert.Assert(t, is.Len(portConfigs, 2))
assert.Check(t, is.Equal(uint32(81), portConfigs[0].TargetPort))
assert.Check(t, is.Equal(uint32(82), portConfigs[1].TargetPort))
@ -460,7 +460,7 @@ func TestUpdateSecretUpdateInPlace(t *testing.T) {
updatedSecrets, err := getUpdatedSecrets(apiClient, flags, secrets)
assert.Check(t, err)
assert.NilError(t, err)
assert.Assert(t, is.Len(updatedSecrets, 1))
assert.Check(t, is.Equal("tn9qiblgnuuut11eufquw5dev", updatedSecrets[0].SecretID))
assert.Check(t, is.Equal("foo", updatedSecrets[0].SecretName))
@ -640,7 +640,7 @@ func TestUpdateNetworks(t *testing.T) {
err = flags.Set(flagNetworkRemove, "id999")
assert.NilError(t, err)
err = updateService(ctx, client, flags, &svc)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual([]swarm.NetworkAttachmentConfig{{Target: "id555"}}, svc.TaskTemplate.Networks))
flags = newUpdateCommand(nil).Flags()
@ -649,6 +649,6 @@ func TestUpdateNetworks(t *testing.T) {
err = flags.Set(flagNetworkRemove, "aaa-network")
assert.NilError(t, err)
err = updateService(ctx, client, flags, &svc)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual([]swarm.NetworkAttachmentConfig{{Target: "id999"}}, svc.TaskTemplate.Networks))
}

Просмотреть файл

@ -45,6 +45,6 @@ func TestLoadBundlefile(t *testing.T) {
path := filepath.Join("testdata", "bundlefile_with_two_services.dab")
bundleFile, err := loadBundlefile(buf, namespace, path)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.Equal(len(bundleFile.Services), 2))
}

Просмотреть файл

@ -56,7 +56,7 @@ func TestValidateExternalNetworks(t *testing.T) {
networks := []string{testcase.network}
err := validateExternalNetworks(context.Background(), fakeClient, networks)
if testcase.expectedMsg == "" {
assert.Check(t, err)
assert.NilError(t, err)
} else {
assert.ErrorContains(t, err, testcase.expectedMsg)
}

Просмотреть файл

@ -94,7 +94,7 @@ func TestServiceUpdateResolveImageChanged(t *testing.T) {
},
}
err := deployServices(ctx, client, spec, namespace, false, ResolveImageChanged)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.Equal(testcase.expectedQueryRegistry, receivedOptions.QueryRegistry))
assert.Check(t, is.Equal(testcase.expectedImage, receivedService.TaskTemplate.ContainerSpec.Image))

Просмотреть файл

@ -40,7 +40,7 @@ func TestDisplayTrustRootNoRoot(t *testing.T) {
func TestDisplayTrustRootInvalidFlags(t *testing.T) {
// we need an actual PEMfile to test
tmpfile, err := ioutil.TempFile("", "pemfile")
assert.Check(t, err)
assert.NilError(t, err)
defer os.Remove(tmpfile.Name())
tmpfile.Write([]byte(`
-----BEGIN CERTIFICATE-----

Просмотреть файл

@ -24,7 +24,7 @@ func TestTaskPrintWithQuietOption(t *testing.T) {
cli := test.NewFakeCli(apiClient)
tasks := []swarm.Task{*Task(TaskID("id-foo"))}
err := Print(context.Background(), cli, tasks, idresolver.New(apiClient, noResolve), trunc, quiet, formatter.TableFormatKey)
assert.Check(t, err)
assert.NilError(t, err)
golden.Assert(t, cli.OutBuffer().String(), "task-print-with-quiet-option.golden")
}
@ -38,7 +38,7 @@ func TestTaskPrintWithNoTruncOption(t *testing.T) {
*Task(TaskID("id-foo-yov6omdek8fg3k5stosyp2m50")),
}
err := Print(context.Background(), cli, tasks, idresolver.New(apiClient, noResolve), trunc, quiet, "{{ .ID }}")
assert.Check(t, err)
assert.NilError(t, err)
golden.Assert(t, cli.OutBuffer().String(), "task-print-with-no-trunc-option.golden")
}
@ -52,7 +52,7 @@ func TestTaskPrintWithGlobalService(t *testing.T) {
*Task(TaskServiceID("service-id-foo"), TaskNodeID("node-id-bar"), TaskSlot(0)),
}
err := Print(context.Background(), cli, tasks, idresolver.New(apiClient, noResolve), trunc, quiet, "{{ .Name }}")
assert.Check(t, err)
assert.NilError(t, err)
golden.Assert(t, cli.OutBuffer().String(), "task-print-with-global-service.golden")
}
@ -66,7 +66,7 @@ func TestTaskPrintWithReplicatedService(t *testing.T) {
*Task(TaskServiceID("service-id-foo"), TaskSlot(1)),
}
err := Print(context.Background(), cli, tasks, idresolver.New(apiClient, noResolve), trunc, quiet, "{{ .Name }}")
assert.Check(t, err)
assert.NilError(t, err)
golden.Assert(t, cli.OutBuffer().String(), "task-print-with-replicated-service.golden")
}
@ -102,7 +102,7 @@ func TestTaskPrintWithIndentation(t *testing.T) {
),
}
err := Print(context.Background(), cli, tasks, idresolver.New(apiClient, noResolve), trunc, quiet, formatter.TableFormatKey)
assert.Check(t, err)
assert.NilError(t, err)
golden.Assert(t, cli.OutBuffer().String(), "task-print-with-indentation.golden")
}
@ -123,6 +123,6 @@ func TestTaskPrintWithResolution(t *testing.T) {
*Task(TaskServiceID("service-id-foo"), TaskSlot(1)),
}
err := Print(context.Background(), cli, tasks, idresolver.New(apiClient, noResolve), trunc, quiet, "{{ .Name }} {{ .Node }}")
assert.Check(t, err)
assert.NilError(t, err)
golden.Assert(t, cli.OutBuffer().String(), "task-print-with-resolution.golden")
}

Просмотреть файл

@ -14,11 +14,11 @@ import (
func TestGetOrGenerateNotaryKeyAndInitRepo(t *testing.T) {
tmpDir, err := ioutil.TempDir("", "notary-test-")
assert.Check(t, err)
assert.NilError(t, err)
defer os.RemoveAll(tmpDir)
notaryRepo, err := client.NewFileCachedRepository(tmpDir, "gun", "https://localhost", nil, passphrase.ConstantRetriever(passwd), trustpinning.TrustPinConfig{})
assert.Check(t, err)
assert.NilError(t, err)
err = getOrGenerateRootKeyAndInitRepo(notaryRepo)
assert.Check(t, is.Error(err, "client is offline"))

Просмотреть файл

@ -36,7 +36,7 @@ func TestTrustKeyGenerateErrors(t *testing.T) {
}
tmpDir, err := ioutil.TempDir("", "docker-key-generate-test-")
assert.Check(t, err)
assert.NilError(t, err)
defer os.RemoveAll(tmpDir)
config.SetDir(tmpDir)
@ -51,11 +51,11 @@ func TestTrustKeyGenerateErrors(t *testing.T) {
func TestGenerateKeySuccess(t *testing.T) {
pubKeyCWD, err := ioutil.TempDir("", "pub-keys-")
assert.Check(t, err)
assert.NilError(t, err)
defer os.RemoveAll(pubKeyCWD)
privKeyStorageDir, err := ioutil.TempDir("", "priv-keys-")
assert.Check(t, err)
assert.NilError(t, err)
defer os.RemoveAll(privKeyStorageDir)
passwd := "password"
@ -63,10 +63,10 @@ func TestGenerateKeySuccess(t *testing.T) {
// generate a single key
keyName := "alice"
privKeyFileStore, err := trustmanager.NewKeyFileStore(privKeyStorageDir, cannedPasswordRetriever)
assert.Check(t, err)
assert.NilError(t, err)
pubKeyPEM, err := generateKeyAndOutputPubPEM(keyName, privKeyFileStore)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.Equal(keyName, pubKeyPEM.Headers["role"]))
// the default GUN is empty
@ -77,10 +77,10 @@ func TestGenerateKeySuccess(t *testing.T) {
// check that an appropriate ~/<trust_dir>/private/<key_id>.key file exists
expectedPrivKeyDir := filepath.Join(privKeyStorageDir, notary.PrivDir)
_, err = os.Stat(expectedPrivKeyDir)
assert.Check(t, err)
assert.NilError(t, err)
keyFiles, err := ioutil.ReadDir(expectedPrivKeyDir)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.Len(keyFiles, 1))
privKeyFilePath := filepath.Join(expectedPrivKeyDir, keyFiles[0].Name())
@ -96,28 +96,28 @@ func TestGenerateKeySuccess(t *testing.T) {
assert.Check(t, is.Equal("ENCRYPTED PRIVATE KEY", privKeyPEM.Type))
// check that the passphrase matches
_, err = tufutils.ParsePKCS8ToTufKey(privKeyPEM.Bytes, []byte(passwd))
assert.Check(t, err)
assert.NilError(t, err)
// check that the public key exists at the correct path if we use the helper:
returnedPath, err := writePubKeyPEMToDir(pubKeyPEM, keyName, pubKeyCWD)
assert.Check(t, err)
assert.NilError(t, err)
expectedPubKeyPath := filepath.Join(pubKeyCWD, keyName+".pub")
assert.Check(t, is.Equal(returnedPath, expectedPubKeyPath))
_, err = os.Stat(expectedPubKeyPath)
assert.Check(t, err)
assert.NilError(t, err)
// check that the public key is the only file output in CWD
cwdKeyFiles, err := ioutil.ReadDir(pubKeyCWD)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.Len(cwdKeyFiles, 1))
}
func TestValidateKeyArgs(t *testing.T) {
pubKeyCWD, err := ioutil.TempDir("", "pub-keys-")
assert.Check(t, err)
assert.NilError(t, err)
defer os.RemoveAll(pubKeyCWD)
err = validateKeyArgs("a", pubKeyCWD)
assert.Check(t, err)
assert.NilError(t, err)
err = validateKeyArgs("a/b", pubKeyCWD)
assert.Error(t, err, "key name \"a/b\" must start with lowercase alphanumeric characters and can include \"-\" or \"_\" after the first character")

Просмотреть файл

@ -51,7 +51,7 @@ func TestTrustKeyLoadErrors(t *testing.T) {
},
}
tmpDir, err := ioutil.TempDir("", "docker-key-load-test-")
assert.Check(t, err)
assert.NilError(t, err)
defer os.RemoveAll(tmpDir)
config.SetDir(tmpDir)
@ -118,24 +118,24 @@ func TestLoadKeyFromPath(t *testing.T) {
func testLoadKeyFromPath(t *testing.T, privKeyID string, privKeyFixture []byte) {
privKeyDir, err := ioutil.TempDir("", "key-load-test-")
assert.Check(t, err)
assert.NilError(t, err)
defer os.RemoveAll(privKeyDir)
privKeyFilepath := filepath.Join(privKeyDir, "privkey.pem")
assert.Check(t, ioutil.WriteFile(privKeyFilepath, privKeyFixture, notary.PrivNoExecPerms))
keyStorageDir, err := ioutil.TempDir("", "loaded-keys-")
assert.Check(t, err)
assert.NilError(t, err)
defer os.RemoveAll(keyStorageDir)
passwd := "password"
cannedPasswordRetriever := passphrase.ConstantRetriever(passwd)
keyFileStore, err := storage.NewPrivateKeyFileStorage(keyStorageDir, notary.KeyExtension)
assert.Check(t, err)
assert.NilError(t, err)
privKeyImporters := []trustmanager.Importer{keyFileStore}
// get the privKeyBytes
privKeyBytes, err := getPrivKeyBytesFromPath(privKeyFilepath)
assert.Check(t, err)
assert.NilError(t, err)
// import the key to our keyStorageDir
assert.Check(t, loadPrivKeyBytesToStore(privKeyBytes, privKeyImporters, privKeyFilepath, "signer-name", cannedPasswordRetriever))
@ -143,7 +143,7 @@ func testLoadKeyFromPath(t *testing.T, privKeyID string, privKeyFixture []byte)
// check that the appropriate ~/<trust_dir>/private/<key_id>.key file exists
expectedImportKeyPath := filepath.Join(keyStorageDir, notary.PrivDir, privKeyID+"."+notary.KeyExtension)
_, err = os.Stat(expectedImportKeyPath)
assert.Check(t, err)
assert.NilError(t, err)
// verify the key content
from, _ := os.OpenFile(expectedImportKeyPath, os.O_RDONLY, notary.PrivExecPerms)
@ -157,7 +157,7 @@ func testLoadKeyFromPath(t *testing.T, privKeyID string, privKeyFixture []byte)
assert.Check(t, is.Equal("ENCRYPTED PRIVATE KEY", keyPEM.Type))
decryptedKey, err := tufutils.ParsePKCS8ToTufKey(keyPEM.Bytes, []byte(passwd))
assert.Check(t, err)
assert.NilError(t, err)
fixturePEM, _ := pem.Decode(privKeyFixture)
assert.Check(t, is.DeepEqual(fixturePEM.Bytes, decryptedKey.Private()))
}
@ -172,13 +172,13 @@ func TestLoadKeyTooPermissive(t *testing.T) {
func testLoadKeyTooPermissive(t *testing.T, privKeyFixture []byte) {
privKeyDir, err := ioutil.TempDir("", "key-load-test-")
assert.Check(t, err)
assert.NilError(t, err)
defer os.RemoveAll(privKeyDir)
privKeyFilepath := filepath.Join(privKeyDir, "privkey477.pem")
assert.Check(t, ioutil.WriteFile(privKeyFilepath, privKeyFixture, 0477))
keyStorageDir, err := ioutil.TempDir("", "loaded-keys-")
assert.Check(t, err)
assert.NilError(t, err)
defer os.RemoveAll(keyStorageDir)
// import the key to our keyStorageDir
@ -204,13 +204,13 @@ func testLoadKeyTooPermissive(t *testing.T, privKeyFixture []byte) {
assert.Check(t, ioutil.WriteFile(privKeyFilepath, privKeyFixture, 0400))
_, err = getPrivKeyBytesFromPath(privKeyFilepath)
assert.Check(t, err)
assert.NilError(t, err)
privKeyFilepath = filepath.Join(privKeyDir, "privkey600.pem")
assert.Check(t, ioutil.WriteFile(privKeyFilepath, privKeyFixture, 0600))
_, err = getPrivKeyBytesFromPath(privKeyFilepath)
assert.Check(t, err)
assert.NilError(t, err)
}
var pubKeyFixture = []byte(`-----BEGIN PUBLIC KEY-----
@ -220,22 +220,22 @@ H3nzy2O6Q/ct4BjOBKa+WCdRtPo78bA+C/7t81ADQO8Jqaj59W50rwoqDQ==
func TestLoadPubKeyFailure(t *testing.T) {
pubKeyDir, err := ioutil.TempDir("", "key-load-test-pubkey-")
assert.Check(t, err)
assert.NilError(t, err)
defer os.RemoveAll(pubKeyDir)
pubKeyFilepath := filepath.Join(pubKeyDir, "pubkey.pem")
assert.Check(t, ioutil.WriteFile(pubKeyFilepath, pubKeyFixture, notary.PrivNoExecPerms))
keyStorageDir, err := ioutil.TempDir("", "loaded-keys-")
assert.Check(t, err)
assert.NilError(t, err)
defer os.RemoveAll(keyStorageDir)
passwd := "password"
cannedPasswordRetriever := passphrase.ConstantRetriever(passwd)
keyFileStore, err := storage.NewPrivateKeyFileStorage(keyStorageDir, notary.KeyExtension)
assert.Check(t, err)
assert.NilError(t, err)
privKeyImporters := []trustmanager.Importer{keyFileStore}
pubKeyBytes, err := getPrivKeyBytesFromPath(pubKeyFilepath)
assert.Check(t, err)
assert.NilError(t, err)
// import the key to our keyStorageDir - it should fail
err = loadPrivKeyBytesToStore(pubKeyBytes, privKeyImporters, pubKeyFilepath, "signer-name", cannedPasswordRetriever)

Просмотреть файл

@ -136,7 +136,7 @@ func TestNewRevokeTrustAllSigConfirmation(t *testing.T) {
func TestGetSignableRolesForTargetAndRemoveError(t *testing.T) {
tmpDir, err := ioutil.TempDir("", "notary-test-")
assert.Check(t, err)
assert.NilError(t, err)
defer os.RemoveAll(tmpDir)
notaryRepo, err := client.NewFileCachedRepository(tmpDir, "gun", "https://localhost", nil, passphrase.ConstantRetriever("password"), trustpinning.TrustPinConfig{})

Просмотреть файл

@ -60,7 +60,7 @@ func TestTrustSignCommandErrors(t *testing.T) {
}
// change to a tmpdir
tmpDir, err := ioutil.TempDir("", "docker-sign-test-")
assert.Check(t, err)
assert.NilError(t, err)
defer os.RemoveAll(tmpDir)
config.SetDir(tmpDir)
for _, tc := range testCases {
@ -83,15 +83,15 @@ func TestTrustSignCommandOfflineErrors(t *testing.T) {
func TestGetOrGenerateNotaryKey(t *testing.T) {
tmpDir, err := ioutil.TempDir("", "notary-test-")
assert.Check(t, err)
assert.NilError(t, err)
defer os.RemoveAll(tmpDir)
notaryRepo, err := client.NewFileCachedRepository(tmpDir, "gun", "https://localhost", nil, passphrase.ConstantRetriever(passwd), trustpinning.TrustPinConfig{})
assert.Check(t, err)
assert.NilError(t, err)
// repo is empty, try making a root key
rootKeyA, err := getOrGenerateNotaryKey(notaryRepo, data.CanonicalRootRole)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, rootKeyA != nil)
// we should only have one newly generated key
@ -101,7 +101,7 @@ func TestGetOrGenerateNotaryKey(t *testing.T) {
// this time we should get back the same key if we ask for another root key
rootKeyB, err := getOrGenerateNotaryKey(notaryRepo, data.CanonicalRootRole)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, rootKeyB != nil)
// we should only have one newly generated key
@ -114,7 +114,7 @@ func TestGetOrGenerateNotaryKey(t *testing.T) {
// Now also try with a delegation key
releasesKey, err := getOrGenerateNotaryKey(notaryRepo, data.RoleName(trust.ReleasesRole))
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, releasesKey != nil)
// we should now have two keys
@ -128,20 +128,20 @@ func TestGetOrGenerateNotaryKey(t *testing.T) {
func TestAddStageSigners(t *testing.T) {
tmpDir, err := ioutil.TempDir("", "notary-test-")
assert.Check(t, err)
assert.NilError(t, err)
defer os.RemoveAll(tmpDir)
notaryRepo, err := client.NewFileCachedRepository(tmpDir, "gun", "https://localhost", nil, passphrase.ConstantRetriever(passwd), trustpinning.TrustPinConfig{})
assert.Check(t, err)
assert.NilError(t, err)
// stage targets/user
userRole := data.RoleName("targets/user")
userKey := data.NewPublicKey("algoA", []byte("a"))
err = addStagedSigner(notaryRepo, userRole, []data.PublicKey{userKey})
assert.Check(t, err)
assert.NilError(t, err)
// check the changelist for four total changes: two on targets/releases and two on targets/user
cl, err := notaryRepo.GetChangelist()
assert.Check(t, err)
assert.NilError(t, err)
changeList := cl.List()
assert.Check(t, is.Len(changeList, 4))
// ordering is determinstic:
@ -213,11 +213,11 @@ func TestAddStageSigners(t *testing.T) {
func TestGetSignedManifestHashAndSize(t *testing.T) {
tmpDir, err := ioutil.TempDir("", "notary-test-")
assert.Check(t, err)
assert.NilError(t, err)
defer os.RemoveAll(tmpDir)
notaryRepo, err := client.NewFileCachedRepository(tmpDir, "gun", "https://localhost", nil, passphrase.ConstantRetriever(passwd), trustpinning.TrustPinConfig{})
assert.Check(t, err)
assert.NilError(t, err)
target := &client.Target{}
target.Hashes, target.Length, err = getSignedManifestHashAndSize(notaryRepo, "test")
assert.Check(t, is.Error(err, "client is offline"))
@ -241,11 +241,11 @@ func TestGetReleasedTargetHashAndSize(t *testing.T) {
func TestCreateTarget(t *testing.T) {
tmpDir, err := ioutil.TempDir("", "notary-test-")
assert.Check(t, err)
assert.NilError(t, err)
defer os.RemoveAll(tmpDir)
notaryRepo, err := client.NewFileCachedRepository(tmpDir, "gun", "https://localhost", nil, passphrase.ConstantRetriever(passwd), trustpinning.TrustPinConfig{})
assert.Check(t, err)
assert.NilError(t, err)
_, err = createTarget(notaryRepo, "")
assert.Check(t, is.Error(err, "No tag specified"))
_, err = createTarget(notaryRepo, "1")
@ -254,11 +254,11 @@ func TestCreateTarget(t *testing.T) {
func TestGetExistingSignatureInfoForReleasedTag(t *testing.T) {
tmpDir, err := ioutil.TempDir("", "notary-test-")
assert.Check(t, err)
assert.NilError(t, err)
defer os.RemoveAll(tmpDir)
notaryRepo, err := client.NewFileCachedRepository(tmpDir, "gun", "https://localhost", nil, passphrase.ConstantRetriever(passwd), trustpinning.TrustPinConfig{})
assert.Check(t, err)
assert.NilError(t, err)
_, err = getExistingSignatureInfoForReleasedTag(notaryRepo, "test")
assert.Check(t, is.Error(err, "client is offline"))
}
@ -274,7 +274,7 @@ func TestPrettyPrintExistingSignatureInfo(t *testing.T) {
func TestSignCommandChangeListIsCleanedOnError(t *testing.T) {
tmpDir, err := ioutil.TempDir("", "docker-sign-test-")
assert.Check(t, err)
assert.NilError(t, err)
defer os.RemoveAll(tmpDir)
config.SetDir(tmpDir)
@ -288,7 +288,7 @@ func TestSignCommandChangeListIsCleanedOnError(t *testing.T) {
assert.Assert(t, is.ErrorContains(err, ""))
notaryRepo, err := client.NewFileCachedRepository(tmpDir, "docker.io/library/ubuntu", "https://localhost", nil, passphrase.ConstantRetriever(passwd), trustpinning.TrustPinConfig{})
assert.Check(t, err)
assert.NilError(t, err)
cl, err := notaryRepo.GetChangelist()
assert.NilError(t, err)
assert.Check(t, is.Equal(len(cl.List()), 0))

Просмотреть файл

@ -51,7 +51,7 @@ func TestTrustSignerAddErrors(t *testing.T) {
},
}
tmpDir, err := ioutil.TempDir("", "docker-sign-test-")
assert.Check(t, err)
assert.NilError(t, err)
defer os.RemoveAll(tmpDir)
config.SetDir(tmpDir)
@ -67,12 +67,12 @@ func TestTrustSignerAddErrors(t *testing.T) {
func TestSignerAddCommandNoTargetsKey(t *testing.T) {
tmpDir, err := ioutil.TempDir("", "docker-sign-test-")
assert.Check(t, err)
assert.NilError(t, err)
defer os.RemoveAll(tmpDir)
config.SetDir(tmpDir)
tmpfile, err := ioutil.TempFile("", "pemfile")
assert.Check(t, err)
assert.NilError(t, err)
defer os.Remove(tmpfile.Name())
cli := test.NewFakeCli(&fakeClient{})
@ -86,7 +86,7 @@ func TestSignerAddCommandNoTargetsKey(t *testing.T) {
func TestSignerAddCommandBadKeyPath(t *testing.T) {
tmpDir, err := ioutil.TempDir("", "docker-sign-test-")
assert.Check(t, err)
assert.NilError(t, err)
defer os.RemoveAll(tmpDir)
config.SetDir(tmpDir)
@ -101,12 +101,12 @@ func TestSignerAddCommandBadKeyPath(t *testing.T) {
func TestSignerAddCommandInvalidRepoName(t *testing.T) {
tmpDir, err := ioutil.TempDir("", "docker-sign-test-")
assert.Check(t, err)
assert.NilError(t, err)
defer os.RemoveAll(tmpDir)
config.SetDir(tmpDir)
pubKeyDir, err := ioutil.TempDir("", "key-load-test-pubkey-")
assert.Check(t, err)
assert.NilError(t, err)
defer os.RemoveAll(pubKeyDir)
pubKeyFilepath := filepath.Join(pubKeyDir, "pubkey.pem")
assert.Check(t, ioutil.WriteFile(pubKeyFilepath, pubKeyFixture, notary.PrivNoExecPerms))
@ -130,7 +130,7 @@ func TestIngestPublicKeys(t *testing.T) {
assert.Check(t, is.Error(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.Check(t, err)
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())))

Просмотреть файл

@ -90,7 +90,7 @@ func TestRemoveLastSignerWarning(t *testing.T) {
cli.SetNotaryClient(getLoadedNotaryRepository)
err := removeSigner(cli, signerRemoveOptions{signer: "alice", repos: []string{"signed-repo"}, forceYes: false})
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.Contains(cli.OutBuffer().String(),
"The signer \"alice\" signed the last released version of signed-repo. "+
"Removing this signer will make signed-repo unpullable. "+

Просмотреть файл

@ -121,7 +121,7 @@ func TestSecrets(t *testing.T) {
}
specs, err := Secrets(namespace, source)
assert.Check(t, err)
assert.NilError(t, err)
assert.Assert(t, is.Len(specs, 1))
secret := specs[0]
assert.Check(t, is.Equal("foo_one", secret.Name))
@ -152,7 +152,7 @@ func TestConfigs(t *testing.T) {
}
specs, err := Configs(namespace, source)
assert.Check(t, err)
assert.NilError(t, err)
assert.Assert(t, is.Len(specs, 1))
config := specs[0]
assert.Check(t, is.Equal("foo_one", config.Name))

Просмотреть файл

@ -20,7 +20,7 @@ import (
func TestConvertRestartPolicyFromNone(t *testing.T) {
policy, err := convertRestartPolicy("no", nil)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual((*swarm.RestartPolicy)(nil), policy))
}
@ -34,7 +34,7 @@ func TestConvertRestartPolicyFromAlways(t *testing.T) {
expected := &swarm.RestartPolicy{
Condition: swarm.RestartPolicyConditionAny,
}
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(expected, policy))
}
@ -45,7 +45,7 @@ func TestConvertRestartPolicyFromFailure(t *testing.T) {
Condition: swarm.RestartPolicyConditionOnFailure,
MaxAttempts: &attempts,
}
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(expected, policy))
}
@ -84,7 +84,7 @@ func TestConvertResourcesFull(t *testing.T) {
},
}
resources, err := convertResources(source)
assert.Check(t, err)
assert.NilError(t, err)
expected := &swarm.ResourceRequirements{
Limits: &swarm.Resources{
@ -109,7 +109,7 @@ func TestConvertResourcesOnlyMemory(t *testing.T) {
},
}
resources, err := convertResources(source)
assert.Check(t, err)
assert.NilError(t, err)
expected := &swarm.ResourceRequirements{
Limits: &swarm.Resources{
@ -140,7 +140,7 @@ func TestConvertHealthcheck(t *testing.T) {
}
healthcheck, err := convertHealthcheck(source)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(expected, healthcheck))
}
@ -151,7 +151,7 @@ func TestConvertHealthcheckDisable(t *testing.T) {
}
healthcheck, err := convertHealthcheck(source)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(expected, healthcheck))
}
@ -195,7 +195,7 @@ func TestConvertEndpointSpec(t *testing.T) {
},
}
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(expected, *endpoint))
}
@ -212,7 +212,7 @@ func TestConvertServiceNetworksOnlyDefault(t *testing.T) {
},
}
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(expected, configs))
}
@ -250,7 +250,7 @@ func TestConvertServiceNetworks(t *testing.T) {
sortedConfigs := byTargetSort(configs)
sort.Sort(&sortedConfigs)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(expected, []swarm.NetworkAttachmentConfig(sortedConfigs)))
}
@ -273,7 +273,7 @@ func TestConvertServiceNetworksCustomDefault(t *testing.T) {
},
}
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(expected, []swarm.NetworkAttachmentConfig(configs)))
}
@ -294,7 +294,7 @@ func (s byTargetSort) Swap(i, j int) {
func TestConvertDNSConfigEmpty(t *testing.T) {
dnsConfig, err := convertDNSConfig(nil, nil)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual((*swarm.DNSConfig)(nil), dnsConfig))
}
@ -305,7 +305,7 @@ var (
func TestConvertDNSConfigAll(t *testing.T) {
dnsConfig, err := convertDNSConfig(nameservers, search)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(&swarm.DNSConfig{
Nameservers: nameservers,
Search: search,
@ -314,7 +314,7 @@ func TestConvertDNSConfigAll(t *testing.T) {
func TestConvertDNSConfigNameservers(t *testing.T) {
dnsConfig, err := convertDNSConfig(nameservers, nil)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(&swarm.DNSConfig{
Nameservers: nameservers,
Search: nil,
@ -323,7 +323,7 @@ func TestConvertDNSConfigNameservers(t *testing.T) {
func TestConvertDNSConfigSearch(t *testing.T) {
dnsConfig, err := convertDNSConfig(nil, search)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(&swarm.DNSConfig{
Nameservers: nil,
Search: search,
@ -332,20 +332,20 @@ func TestConvertDNSConfigSearch(t *testing.T) {
func TestConvertCredentialSpec(t *testing.T) {
swarmSpec, err := convertCredentialSpec(composetypes.CredentialSpecConfig{})
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.Nil(swarmSpec))
swarmSpec, err = convertCredentialSpec(composetypes.CredentialSpecConfig{
File: "/foo",
})
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.Equal(swarmSpec.File, "/foo"))
assert.Check(t, is.Equal(swarmSpec.Registry, ""))
swarmSpec, err = convertCredentialSpec(composetypes.CredentialSpecConfig{
Registry: "foo",
})
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.Equal(swarmSpec.File, ""))
assert.Check(t, is.Equal(swarmSpec.Registry, "foo"))

Просмотреть файл

@ -19,7 +19,7 @@ func TestConvertVolumeToMountAnonymousVolume(t *testing.T) {
Target: "/foo/bar",
}
mount, err := convertVolumeToMount(config, volumes{}, NewNamespace("foo"))
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(expected, mount))
}
@ -174,7 +174,7 @@ func TestConvertVolumeToMountNamedVolume(t *testing.T) {
},
}
mount, err := convertVolumeToMount(config, stackVolumes, namespace)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(expected, mount))
}
@ -221,7 +221,7 @@ func TestConvertVolumeToMountNamedVolumeWithNameCustomizd(t *testing.T) {
},
}
mount, err := convertVolumeToMount(config, stackVolumes, namespace)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(expected, mount))
}
@ -245,7 +245,7 @@ func TestConvertVolumeToMountNamedVolumeExternal(t *testing.T) {
Target: "/foo",
}
mount, err := convertVolumeToMount(config, stackVolumes, namespace)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(expected, mount))
}
@ -274,7 +274,7 @@ func TestConvertVolumeToMountNamedVolumeExternalNoCopy(t *testing.T) {
},
}
mount, err := convertVolumeToMount(config, stackVolumes, namespace)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(expected, mount))
}
@ -296,7 +296,7 @@ func TestConvertVolumeToMountBind(t *testing.T) {
Bind: &composetypes.ServiceVolumeBind{Propagation: "shared"},
}
mount, err := convertVolumeToMount(config, stackVolumes, namespace)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(expected, mount))
}
@ -326,7 +326,7 @@ func TestConvertTmpfsToMountVolume(t *testing.T) {
TmpfsOptions: &mount.TmpfsOptions{SizeBytes: 1000},
}
mount, err := convertVolumeToMount(config, volumes{}, NewNamespace("foo"))
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(expected, mount))
}

Просмотреть файл

@ -47,7 +47,7 @@ func TestInterpolate(t *testing.T) {
},
}
result, err := Interpolate(services, Options{LookupValue: defaultMapping})
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(expected, result))
}
@ -75,7 +75,7 @@ func TestInterpolateWithDefaults(t *testing.T) {
},
}
result, err := Interpolate(config, Options{})
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(expected, result))
}
@ -92,7 +92,7 @@ func TestInterpolateWithCast(t *testing.T) {
LookupValue: defaultMapping,
TypeCastMapping: map[Path]Cast{NewPath(PathMatchAll, "replicas"): toInt},
})
assert.Check(t, err)
assert.NilError(t, err)
expected := map[string]interface{}{
"foo": map[string]interface{}{
"replicas": 5,

Просмотреть файл

@ -410,7 +410,7 @@ services:
- QUX=
- QUUX
`, map[string]string{"QUX": "qux"})
assert.Check(t, err)
assert.NilError(t, err)
expected := types.MappingWithEquals{
"FOO": strPtr("1"),

Просмотреть файл

@ -319,12 +319,12 @@ configs: {}
`
actual, err := yaml.Marshal(cfg)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.Equal(expected, string(actual)))
// Make sure the expected still
dict, err := ParseYAML([]byte("version: '3.6'\n" + expected))
assert.Check(t, err)
assert.NilError(t, err)
_, err = Load(buildConfigDetails(dict, map[string]string{}))
assert.Check(t, err)
assert.NilError(t, err)
}

Просмотреть файл

@ -13,7 +13,7 @@ func TestParseVolumeAnonymousVolume(t *testing.T) {
for _, path := range []string{"/path", "/path/foo"} {
volume, err := ParseVolume(path)
expected := types.ServiceVolumeConfig{Type: "volume", Target: path}
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(expected, volume))
}
}
@ -22,7 +22,7 @@ func TestParseVolumeAnonymousVolumeWindows(t *testing.T) {
for _, path := range []string{"C:\\path", "Z:\\path\\foo"} {
volume, err := ParseVolume(path)
expected := types.ServiceVolumeConfig{Type: "volume", Target: path}
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(expected, volume))
}
}
@ -36,7 +36,7 @@ func TestParseVolumeShortVolumes(t *testing.T) {
for _, path := range []string{".", "/a"} {
volume, err := ParseVolume(path)
expected := types.ServiceVolumeConfig{Type: "volume", Target: path}
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(expected, volume))
}
}
@ -56,7 +56,7 @@ func TestParseVolumeBindMount(t *testing.T) {
Source: path,
Target: "/target",
}
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(expected, volume))
}
}
@ -74,7 +74,7 @@ func TestParseVolumeRelativeBindMountWindows(t *testing.T) {
Source: path,
Target: "d:\\target",
}
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(expected, volume))
}
}
@ -87,7 +87,7 @@ func TestParseVolumeWithBindOptions(t *testing.T) {
Target: "/target",
Bind: &types.ServiceVolumeBind{Propagation: "slave"},
}
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(expected, volume))
}
@ -100,13 +100,13 @@ func TestParseVolumeWithBindOptionsWindows(t *testing.T) {
ReadOnly: true,
Bind: &types.ServiceVolumeBind{Propagation: "rprivate"},
}
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(expected, volume))
}
func TestParseVolumeWithInvalidVolumeOptions(t *testing.T) {
_, err := ParseVolume("name:/target:bogus")
assert.Check(t, err)
assert.NilError(t, err)
}
func TestParseVolumeWithVolumeOptions(t *testing.T) {
@ -117,7 +117,7 @@ func TestParseVolumeWithVolumeOptions(t *testing.T) {
Target: "/target",
Volume: &types.ServiceVolumeVolume{NoCopy: true},
}
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(expected, volume))
}
@ -130,7 +130,7 @@ func TestParseVolumeWithReadOnly(t *testing.T) {
Target: "/target",
ReadOnly: true,
}
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(expected, volume))
}
}
@ -144,7 +144,7 @@ func TestParseVolumeWithRW(t *testing.T) {
Target: "/target",
ReadOnly: false,
}
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(expected, volume))
}
}

Просмотреть файл

@ -42,7 +42,7 @@ func TestValidateAllowsXTopLevelFields(t *testing.T) {
}
err := Validate(config, "3.4")
assert.Check(t, err)
assert.NilError(t, err)
}
func TestValidateSecretConfigNames(t *testing.T) {
@ -61,7 +61,7 @@ func TestValidateSecretConfigNames(t *testing.T) {
}
err := Validate(config, "3.5")
assert.Check(t, err)
assert.NilError(t, err)
}
func TestValidateInvalidVersion(t *testing.T) {

Просмотреть файл

@ -20,7 +20,7 @@ func defaultMapping(name string) (string, bool) {
func TestEscaped(t *testing.T) {
result, err := Substitute("$${foo}", defaultMapping)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.Equal("${foo}", result))
}
@ -50,7 +50,7 @@ func TestInvalid(t *testing.T) {
func TestNoValueNoDefault(t *testing.T) {
for _, template := range []string{"This ${missing} var", "This ${BAR} var"} {
result, err := Substitute(template, defaultMapping)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.Equal("This var", result))
}
}
@ -58,7 +58,7 @@ func TestNoValueNoDefault(t *testing.T) {
func TestValueNoDefault(t *testing.T) {
for _, template := range []string{"This $FOO var", "This ${FOO} var"} {
result, err := Substitute(template, defaultMapping)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.Equal("This first var", result))
}
}
@ -66,26 +66,26 @@ func TestValueNoDefault(t *testing.T) {
func TestNoValueWithDefault(t *testing.T) {
for _, template := range []string{"ok ${missing:-def}", "ok ${missing-def}"} {
result, err := Substitute(template, defaultMapping)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.Equal("ok def", result))
}
}
func TestEmptyValueWithSoftDefault(t *testing.T) {
result, err := Substitute("ok ${BAR:-def}", defaultMapping)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.Equal("ok def", result))
}
func TestEmptyValueWithHardDefault(t *testing.T) {
result, err := Substitute("ok ${BAR-def}", defaultMapping)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.Equal("ok ", result))
}
func TestNonAlphanumericDefault(t *testing.T) {
result, err := Substitute("ok ${BAR:-/non:-alphanumeric}", defaultMapping)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.Equal("ok /non:-alphanumeric", result))
}
@ -144,7 +144,7 @@ func TestDefaultsForMandatoryVariables(t *testing.T) {
for _, tc := range testCases {
result, err := Substitute(tc.template, defaultMapping)
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.Equal(tc.expected, result))
}
}

Просмотреть файл

@ -227,7 +227,7 @@ func TestNativeStoreGetMissingCredentials(t *testing.T) {
fileStore: NewFileStore(f),
}
_, err := s.Get(missingCredsAddress)
assert.Check(t, err)
assert.NilError(t, err)
}
func TestNativeStoreGetInvalidAddress(t *testing.T) {

Просмотреть файл

@ -20,7 +20,7 @@ func TestCommonOptionsInstallFlags(t *testing.T) {
"--tlscert=\"/foo/cert\"",
"--tlskey=\"/foo/key\"",
})
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.Equal("/foo/cafile", opts.TLSOptions.CAFile))
assert.Check(t, is.Equal("/foo/cert", opts.TLSOptions.CertFile))
assert.Check(t, is.Equal(opts.TLSOptions.KeyFile, "/foo/key"))
@ -36,7 +36,7 @@ func TestCommonOptionsInstallFlagsWithDefaults(t *testing.T) {
opts.InstallFlags(flags)
err := flags.Parse([]string{})
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.Equal(defaultPath("ca.pem"), opts.TLSOptions.CAFile))
assert.Check(t, is.Equal(defaultPath("cert.pem"), opts.TLSOptions.CertFile))
assert.Check(t, is.Equal(defaultPath("key.pem"), opts.TLSOptions.KeyFile))

Просмотреть файл

@ -16,41 +16,41 @@ import (
func TestGetTag(t *testing.T) {
ref, err := reference.ParseNormalizedNamed("ubuntu@sha256:45b23dee08af5e43a7fea6c4cf9c25ccf269ee113168c19722f87876677c5cb2")
assert.Check(t, err)
assert.NilError(t, err)
tag := getTag(ref)
assert.Check(t, is.Equal("", tag))
ref, err = reference.ParseNormalizedNamed("alpine:latest")
assert.Check(t, err)
assert.NilError(t, err)
tag = getTag(ref)
assert.Check(t, is.Equal(tag, "latest"))
ref, err = reference.ParseNormalizedNamed("alpine")
assert.Check(t, err)
assert.NilError(t, err)
tag = getTag(ref)
assert.Check(t, is.Equal(tag, ""))
}
func TestGetDigest(t *testing.T) {
ref, err := reference.ParseNormalizedNamed("ubuntu@sha256:45b23dee08af5e43a7fea6c4cf9c25ccf269ee113168c19722f87876677c5cb2")
assert.Check(t, err)
assert.NilError(t, err)
d := getDigest(ref)
assert.Check(t, is.Equal(digest.Digest("sha256:45b23dee08af5e43a7fea6c4cf9c25ccf269ee113168c19722f87876677c5cb2"), d))
ref, err = reference.ParseNormalizedNamed("alpine:latest")
assert.Check(t, err)
assert.NilError(t, err)
d = getDigest(ref)
assert.Check(t, is.Equal(digest.Digest(""), d))
ref, err = reference.ParseNormalizedNamed("alpine")
assert.Check(t, err)
assert.NilError(t, err)
d = getDigest(ref)
assert.Check(t, is.Equal(digest.Digest(""), d))
}
func TestGetSignableRolesError(t *testing.T) {
tmpDir, err := ioutil.TempDir("", "notary-test-")
assert.Check(t, err)
assert.NilError(t, err)
defer os.RemoveAll(tmpDir)
notaryRepo, err := client.NewFileCachedRepository(tmpDir, "gun", "https://localhost", nil, passphrase.ConstantRetriever("password"), trustpinning.TrustPinConfig{})

Просмотреть файл

@ -19,7 +19,7 @@ func TestClientDebugEnabled(t *testing.T) {
cmd.Flags().Set("debug", "true")
err := cmd.PersistentPreRunE(cmd, []string{})
assert.Check(t, err)
assert.NilError(t, err)
assert.Check(t, is.Equal("1", os.Getenv("DEBUG")))
assert.Check(t, is.Equal(logrus.DebugLevel, logrus.GetLevel()))
}

Просмотреть файл

@ -11,7 +11,7 @@ import (
// GitHub #32120
func TestParseJSONFunctions(t *testing.T) {
tm, err := Parse(`{{json .Ports}}`)
assert.Check(t, err)
assert.NilError(t, err)
var b bytes.Buffer
assert.Check(t, tm.Execute(&b, map[string]string{"Ports": "0.0.0.0:2->8/udp"}))
@ -21,7 +21,7 @@ func TestParseJSONFunctions(t *testing.T) {
func TestParseStringFunctions(t *testing.T) {
tm, err := Parse(`{{join (split . ":") "/"}}`)
assert.Check(t, err)
assert.NilError(t, err)
var b bytes.Buffer
assert.Check(t, tm.Execute(&b, "text:with:colon"))
@ -31,7 +31,7 @@ func TestParseStringFunctions(t *testing.T) {
func TestNewParse(t *testing.T) {
tm, err := NewParse("foo", "this is a {{ . }}")
assert.Check(t, err)
assert.NilError(t, err)
var b bytes.Buffer
assert.Check(t, tm.Execute(&b, "string"))
@ -66,7 +66,7 @@ func TestParseTruncateFunction(t *testing.T) {
for _, testCase := range testCases {
tm, err := Parse(testCase.template)
assert.Check(t, err)
assert.NilError(t, err)
t.Run("Non Empty Source Test with template: "+testCase.template, func(t *testing.T) {
var b bytes.Buffer