当前位置: 首页>>代码示例>>Golang>>正文


Golang checker.Not函数代码示例

本文整理汇总了Golang中github.com/docker/docker/pkg/integration/checker.Not函数的典型用法代码示例。如果您正苦于以下问题:Golang Not函数的具体用法?Golang Not怎么用?Golang Not使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Not函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: TestPruneImageDangling

func (s *DockerDaemonSuite) TestPruneImageDangling(c *check.C) {
	c.Assert(s.d.StartWithBusybox(), checker.IsNil)

	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:haoshuwei,项目名称:docker,代码行数:29,代码来源:docker_cli_prune_unix_test.go

示例2: TestContainerPsOmitFields

// regression test for non-empty fields from #13901
func (s *DockerSuite) TestContainerPsOmitFields(c *check.C) {
	testRequires(c, DaemonIsLinux)
	name := "pstest"
	port := 80
	dockerCmd(c, "run", "-d", "--name", name, "--expose", strconv.Itoa(port), "busybox", "top")

	status, body, err := sockRequest("GET", "/containers/json?all=1", nil)
	c.Assert(err, checker.IsNil)
	c.Assert(status, checker.Equals, http.StatusOK)

	var resp []containerPs
	err = json.Unmarshal(body, &resp)
	c.Assert(err, checker.IsNil)

	var foundContainer *containerPs
	for _, container := range resp {
		for _, testName := range container.Names {
			if "/"+name == testName {
				foundContainer = &container
				break
			}
		}
	}

	c.Assert(foundContainer.Ports, checker.HasLen, 1)
	c.Assert(foundContainer.Ports[0]["PrivatePort"], checker.Equals, float64(port))
	_, ok := foundContainer.Ports[0]["PublicPort"]
	c.Assert(ok, checker.Not(checker.Equals), true)
	_, ok = foundContainer.Ports[0]["IP"]
	c.Assert(ok, checker.Not(checker.Equals), true)
}
开发者ID:rwdev,项目名称:docker,代码行数:32,代码来源:docker_api_containers_test.go

示例3: 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:justincormack,项目名称:docker,代码行数:29,代码来源:docker_cli_secret_create_test.go

示例4: 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 := 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 = 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:SUSE,项目名称:docker.mirror,代码行数:29,代码来源:docker_cli_save_load_test.go

示例5: 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:CWSpear,项目名称:docker,代码行数:33,代码来源:docker_cli_ps_test.go

示例6: TestContainerApiPsOmitFields

// regression test for non-empty fields from #13901
func (s *DockerSuite) TestContainerApiPsOmitFields(c *check.C) {
	// Problematic for Windows porting due to networking not yet being passed back
	testRequires(c, DaemonIsLinux)
	name := "pstest"
	port := 80
	runSleepingContainer(c, "--name", name, "--expose", strconv.Itoa(port))

	status, body, err := sockRequest("GET", "/containers/json?all=1", nil)
	c.Assert(err, checker.IsNil)
	c.Assert(status, checker.Equals, http.StatusOK)

	var resp []containerPs
	err = json.Unmarshal(body, &resp)
	c.Assert(err, checker.IsNil)

	var foundContainer *containerPs
	for _, container := range resp {
		for _, testName := range container.Names {
			if "/"+name == testName {
				foundContainer = &container
				break
			}
		}
	}

	c.Assert(foundContainer.Ports, checker.HasLen, 1)
	c.Assert(foundContainer.Ports[0]["PrivatePort"], checker.Equals, float64(port))
	_, ok := foundContainer.Ports[0]["PublicPort"]
	c.Assert(ok, checker.Not(checker.Equals), true)
	_, ok = foundContainer.Ports[0]["IP"]
	c.Assert(ok, checker.Not(checker.Equals), true)
}
开发者ID:CadeLaRen,项目名称:docker-3,代码行数:33,代码来源:docker_api_containers_test.go

示例7: TestSwarmNodeTaskListFilter

func (s *DockerSwarmSuite) TestSwarmNodeTaskListFilter(c *check.C) {
	d := s.AddDaemon(c, true, true)

	name := "redis-cluster-md5"
	out, err := d.Cmd("service", "create", "--name", name, "--replicas=3", "busybox", "top")
	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, 3)

	filter := "name=redis-cluster"

	out, err = d.Cmd("node", "tasks", "--filter", filter, "self")
	c.Assert(err, checker.IsNil)
	c.Assert(out, checker.Contains, name+".1")
	c.Assert(out, checker.Contains, name+".2")
	c.Assert(out, checker.Contains, name+".3")

	out, err = d.Cmd("node", "tasks", "--filter", "name=none", "self")
	c.Assert(err, checker.IsNil)
	c.Assert(out, checker.Not(checker.Contains), name+".1")
	c.Assert(out, checker.Not(checker.Contains), name+".2")
	c.Assert(out, checker.Not(checker.Contains), name+".3")
}
开发者ID:benizi,项目名称:docker,代码行数:25,代码来源:docker_cli_swarm_test.go

示例8: TestSaveImageId

func (s *DockerSuite) TestSaveImageId(c *check.C) {
	testRequires(c, DaemonIsLinux)
	repoName := "foobar-save-image-id-test"
	dockerCmd(c, "tag", "emptyfs:latest", fmt.Sprintf("%v:latest", repoName))

	out, _ := dockerCmd(c, "images", "-q", "--no-trunc", repoName)
	cleanedLongImageID := strings.TrimSpace(out)

	out, _ = dockerCmd(c, "images", "-q", repoName)
	cleanedShortImageID := strings.TrimSpace(out)

	// Make sure IDs are not empty
	c.Assert(cleanedLongImageID, checker.Not(check.Equals), "", check.Commentf("Id should not be empty."))
	c.Assert(cleanedShortImageID, checker.Not(check.Equals), "", check.Commentf("Id should not be empty."))

	saveCmd := exec.Command(dockerBinary, "save", cleanedShortImageID)
	tarCmd := exec.Command("tar", "t")

	var err error
	tarCmd.Stdin, err = saveCmd.StdoutPipe()
	c.Assert(err, checker.IsNil, check.Commentf("cannot set stdout pipe for tar: %v", err))
	grepCmd := exec.Command("grep", cleanedLongImageID)
	grepCmd.Stdin, err = tarCmd.StdoutPipe()
	c.Assert(err, checker.IsNil, check.Commentf("cannot set stdout pipe for grep: %v", err))

	c.Assert(tarCmd.Start(), checker.IsNil, check.Commentf("tar failed with error: %v", err))
	c.Assert(saveCmd.Start(), checker.IsNil, check.Commentf("docker save failed with error: %v", err))
	defer saveCmd.Wait()
	defer tarCmd.Wait()

	out, _, err = runCommandWithOutput(grepCmd)

	c.Assert(err, checker.IsNil, check.Commentf("failed to save repo with image ID: %s, %v", out, err))
}
开发者ID:previousnext,项目名称:kube-ingress,代码行数:34,代码来源:docker_cli_save_load_test.go

示例9: 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:CadeLaRen,项目名称:docker-3,代码行数:30,代码来源:docker_cli_search_test.go

示例10: 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:CadeLaRen,项目名称:docker-3,代码行数:32,代码来源:docker_cli_logs_test.go

示例11: TestSwarmContainerAttachByNetworkId

func (s *DockerSwarmSuite) TestSwarmContainerAttachByNetworkId(c *check.C) {
	d := s.AddDaemon(c, true, true)

	out, err := d.Cmd("network", "create", "--attachable", "-d", "overlay", "testnet")
	c.Assert(err, checker.IsNil)
	c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "")
	networkID := strings.TrimSpace(out)

	out, err = d.Cmd("run", "-d", "--net", networkID, "busybox", "top")
	c.Assert(err, checker.IsNil)
	cID := strings.TrimSpace(out)
	d.waitRun(cID)

	_, err = d.Cmd("rm", "-f", cID)
	c.Assert(err, checker.IsNil)

	out, err = d.Cmd("network", "rm", "testnet")
	c.Assert(err, checker.IsNil)

	checkNetwork := func(*check.C) (interface{}, check.CommentInterface) {
		out, err := d.Cmd("network", "ls")
		c.Assert(err, checker.IsNil)
		return out, nil
	}

	waitAndAssert(c, 3*time.Second, checkNetwork, checker.Not(checker.Contains), "testnet")
}
开发者ID:daehyeok,项目名称:docker,代码行数:27,代码来源:docker_cli_swarm_test.go

示例12: 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:Mic92,项目名称:docker,代码行数:28,代码来源:docker_cli_events_test.go

示例13: TestPsListContainersFilterIsTask

func (s *DockerSwarmSuite) TestPsListContainersFilterIsTask(c *check.C) {
	d := s.AddDaemon(c, true, true)

	// Create a bare container
	out, err := d.Cmd("run", "-d", "--name=bare-container", "busybox", "top")
	c.Assert(err, checker.IsNil)
	bareID := strings.TrimSpace(out)[:12]
	// Create a service
	name := "busybox-top"
	out, err = d.Cmd("service", "create", "--name", name, "busybox", "top")
	c.Assert(err, checker.IsNil)
	c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "")

	// make sure task has been deployed.
	waitAndAssert(c, defaultReconciliationTimeout, d.checkServiceRunningTasks(c, name), checker.Equals, 1)

	// Filter non-tasks
	out, err = d.Cmd("ps", "-a", "-q", "--filter=is-task=false")
	c.Assert(err, checker.IsNil)
	psOut := strings.TrimSpace(out)
	c.Assert(psOut, checker.Equals, bareID, check.Commentf("Expected id %s, got %s for is-task label, output %q", bareID, psOut, out))

	// Filter tasks
	out, err = d.Cmd("ps", "-a", "-q", "--filter=is-task=true")
	c.Assert(err, checker.IsNil)
	lines := strings.Split(strings.Trim(out, "\n "), "\n")
	c.Assert(lines, checker.HasLen, 1)
	c.Assert(lines[0], checker.Not(checker.Equals), bareID, check.Commentf("Expected not %s, but got it for is-task label, output %q", bareID, out))
}
开发者ID:MHBauer,项目名称:docker,代码行数:29,代码来源:docker_cli_swarm_test.go

示例14: TestInspectStopWhenNotFound

func (s *DockerSuite) TestInspectStopWhenNotFound(c *check.C) {
	dockerCmd(c, "run", "--name=busybox", "-d", "busybox", "top")
	dockerCmd(c, "run", "--name=not-shown", "-d", "busybox", "top")
	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:DaveDaCoda,项目名称:docker,代码行数:10,代码来源:docker_cli_inspect_test.go

示例15: TestSwarmInitLocked

func (s *DockerSwarmSuite) TestSwarmInitLocked(c *check.C) {
	d := s.AddDaemon(c, false, false)

	outs, err := d.Cmd("swarm", "init", "--autolock")
	c.Assert(err, checker.IsNil, check.Commentf("out: %v", outs))

	c.Assert(outs, checker.Contains, "docker swarm unlock")

	var unlockKey string
	for _, line := range strings.Split(outs, "\n") {
		if strings.Contains(line, "SWMKEY") {
			unlockKey = strings.TrimSpace(line)
			break
		}
	}

	c.Assert(unlockKey, checker.Not(checker.Equals), "")

	outs, err = d.Cmd("swarm", "unlock-key", "-q")
	c.Assert(outs, checker.Equals, unlockKey+"\n")

	c.Assert(getNodeStatus(c, d), checker.Equals, swarm.LocalNodeStateActive)

	// It starts off locked
	c.Assert(d.Restart(), checker.IsNil)
	c.Assert(getNodeStatus(c, d), checker.Equals, swarm.LocalNodeStateLocked)

	cmd := d.command("swarm", "unlock")
	cmd.Stdin = bytes.NewBufferString("wrong-secret-key")
	out, err := cmd.CombinedOutput()
	c.Assert(err, checker.NotNil, check.Commentf("out: %v", string(out)))
	c.Assert(string(out), checker.Contains, "invalid key")

	c.Assert(getNodeStatus(c, d), checker.Equals, swarm.LocalNodeStateLocked)

	cmd = d.command("swarm", "unlock")
	cmd.Stdin = bytes.NewBufferString(unlockKey)
	out, err = cmd.CombinedOutput()
	c.Assert(err, checker.IsNil, check.Commentf("out: %v", string(out)))

	c.Assert(getNodeStatus(c, d), checker.Equals, swarm.LocalNodeStateActive)

	outs, err = d.Cmd("node", "ls")
	c.Assert(err, checker.IsNil)
	c.Assert(outs, checker.Not(checker.Contains), "Swarm is encrypted and needs to be unlocked")

	outs, err = d.Cmd("swarm", "update", "--autolock=false")
	c.Assert(err, checker.IsNil, check.Commentf("out: %v", outs))

	checkSwarmLockedToUnlocked(c, d, unlockKey)

	outs, err = d.Cmd("node", "ls")
	c.Assert(err, checker.IsNil)
	c.Assert(outs, checker.Not(checker.Contains), "Swarm is encrypted and needs to be unlocked")
}
开发者ID:haoshuwei,项目名称:docker,代码行数:55,代码来源:docker_cli_swarm_test.go


注:本文中的github.com/docker/docker/pkg/integration/checker.Not函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。