本文整理汇总了Golang中github.com/docker/docker/integration-cli/checker.Not函数的典型用法代码示例。如果您正苦于以下问题:Golang Not函数的具体用法?Golang Not怎么用?Golang Not使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Not函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestAPIImagesSizeCompatibility
// Test case for 30027: image size reported as -1 in v1.12 client against v1.13 daemon.
// This test checks to make sure both v1.12 and v1.13 client against v1.13 daemon get correct `Size` after the fix.
func (s *DockerSuite) TestAPIImagesSizeCompatibility(c *check.C) {
status, b, err := request.SockRequest("GET", "/images/json", nil, daemonHost())
c.Assert(err, checker.IsNil)
c.Assert(status, checker.Equals, http.StatusOK)
var images []types.ImageSummary
err = json.Unmarshal(b, &images)
c.Assert(err, checker.IsNil)
c.Assert(len(images), checker.Not(checker.Equals), 0)
for _, image := range images {
c.Assert(image.Size, checker.Not(checker.Equals), int64(-1))
}
type v124Image struct {
ID string `json:"Id"`
ParentID string `json:"ParentId"`
RepoTags []string
RepoDigests []string
Created int64
Size int64
VirtualSize int64
Labels map[string]string
}
status, b, err = request.SockRequest("GET", "/v1.24/images/json", nil, daemonHost())
c.Assert(err, checker.IsNil)
c.Assert(status, checker.Equals, http.StatusOK)
var v124Images []v124Image
err = json.Unmarshal(b, &v124Images)
c.Assert(err, checker.IsNil)
c.Assert(len(v124Images), checker.Not(checker.Equals), 0)
for _, image := range v124Images {
c.Assert(image.Size, checker.Not(checker.Equals), int64(-1))
}
}
开发者ID:jwhonce,项目名称:docker,代码行数:35,代码来源:docker_api_images_test.go
示例2: TestLogsSinceFutureFollow
func (s *DockerSuite) TestLogsSinceFutureFollow(c *check.C) {
// TODO Windows TP5 - Figure out why this test is so flakey. Disabled for now.
testRequires(c, DaemonIsLinux)
name := "testlogssincefuturefollow"
out, _ := dockerCmd(c, "run", "-d", "--name", name, "busybox", "/bin/sh", "-c", `for i in $(seq 1 5); do echo log$i; sleep 1; done`)
// Extract one timestamp from the log file to give us a starting point for
// our `--since` argument. Because the log producer runs in the background,
// we need to check repeatedly for some output to be produced.
var timestamp string
for i := 0; i != 100 && timestamp == ""; i++ {
if out, _ = dockerCmd(c, "logs", "-t", name); out == "" {
time.Sleep(time.Millisecond * 100) // Retry
} else {
timestamp = strings.Split(strings.Split(out, "\n")[0], " ")[0]
}
}
c.Assert(timestamp, checker.Not(checker.Equals), "")
t, err := time.Parse(time.RFC3339Nano, timestamp)
c.Assert(err, check.IsNil)
since := t.Unix() + 2
out, _ = dockerCmd(c, "logs", "-t", "-f", fmt.Sprintf("--since=%v", since), name)
c.Assert(out, checker.Not(checker.HasLen), 0, check.Commentf("cannot read from empty log"))
lines := strings.Split(strings.TrimSpace(out), "\n")
for _, v := range lines {
ts, err := time.Parse(time.RFC3339Nano, strings.Split(v, " ")[0])
c.Assert(err, checker.IsNil, check.Commentf("cannot parse timestamp output from log: '%v'", v))
c.Assert(ts.Unix() >= since, checker.Equals, true, check.Commentf("earlier log found. since=%v logdate=%v", since, ts))
}
}
开发者ID:shakamunyi,项目名称:docker,代码行数:32,代码来源:docker_cli_logs_test.go
示例3: TestEventsFilterImageName
func (s *DockerSuite) TestEventsFilterImageName(c *check.C) {
since := daemonUnixTime(c)
out, _ := dockerCmd(c, "run", "--name", "container_1", "-d", "busybox:latest", "true")
container1 := strings.TrimSpace(out)
out, _ = dockerCmd(c, "run", "--name", "container_2", "-d", "busybox", "true")
container2 := strings.TrimSpace(out)
name := "busybox"
out, _ = dockerCmd(c, "events", "--since", since, "--until", daemonUnixTime(c), "--filter", fmt.Sprintf("image=%s", name))
events := strings.Split(out, "\n")
events = events[:len(events)-1]
c.Assert(events, checker.Not(checker.HasLen), 0) //Expected events but found none for the image busybox:latest
count1 := 0
count2 := 0
for _, e := range events {
if strings.Contains(e, container1) {
count1++
} else if strings.Contains(e, container2) {
count2++
}
}
c.Assert(count1, checker.Not(checker.Equals), 0, check.Commentf("Expected event from container but got %d from %s", count1, container1))
c.Assert(count2, checker.Not(checker.Equals), 0, check.Commentf("Expected event from container but got %d from %s", count2, container2))
}
开发者ID:docker,项目名称:docker,代码行数:28,代码来源:docker_cli_events_test.go
示例4: TestServiceCreateWithSecretSourceTarget
func (s *DockerSwarmSuite) TestServiceCreateWithSecretSourceTarget(c *check.C) {
d := s.AddDaemon(c, true, true)
serviceName := "test-service-secret"
testName := "test_secret"
id := d.CreateSecret(c, swarm.SecretSpec{
swarm.Annotations{
Name: testName,
},
[]byte("TESTINGDATA"),
})
c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("secrets: %s", id))
testTarget := "testing"
out, err := d.Cmd("service", "create", "--name", serviceName, "--secret", fmt.Sprintf("source=%s,target=%s", testName, testTarget), "busybox", "top")
c.Assert(err, checker.IsNil, check.Commentf(out))
out, err = d.Cmd("service", "inspect", "--format", "{{ json .Spec.TaskTemplate.ContainerSpec.Secrets }}", serviceName)
c.Assert(err, checker.IsNil)
var refs []swarm.SecretReference
c.Assert(json.Unmarshal([]byte(out), &refs), checker.IsNil)
c.Assert(refs, checker.HasLen, 1)
c.Assert(refs[0].SecretName, checker.Equals, testName)
c.Assert(refs[0].File, checker.Not(checker.IsNil))
c.Assert(refs[0].File.Name, checker.Equals, testTarget)
}
开发者ID:docker,项目名称:docker,代码行数:28,代码来源:docker_cli_service_create_test.go
示例5: TestSaveLoadNoTag
func (s *DockerSuite) TestSaveLoadNoTag(c *check.C) {
testRequires(c, DaemonIsLinux)
name := "saveloadnotag"
_, err := buildImage(name, "FROM busybox\nENV foo=bar", true)
c.Assert(err, checker.IsNil, check.Commentf("%v", err))
id := inspectField(c, name, "Id")
// Test to make sure that save w/o name just shows imageID during load
out, _, err := testutil.RunCommandPipelineWithOutput(
exec.Command(dockerBinary, "save", id),
exec.Command(dockerBinary, "load"))
c.Assert(err, checker.IsNil, check.Commentf("failed to save and load repo: %s, %v", out, err))
// Should not show 'name' but should show the image ID during the load
c.Assert(out, checker.Not(checker.Contains), "Loaded image: ")
c.Assert(out, checker.Contains, "Loaded image ID:")
c.Assert(out, checker.Contains, id)
// Test to make sure that save by name shows that name during load
out, _, err = testutil.RunCommandPipelineWithOutput(
exec.Command(dockerBinary, "save", name),
exec.Command(dockerBinary, "load"))
c.Assert(err, checker.IsNil, check.Commentf("failed to save and load repo: %s, %v", out, err))
c.Assert(out, checker.Contains, "Loaded image: "+name+":latest")
c.Assert(out, checker.Not(checker.Contains), "Loaded image ID:")
}
开发者ID:docker,项目名称:docker,代码行数:29,代码来源:docker_cli_save_load_test.go
示例6: TestPruneImageDangling
func (s *DockerDaemonSuite) TestPruneImageDangling(c *check.C) {
s.d.StartWithBusybox(c)
out, _, err := s.d.BuildImageWithOut("test",
`FROM busybox
LABEL foo=bar`, true, "-q")
c.Assert(err, checker.IsNil)
id := strings.TrimSpace(out)
out, err = s.d.Cmd("images", "-q", "--no-trunc")
c.Assert(err, checker.IsNil)
c.Assert(strings.TrimSpace(out), checker.Contains, id)
out, err = s.d.Cmd("image", "prune", "--force")
c.Assert(err, checker.IsNil)
c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), id)
out, err = s.d.Cmd("images", "-q", "--no-trunc")
c.Assert(err, checker.IsNil)
c.Assert(strings.TrimSpace(out), checker.Contains, id)
out, err = s.d.Cmd("image", "prune", "--force", "--all")
c.Assert(err, checker.IsNil)
c.Assert(strings.TrimSpace(out), checker.Contains, id)
out, err = s.d.Cmd("images", "-q", "--no-trunc")
c.Assert(err, checker.IsNil)
c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), id)
}
开发者ID:docker,项目名称:docker,代码行数:29,代码来源:docker_cli_prune_unix_test.go
示例7: TestSearchWithLimit
// test case for #23055
func (s *DockerSuite) TestSearchWithLimit(c *check.C) {
testRequires(c, Network, DaemonIsLinux)
limit := 10
out, _, err := dockerCmdWithError("search", fmt.Sprintf("--limit=%d", limit), "docker")
c.Assert(err, checker.IsNil)
outSlice := strings.Split(out, "\n")
c.Assert(outSlice, checker.HasLen, limit+2) // 1 header, 1 carriage return
limit = 50
out, _, err = dockerCmdWithError("search", fmt.Sprintf("--limit=%d", limit), "docker")
c.Assert(err, checker.IsNil)
outSlice = strings.Split(out, "\n")
c.Assert(outSlice, checker.HasLen, limit+2) // 1 header, 1 carriage return
limit = 100
out, _, err = dockerCmdWithError("search", fmt.Sprintf("--limit=%d", limit), "docker")
c.Assert(err, checker.IsNil)
outSlice = strings.Split(out, "\n")
c.Assert(outSlice, checker.HasLen, limit+2) // 1 header, 1 carriage return
limit = 0
out, _, err = dockerCmdWithError("search", fmt.Sprintf("--limit=%d", limit), "docker")
c.Assert(err, checker.Not(checker.IsNil))
limit = 200
out, _, err = dockerCmdWithError("search", fmt.Sprintf("--limit=%d", limit), "docker")
c.Assert(err, checker.Not(checker.IsNil))
}
开发者ID:docker,项目名称:docker,代码行数:30,代码来源:docker_cli_search_test.go
示例8: TestPsByOrder
func (s *DockerSuite) TestPsByOrder(c *check.C) {
name1 := "xyz-abc"
out, err := runSleepingContainer(c, "--name", name1)
c.Assert(err, checker.NotNil)
c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "")
container1 := strings.TrimSpace(out)
name2 := "xyz-123"
out, err = runSleepingContainer(c, "--name", name2)
c.Assert(err, checker.NotNil)
c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "")
container2 := strings.TrimSpace(out)
name3 := "789-abc"
out, err = runSleepingContainer(c, "--name", name3)
c.Assert(err, checker.NotNil)
c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "")
name4 := "789-123"
out, err = runSleepingContainer(c, "--name", name4)
c.Assert(err, checker.NotNil)
c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "")
// Run multiple time should have the same result
out, err = dockerCmd(c, "ps", "--no-trunc", "-q", "-f", "name=xyz")
c.Assert(err, checker.NotNil)
c.Assert(strings.TrimSpace(out), checker.Equals, fmt.Sprintf("%s\n%s", container2, container1))
// Run multiple time should have the same result
out, err = dockerCmd(c, "ps", "--no-trunc", "-q", "-f", "name=xyz")
c.Assert(err, checker.NotNil)
c.Assert(strings.TrimSpace(out), checker.Equals, fmt.Sprintf("%s\n%s", container2, container1))
}
开发者ID:shakamunyi,项目名称:docker,代码行数:33,代码来源:docker_cli_ps_test.go
示例9: TestSecretCreateWithFile
func (s *DockerSwarmSuite) TestSecretCreateWithFile(c *check.C) {
d := s.AddDaemon(c, true, true)
testFile, err := ioutil.TempFile("", "secretCreateTest")
c.Assert(err, checker.IsNil, check.Commentf("failed to create temporary file"))
defer os.Remove(testFile.Name())
testData := "TESTINGDATA"
_, err = testFile.Write([]byte(testData))
c.Assert(err, checker.IsNil, check.Commentf("failed to write to temporary file"))
testName := "test_secret"
out, err := d.Cmd("secret", "create", "--file", testFile.Name(), testName)
c.Assert(err, checker.IsNil)
c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "", check.Commentf(out))
id := strings.TrimSpace(out)
secret := d.GetSecret(c, id)
c.Assert(secret.Spec.Name, checker.Equals, testName)
testName = "test_secret_2"
out, err = d.Cmd("secret", "create", testName, "-f", testFile.Name())
c.Assert(err, checker.IsNil)
c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "", check.Commentf(out))
id = strings.TrimSpace(out)
secret = d.GetSecret(c, id)
c.Assert(secret.Spec.Name, checker.Equals, testName)
}
开发者ID:shakamunyi,项目名称:docker,代码行数:29,代码来源:docker_cli_secret_create_test.go
示例10: TestInspectStopWhenNotFound
func (s *DockerSuite) TestInspectStopWhenNotFound(c *check.C) {
runSleepingContainer(c, "--name=busybox", "-d")
runSleepingContainer(c, "--name=not-shown", "-d")
out, _, err := dockerCmdWithError("inspect", "--type=container", "--format='{{.Name}}'", "busybox", "missing", "not-shown")
c.Assert(err, checker.Not(check.IsNil))
c.Assert(out, checker.Contains, "busybox")
c.Assert(out, checker.Not(checker.Contains), "not-shown")
c.Assert(out, checker.Contains, "Error: No such container: missing")
}
开发者ID:shakamunyi,项目名称:docker,代码行数:10,代码来源:docker_cli_inspect_test.go
示例11: TestDaemonEventsWithFilters
func (s *DockerDaemonSuite) TestDaemonEventsWithFilters(c *check.C) {
testRequires(c, SameHostDaemon, DaemonIsLinux)
// daemon config file
configFilePath := "test.json"
configFile, err := os.Create(configFilePath)
c.Assert(err, checker.IsNil)
defer os.Remove(configFilePath)
daemonConfig := `{"labels":["foo=bar"]}`
fmt.Fprintf(configFile, "%s", daemonConfig)
configFile.Close()
s.d.Start(c, fmt.Sprintf("--config-file=%s", configFilePath))
// Get daemon ID
out, err := s.d.Cmd("info")
c.Assert(err, checker.IsNil)
daemonID := ""
daemonName := ""
for _, line := range strings.Split(out, "\n") {
if strings.HasPrefix(line, "ID: ") {
daemonID = strings.TrimPrefix(line, "ID: ")
} else if strings.HasPrefix(line, "Name: ") {
daemonName = strings.TrimPrefix(line, "Name: ")
}
}
c.Assert(daemonID, checker.Not(checker.Equals), "")
c.Assert(s.d.Signal(syscall.SIGHUP), checker.IsNil)
time.Sleep(3 * time.Second)
out, err = s.d.Cmd("events", "--since=0", "--until", daemonUnixTime(c), "--filter", fmt.Sprintf("daemon=%s", daemonID))
c.Assert(err, checker.IsNil)
c.Assert(out, checker.Contains, fmt.Sprintf("daemon reload %s", daemonID))
out, err = s.d.Cmd("events", "--since=0", "--until", daemonUnixTime(c), "--filter", fmt.Sprintf("daemon=%s", daemonName))
c.Assert(err, checker.IsNil)
c.Assert(out, checker.Contains, fmt.Sprintf("daemon reload %s", daemonID))
out, err = s.d.Cmd("events", "--since=0", "--until", daemonUnixTime(c), "--filter", "daemon=foo")
c.Assert(err, checker.IsNil)
c.Assert(out, checker.Not(checker.Contains), fmt.Sprintf("daemon reload %s", daemonID))
out, err = s.d.Cmd("events", "--since=0", "--until", daemonUnixTime(c), "--filter", "type=daemon")
c.Assert(err, checker.IsNil)
c.Assert(out, checker.Contains, fmt.Sprintf("daemon reload %s", daemonID))
out, err = s.d.Cmd("events", "--since=0", "--until", daemonUnixTime(c), "--filter", "type=container")
c.Assert(err, checker.IsNil)
c.Assert(out, checker.Not(checker.Contains), fmt.Sprintf("daemon reload %s", daemonID))
}
开发者ID:docker,项目名称:docker,代码行数:52,代码来源:docker_cli_events_unix_test.go
示例12: TestPluginIDPrefix
func (s *DockerSuite) TestPluginIDPrefix(c *check.C) {
testRequires(c, DaemonIsLinux, Network)
_, _, err := dockerCmdWithError("plugin", "install", "--disable", "--grant-all-permissions", pNameWithTag)
c.Assert(err, checker.IsNil)
// Find ID first
id, _, err := dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", pNameWithTag)
id = strings.TrimSpace(id)
c.Assert(err, checker.IsNil)
// List current state
out, _, err := dockerCmdWithError("plugin", "ls")
c.Assert(err, checker.IsNil)
c.Assert(out, checker.Contains, pName)
c.Assert(out, checker.Contains, pTag)
c.Assert(out, checker.Contains, "false")
env, _ := dockerCmd(c, "plugin", "inspect", "-f", "{{.Settings.Env}}", id[:5])
c.Assert(strings.TrimSpace(env), checker.Equals, "[DEBUG=0]")
dockerCmd(c, "plugin", "set", id[:5], "DEBUG=1")
env, _ = dockerCmd(c, "plugin", "inspect", "-f", "{{.Settings.Env}}", id[:5])
c.Assert(strings.TrimSpace(env), checker.Equals, "[DEBUG=1]")
// Enable
_, _, err = dockerCmdWithError("plugin", "enable", id[:5])
c.Assert(err, checker.IsNil)
out, _, err = dockerCmdWithError("plugin", "ls")
c.Assert(err, checker.IsNil)
c.Assert(out, checker.Contains, pName)
c.Assert(out, checker.Contains, pTag)
c.Assert(out, checker.Contains, "true")
// Disable
_, _, err = dockerCmdWithError("plugin", "disable", id[:5])
c.Assert(err, checker.IsNil)
out, _, err = dockerCmdWithError("plugin", "ls")
c.Assert(err, checker.IsNil)
c.Assert(out, checker.Contains, pName)
c.Assert(out, checker.Contains, pTag)
c.Assert(out, checker.Contains, "false")
// Remove
out, _, err = dockerCmdWithError("plugin", "remove", id[:5])
c.Assert(err, checker.IsNil)
// List returns none
out, _, err = dockerCmdWithError("plugin", "ls")
c.Assert(err, checker.IsNil)
c.Assert(out, checker.Not(checker.Contains), pName)
c.Assert(out, checker.Not(checker.Contains), pTag)
}
开发者ID:docker,项目名称:docker,代码行数:52,代码来源:docker_cli_plugins_test.go
示例13: TestLinksPingLinkedContainersOnRename
func (s *DockerSuite) TestLinksPingLinkedContainersOnRename(c *check.C) {
// Problematic on Windows as Windows does not support links
testRequires(c, DaemonIsLinux)
var out string
out, _ = dockerCmd(c, "run", "-d", "--name", "container1", "busybox", "top")
idA := strings.TrimSpace(out)
c.Assert(idA, checker.Not(checker.Equals), "", check.Commentf("%s, id should not be nil", out))
out, _ = dockerCmd(c, "run", "-d", "--link", "container1:alias1", "--name", "container2", "busybox", "top")
idB := strings.TrimSpace(out)
c.Assert(idB, checker.Not(checker.Equals), "", check.Commentf("%s, id should not be nil", out))
dockerCmd(c, "exec", "container2", "ping", "-c", "1", "alias1", "-W", "1")
dockerCmd(c, "rename", "container1", "container_new")
dockerCmd(c, "exec", "container2", "ping", "-c", "1", "alias1", "-W", "1")
}
开发者ID:shakamunyi,项目名称:docker,代码行数:15,代码来源:docker_cli_exec_test.go
示例14: TestCLIProxyProxyTCPSock
// Can't use localhost here since go has a special case to not use proxy if connecting to localhost
// See https://golang.org/pkg/net/http/#ProxyFromEnvironment
func (s *DockerDaemonSuite) TestCLIProxyProxyTCPSock(c *check.C) {
testRequires(c, SameHostDaemon)
// get the IP to use to connect since we can't use localhost
addrs, err := net.InterfaceAddrs()
c.Assert(err, checker.IsNil)
var ip string
for _, addr := range addrs {
sAddr := addr.String()
if !strings.Contains(sAddr, "127.0.0.1") {
addrArr := strings.Split(sAddr, "/")
ip = addrArr[0]
break
}
}
c.Assert(ip, checker.Not(checker.Equals), "")
s.d.Start(c, "-H", "tcp://"+ip+":2375")
icmd.RunCmd(icmd.Cmd{
Command: []string{dockerBinary, "info"},
Env: []string{"DOCKER_HOST=tcp://" + ip + ":2375", "HTTP_PROXY=127.0.0.1:9999"},
}).Assert(c, icmd.Expected{Error: "exit status 1", ExitCode: 1})
// Test with no_proxy
icmd.RunCmd(icmd.Cmd{
Command: []string{dockerBinary, "info"},
Env: []string{"DOCKER_HOST=tcp://" + ip + ":2375", "HTTP_PROXY=127.0.0.1:9999", "NO_PROXY=" + ip},
}).Assert(c, icmd.Success)
}
开发者ID:docker,项目名称:docker,代码行数:31,代码来源:docker_cli_proxy_test.go
示例15: TestServiceLogs
func (s *DockerSwarmSuite) TestServiceLogs(c *check.C) {
testRequires(c, ExperimentalDaemon)
d := s.AddDaemon(c, true, true)
// we have multiple services here for detecting the goroutine issue #28915
services := map[string]string{
"TestServiceLogs1": "hello1",
"TestServiceLogs2": "hello2",
}
for name, message := range services {
out, err := d.Cmd("service", "create", "--name", name, "busybox",
"sh", "-c", fmt.Sprintf("echo %s; tail -f /dev/null", message))
c.Assert(err, checker.IsNil)
c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "")
}
// make sure task has been deployed.
waitAndAssert(c, defaultReconciliationTimeout,
d.CheckActiveContainerCount, checker.Equals, len(services))
for name, message := range services {
out, err := d.Cmd("service", "logs", name)
c.Assert(err, checker.IsNil)
c.Logf("log for %q: %q", name, out)
c.Assert(out, checker.Contains, message)
}
}
开发者ID:docker,项目名称:docker,代码行数:29,代码来源:docker_cli_service_logs_experimental_test.go
示例16: TestPullScratchNotAllowed
// TestPullScratchNotAllowed verifies that pulling 'scratch' is rejected.
func (s *DockerHubPullSuite) TestPullScratchNotAllowed(c *check.C) {
testRequires(c, DaemonIsLinux)
out, err := s.CmdWithError("pull", "scratch")
c.Assert(err, checker.NotNil, check.Commentf("expected pull of scratch to fail"))
c.Assert(out, checker.Contains, "'scratch' is a reserved name")
c.Assert(out, checker.Not(checker.Contains), "Pulling repository scratch")
}
开发者ID:rzzdy,项目名称:docker,代码行数:8,代码来源:docker_cli_pull_test.go
示例17: TestPullAllTagsFromCentralRegistry
// TestPullAllTagsFromCentralRegistry pulls using `all-tags` for a given image and verifies that it
// results in more images than a naked pull.
func (s *DockerHubPullSuite) TestPullAllTagsFromCentralRegistry(c *check.C) {
testRequires(c, DaemonIsLinux)
s.Cmd(c, "pull", "busybox")
outImageCmd := s.Cmd(c, "images", "busybox")
splitOutImageCmd := strings.Split(strings.TrimSpace(outImageCmd), "\n")
c.Assert(splitOutImageCmd, checker.HasLen, 2, check.Commentf("expected a single entry in images\n%v", outImageCmd))
s.Cmd(c, "pull", "--all-tags=true", "busybox")
outImageAllTagCmd := s.Cmd(c, "images", "busybox")
if linesCount := strings.Count(outImageAllTagCmd, "\n"); linesCount <= 2 {
c.Fatalf("pulling all tags should provide more images, got %d", linesCount-1)
}
// Verify that the line for 'busybox:latest' is left unchanged.
var latestLine string
for _, line := range strings.Split(outImageAllTagCmd, "\n") {
if strings.HasPrefix(line, "busybox") && strings.Contains(line, "latest") {
latestLine = line
break
}
}
c.Assert(latestLine, checker.Not(checker.Equals), "", check.Commentf("no entry for busybox:latest found after pulling all tags"))
splitLatest := strings.Fields(latestLine)
splitCurrent := strings.Fields(splitOutImageCmd[1])
c.Assert(splitLatest, checker.DeepEquals, splitCurrent, check.Commentf("busybox:latest was changed after pulling all tags"))
}
开发者ID:rzzdy,项目名称:docker,代码行数:28,代码来源:docker_cli_pull_test.go
示例18: TestSecretInspectMultiple
func (s *DockerSwarmSuite) TestSecretInspectMultiple(c *check.C) {
d := s.AddDaemon(c, true, true)
testNames := []string{
"test0",
"test1",
}
for _, n := range testNames {
id := d.CreateSecret(c, swarm.SecretSpec{
swarm.Annotations{
Name: n,
},
[]byte("TESTINGDATA"),
})
c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("secrets: %s", id))
secret := d.GetSecret(c, id)
c.Assert(secret.Spec.Name, checker.Equals, n)
}
args := []string{
"secret",
"inspect",
}
args = append(args, testNames...)
out, err := d.Cmd(args...)
c.Assert(err, checker.IsNil, check.Commentf(out))
var secrets []swarm.Secret
c.Assert(json.Unmarshal([]byte(out), &secrets), checker.IsNil)
c.Assert(secrets, checker.HasLen, 2)
}
开发者ID:docker,项目名称:docker,代码行数:33,代码来源:docker_cli_secret_inspect_test.go
示例19: TestPullWithExternalAuth
func (s *DockerRegistryAuthHtpasswdSuite) TestPullWithExternalAuth(c *check.C) {
osPath := os.Getenv("PATH")
defer os.Setenv("PATH", osPath)
workingDir, err := os.Getwd()
c.Assert(err, checker.IsNil)
absolute, err := filepath.Abs(filepath.Join(workingDir, "fixtures", "auth"))
c.Assert(err, checker.IsNil)
testPath := fmt.Sprintf("%s%c%s", osPath, filepath.ListSeparator, absolute)
os.Setenv("PATH", testPath)
repoName := fmt.Sprintf("%v/dockercli/busybox:authtest", privateRegistryURL)
tmp, err := ioutil.TempDir("", "integration-cli-")
c.Assert(err, checker.IsNil)
externalAuthConfig := `{ "credsStore": "shell-test" }`
configPath := filepath.Join(tmp, "config.json")
err = ioutil.WriteFile(configPath, []byte(externalAuthConfig), 0644)
c.Assert(err, checker.IsNil)
dockerCmd(c, "--config", tmp, "login", "-u", s.reg.Username(), "-p", s.reg.Password(), privateRegistryURL)
b, err := ioutil.ReadFile(configPath)
c.Assert(err, checker.IsNil)
c.Assert(string(b), checker.Not(checker.Contains), "\"auth\":")
dockerCmd(c, "--config", tmp, "tag", "busybox", repoName)
dockerCmd(c, "--config", tmp, "push", repoName)
dockerCmd(c, "--config", tmp, "pull", repoName)
}
开发者ID:docker,项目名称:docker,代码行数:34,代码来源:docker_cli_pull_local_test.go
示例20: TestImagesEnsureDanglingImageOnlyListedOnce
func (s *DockerSuite) TestImagesEnsureDanglingImageOnlyListedOnce(c *check.C) {
testRequires(c, DaemonIsLinux)
// create container 1
out, _ := dockerCmd(c, "run", "-d", "busybox", "true")
containerID1 := strings.TrimSpace(out)
// tag as foobox
out, _ = dockerCmd(c, "commit", containerID1, "foobox")
imageID := stringid.TruncateID(strings.TrimSpace(out))
// overwrite the tag, making the previous image dangling
dockerCmd(c, "tag", "busybox", "foobox")
out, _ = dockerCmd(c, "images", "-q", "-f", "dangling=true")
// Expect one dangling image
c.Assert(strings.Count(out, imageID), checker.Equals, 1)
out, _ = dockerCmd(c, "images", "-q", "-f", "dangling=false")
//dangling=false would not include dangling images
c.Assert(out, checker.Not(checker.Contains), imageID)
out, _ = dockerCmd(c, "images")
//docker images still include dangling images
c.Assert(out, checker.Contains, imageID)
}
开发者ID:docker,项目名称:docker,代码行数:26,代码来源:docker_cli_images_test.go
注:本文中的github.com/docker/docker/integration-cli/checker.Not函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论