本文整理汇总了Golang中github.com/go-check/check.Not函数的典型用法代码示例。如果您正苦于以下问题:Golang Not函数的具体用法?Golang Not怎么用?Golang Not使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Not函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestCreateWhenCertExpired
func (s *DockerTrustSuite) TestCreateWhenCertExpired(c *check.C) {
c.Skip("Currently changes system time, causing instability")
repoName := s.setupTrustedImage(c, "trusted-create-expired")
// Certificates have 10 years of expiration
elevenYearsFromNow := time.Now().Add(time.Hour * 24 * 365 * 11)
runAtDifferentDate(elevenYearsFromNow, func() {
// Try create
createCmd := exec.Command(dockerBinary, "create", repoName)
s.trustedCmd(createCmd)
out, _, err := runCommandWithOutput(createCmd)
c.Assert(err, check.Not(check.IsNil))
c.Assert(string(out), checker.Contains, "could not validate the path to a trusted root", check.Commentf("Missing expected output on trusted create in the distant future:\n%s", out))
})
runAtDifferentDate(elevenYearsFromNow, func() {
// Try create
createCmd := exec.Command(dockerBinary, "create", "--disable-content-trust", repoName)
s.trustedCmd(createCmd)
out, _, err := runCommandWithOutput(createCmd)
c.Assert(err, check.Not(check.IsNil))
c.Assert(string(out), checker.Contains, "Status: Downloaded", check.Commentf("Missing expected output on trusted create in the distant future:\n%s", out))
})
}
开发者ID:SUSE,项目名称:docker.mirror,代码行数:26,代码来源:docker_cli_create_test.go
示例2: TestGetContainerStatsRmRunning
func (s *DockerSuite) TestGetContainerStatsRmRunning(c *check.C) {
out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
id := strings.TrimSpace(out)
buf := &channelBuffer{make(chan []byte, 1)}
defer buf.Close()
chErr := make(chan error)
go func() {
_, body, err := sockRequestRaw("GET", "/containers/"+id+"/stats?stream=1", nil, "application/json")
if err != nil {
chErr <- err
}
defer body.Close()
_, err = io.Copy(buf, body)
chErr <- err
}()
defer func() {
c.Assert(<-chErr, check.IsNil)
}()
b := make([]byte, 32)
// make sure we've got some stats
_, err := buf.ReadTimeout(b, 2*time.Second)
c.Assert(err, check.IsNil)
// Now remove without `-f` and make sure we are still pulling stats
_, _, err = dockerCmdWithError(c, "rm", id)
c.Assert(err, check.Not(check.IsNil), check.Commentf("rm should have failed but didn't"))
_, err = buf.ReadTimeout(b, 2*time.Second)
c.Assert(err, check.IsNil)
dockerCmd(c, "rm", "-f", id)
_, err = buf.ReadTimeout(b, 2*time.Second)
c.Assert(err, check.Not(check.IsNil))
}
开发者ID:gs11,项目名称:docker,代码行数:35,代码来源:docker_api_containers_test.go
示例3: TestVolumeCliLsFilterDangling
func (s *DockerSuite) TestVolumeCliLsFilterDangling(c *check.C) {
prefix := ""
if daemonPlatform == "windows" {
prefix = "c:"
}
dockerCmd(c, "volume", "create", "--name", "testnotinuse1")
dockerCmd(c, "volume", "create", "--name", "testisinuse1")
dockerCmd(c, "volume", "create", "--name", "testisinuse2")
// Make sure both "created" (but not started), and started
// containers are included in reference counting
dockerCmd(c, "run", "--name", "volume-test1", "-v", "testisinuse1:"+prefix+"/foo", "busybox", "true")
dockerCmd(c, "create", "--name", "volume-test2", "-v", "testisinuse2:"+prefix+"/foo", "busybox", "true")
out, _ := dockerCmd(c, "volume", "ls")
// No filter, all volumes should show
c.Assert(out, checker.Contains, "testnotinuse1\n", check.Commentf("expected volume 'testnotinuse1' in output"))
c.Assert(out, checker.Contains, "testisinuse1\n", check.Commentf("expected volume 'testisinuse1' in output"))
c.Assert(out, checker.Contains, "testisinuse2\n", check.Commentf("expected volume 'testisinuse2' in output"))
out, _ = dockerCmd(c, "volume", "ls", "--filter", "dangling=false")
// Same as above, but explicitly disabling dangling
c.Assert(out, checker.Contains, "testnotinuse1\n", check.Commentf("expected volume 'testnotinuse1' in output"))
c.Assert(out, checker.Contains, "testisinuse1\n", check.Commentf("expected volume 'testisinuse1' in output"))
c.Assert(out, checker.Contains, "testisinuse2\n", check.Commentf("expected volume 'testisinuse2' in output"))
out, _ = dockerCmd(c, "volume", "ls", "--filter", "dangling=true")
// Filter "dangling" volumes; only "dangling" (unused) volumes should be in the output
c.Assert(out, checker.Contains, "testnotinuse1\n", check.Commentf("expected volume 'testnotinuse1' in output"))
c.Assert(out, check.Not(checker.Contains), "testisinuse1\n", check.Commentf("volume 'testisinuse1' in output, but not expected"))
c.Assert(out, check.Not(checker.Contains), "testisinuse2\n", check.Commentf("volume 'testisinuse2' in output, but not expected"))
}
开发者ID:DaveDaCoda,项目名称:docker,代码行数:35,代码来源:docker_cli_volume_test.go
示例4: 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, check.IsNil)
c.Assert(status, check.Equals, http.StatusOK)
var resp []containerPs
err = json.Unmarshal(body, &resp)
c.Assert(err, check.IsNil)
var foundContainer *containerPs
for _, container := range resp {
for _, testName := range container.Names {
if "/"+name == testName {
foundContainer = &container
break
}
}
}
c.Assert(len(foundContainer.Ports), check.Equals, 1)
c.Assert(foundContainer.Ports[0]["PrivatePort"], check.Equals, float64(port))
_, ok := foundContainer.Ports[0]["PublicPort"]
c.Assert(ok, check.Not(check.Equals), true)
_, ok = foundContainer.Ports[0]["IP"]
c.Assert(ok, check.Not(check.Equals), true)
}
开发者ID:previousnext,项目名称:kube-ingress,代码行数:32,代码来源:docker_api_containers_test.go
示例5: TestCreateSimple
func (s *CheckSuite) TestCreateSimple(c *check.C) {
project := setupTest(c)
container := project.Create(c, "busybox")
c.Assert(container.ID, check.Not(check.Equals), "")
c.Assert(strings.HasPrefix(container.Name, "kermit_"), check.Not(check.Equals), true)
}
开发者ID:vdemeester,项目名称:libkermit,代码行数:8,代码来源:simple_test.go
示例6: TestV1
// TestV1 starts a daemon in 'normal' mode
// and ensure v1 endpoints are hit for the following operations:
// login, push, pull, build & run
func (s *DockerRegistrySuite) TestV1(c *check.C) {
reg, err := newTestRegistry(c)
c.Assert(err, check.IsNil)
v2Pings := 0
reg.registerHandler("/v2/", func(w http.ResponseWriter, r *http.Request) {
v2Pings++
// V2 ping 404 causes fallback to v1
w.WriteHeader(404)
})
v1Pings := 0
reg.registerHandler("/v1/_ping", func(w http.ResponseWriter, r *http.Request) {
v1Pings++
})
v1Logins := 0
reg.registerHandler("/v1/users/", func(w http.ResponseWriter, r *http.Request) {
v1Logins++
})
v1Repo := 0
reg.registerHandler("/v1/repositories/busybox/", func(w http.ResponseWriter, r *http.Request) {
v1Repo++
})
reg.registerHandler("/v1/repositories/busybox/images", func(w http.ResponseWriter, r *http.Request) {
v1Repo++
})
err = s.d.Start("--insecure-registry", reg.hostport, "--disable-legacy-registry=false")
c.Assert(err, check.IsNil)
dockerfileName, cleanup, err := makefile(fmt.Sprintf("FROM %s/busybox", reg.hostport))
c.Assert(err, check.IsNil, check.Commentf("Unable to create test dockerfile"))
defer cleanup()
s.d.Cmd("build", "--file", dockerfileName, ".")
c.Assert(v1Repo, check.Not(check.Equals), 0, check.Commentf("Expected v1 repository access after build"))
repoName := fmt.Sprintf("%s/busybox", reg.hostport)
s.d.Cmd("run", repoName)
c.Assert(v1Repo, check.Not(check.Equals), 1, check.Commentf("Expected v1 repository access after run"))
s.d.Cmd("login", "-u", "richard", "-p", "testtest", "-e", "[email protected]", reg.hostport)
c.Assert(v1Logins, check.Not(check.Equals), 0, check.Commentf("Expected v1 login attempt"))
s.d.Cmd("tag", "busybox", repoName)
s.d.Cmd("push", repoName)
c.Assert(v1Repo, check.Equals, 2)
c.Assert(v1Pings, check.Equals, 1)
s.d.Cmd("pull", repoName)
c.Assert(v1Repo, check.Equals, 3, check.Commentf("Expected v1 repository access after pull"))
}
开发者ID:maaquib,项目名称:docker,代码行数:60,代码来源:docker_cli_v2_only.go
示例7: TestInspectSizeFlagContainer
func (s *DockerSuite) TestInspectSizeFlagContainer(c *check.C) {
dockerCmd(c, "run", "--name=busybox", "-d", "busybox", "top")
formatStr := "--format='{{.SizeRw}},{{.SizeRootFs}}'"
out, _ := dockerCmd(c, "inspect", "-s", "--type=container", formatStr, "busybox")
sz := strings.Split(out, ",")
c.Assert(strings.TrimSpace(sz[0]), check.Not(check.Equals), "<nil>")
c.Assert(strings.TrimSpace(sz[1]), check.Not(check.Equals), "<nil>")
}
开发者ID:DaveDaCoda,项目名称:docker,代码行数:10,代码来源:docker_cli_inspect_test.go
示例8: TestInspectTempateError
func (s *DockerSuite) TestInspectTempateError(c *check.C) {
// Template parsing error for both the container and image.
dockerCmd(c, "run", "--name=container1", "-d", "busybox", "top")
out, _, err := dockerCmdWithError("inspect", "--type=container", "--format='Format container: {{.ThisDoesNotExist}}'", "container1")
c.Assert(err, check.Not(check.IsNil))
c.Assert(out, checker.Contains, "Template parsing error")
out, _, err = dockerCmdWithError("inspect", "--type=image", "--format='Format container: {{.ThisDoesNotExist}}'", "busybox")
c.Assert(err, check.Not(check.IsNil))
c.Assert(out, checker.Contains, "Template parsing error")
}
开发者ID:DaveDaCoda,项目名称:docker,代码行数:13,代码来源:docker_cli_inspect_test.go
示例9: TestInspectSizeFlagContainer
func (s *DockerSuite) TestInspectSizeFlagContainer(c *check.C) {
//Both the container and image are named busybox. docker inspect will fetch container
//JSON SizeRw and SizeRootFs field. If there is a flag --size/-s, the fields are not <no value>.
dockerCmd(c, "run", "--name=busybox", "-d", "busybox", "top")
formatStr := fmt.Sprintf("--format='{{.SizeRw}},{{.SizeRootFs}}'")
out, _ := dockerCmd(c, "inspect", "-s", "--type=container", formatStr, "busybox")
sz := strings.Split(out, ",")
c.Assert(strings.TrimSpace(sz[0]), check.Not(check.Equals), "<nil>")
c.Assert(strings.TrimSpace(sz[1]), check.Not(check.Equals), "<nil>")
}
开发者ID:newdeamon,项目名称:docker,代码行数:14,代码来源:docker_cli_inspect_test.go
示例10: TestCrossRepositoryLayerPushNotSupported
func (s *DockerSchema1RegistrySuite) TestCrossRepositoryLayerPushNotSupported(c *check.C) {
sourceRepoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL)
// tag the image to upload it to the private registry
dockerCmd(c, "tag", "busybox", sourceRepoName)
// push the image to the registry
out1, _, err := dockerCmdWithError("push", sourceRepoName)
c.Assert(err, check.IsNil, check.Commentf("pushing the image to the private registry has failed: %s", out1))
// ensure that none of the layers were mounted from another repository during push
c.Assert(strings.Contains(out1, "Mounted from"), check.Equals, false)
digest1 := reference.DigestRegexp.FindString(out1)
c.Assert(len(digest1), checker.GreaterThan, 0, check.Commentf("no digest found for pushed manifest"))
destRepoName := fmt.Sprintf("%v/dockercli/crossrepopush", privateRegistryURL)
// retag the image to upload the same layers to another repo in the same registry
dockerCmd(c, "tag", "busybox", destRepoName)
// push the image to the registry
out2, _, err := dockerCmdWithError("push", destRepoName)
c.Assert(err, check.IsNil, check.Commentf("pushing the image to the private registry has failed: %s", out2))
// schema1 registry should not support cross-repo layer mounts, so ensure that this does not happen
c.Assert(strings.Contains(out2, "Mounted from"), check.Equals, false)
digest2 := reference.DigestRegexp.FindString(out2)
c.Assert(len(digest2), checker.GreaterThan, 0, check.Commentf("no digest found for pushed manifest"))
c.Assert(digest1, check.Not(check.Equals), digest2)
// ensure that we can pull and run the second pushed repository
dockerCmd(c, "rmi", destRepoName)
dockerCmd(c, "pull", destRepoName)
out3, _ := dockerCmd(c, "run", destRepoName, "echo", "-n", "hello world")
c.Assert(out3, check.Equals, "hello world")
}
开发者ID:CadeLaRen,项目名称:docker-3,代码行数:32,代码来源:docker_cli_push_test.go
示例11: TestCreateWhenCertExpired
func (s *DockerTrustSuite) TestCreateWhenCertExpired(c *check.C) {
c.Skip("Currently changes system time, causing instability")
repoName := s.setupTrustedImage(c, "trusted-create-expired")
// Certificates have 10 years of expiration
elevenYearsFromNow := time.Now().Add(time.Hour * 24 * 365 * 11)
testutil.RunAtDifferentDate(elevenYearsFromNow, func() {
// Try create
icmd.RunCmd(icmd.Cmd{
Command: []string{dockerBinary, "create", repoName},
}, trustedCmd).Assert(c, icmd.Expected{
ExitCode: 1,
Err: "could not validate the path to a trusted root",
})
})
testutil.RunAtDifferentDate(elevenYearsFromNow, func() {
// Try create
result := icmd.RunCmd(icmd.Command(dockerBinary, "create", "--disable-content-trust", repoName), trustedCmd)
c.Assert(result.Error, check.Not(check.IsNil))
c.Assert(string(result.Combined()), checker.Contains, "Status: Downloaded", check.Commentf("Missing expected output on trusted create in the distant future:\n%s", result.Combined()))
})
}
开发者ID:docker,项目名称:docker,代码行数:25,代码来源:docker_cli_create_test.go
示例12: TestVolumeCliLsFilterLabels
func (s *DockerSuite) TestVolumeCliLsFilterLabels(c *check.C) {
testVol1 := "testvolcreatelabel-1"
out, _, err := dockerCmdWithError("volume", "create", "--label", "foo=bar1", "--name", testVol1)
c.Assert(err, check.IsNil)
testVol2 := "testvolcreatelabel-2"
out, _, err = dockerCmdWithError("volume", "create", "--label", "foo=bar2", "--name", testVol2)
c.Assert(err, check.IsNil)
out, _ = dockerCmd(c, "volume", "ls", "--filter", "label=foo")
// filter with label=key
c.Assert(out, checker.Contains, "testvolcreatelabel-1\n", check.Commentf("expected volume 'testvolcreatelabel-1' in output"))
c.Assert(out, checker.Contains, "testvolcreatelabel-2\n", check.Commentf("expected volume 'testvolcreatelabel-2' in output"))
out, _ = dockerCmd(c, "volume", "ls", "--filter", "label=foo=bar1")
// filter with label=key=value
c.Assert(out, checker.Contains, "testvolcreatelabel-1\n", check.Commentf("expected volume 'testvolcreatelabel-1' in output"))
c.Assert(out, check.Not(checker.Contains), "testvolcreatelabel-2\n", check.Commentf("expected volume 'testvolcreatelabel-2 in output"))
out, _ = dockerCmd(c, "volume", "ls", "--filter", "label=non-exist")
outArr := strings.Split(strings.TrimSpace(out), "\n")
c.Assert(len(outArr), check.Equals, 1, check.Commentf("\n%s", out))
out, _ = dockerCmd(c, "volume", "ls", "--filter", "label=foo=non-exist")
outArr = strings.Split(strings.TrimSpace(out), "\n")
c.Assert(len(outArr), check.Equals, 1, check.Commentf("\n%s", out))
}
开发者ID:Mokolea,项目名称:docker,代码行数:29,代码来源:docker_cli_volume_test.go
示例13: NewDaemon
// NewDaemon returns a Daemon instance to be used for testing.
// This will create a directory such as d123456789 in the folder specified by $DEST.
// The daemon will not automatically start.
func NewDaemon(c *check.C) *Daemon {
dest := os.Getenv("DEST")
c.Assert(dest, check.Not(check.Equals), "", check.Commentf("Please set the DEST environment variable"))
err := os.MkdirAll(daemonSockRoot, 0700)
c.Assert(err, checker.IsNil, check.Commentf("could not create daemon socket root"))
id := fmt.Sprintf("d%s", stringid.TruncateID(stringid.GenerateRandomID()))
dir := filepath.Join(dest, id)
daemonFolder, err := filepath.Abs(dir)
c.Assert(err, check.IsNil, check.Commentf("Could not make %q an absolute path", dir))
daemonRoot := filepath.Join(daemonFolder, "root")
c.Assert(os.MkdirAll(daemonRoot, 0755), check.IsNil, check.Commentf("Could not create daemon root %q", dir))
userlandProxy := true
if env := os.Getenv("DOCKER_USERLANDPROXY"); env != "" {
if val, err := strconv.ParseBool(env); err != nil {
userlandProxy = val
}
}
return &Daemon{
id: id,
c: c,
folder: daemonFolder,
root: daemonRoot,
storageDriver: os.Getenv("DOCKER_GRAPHDRIVER"),
userlandProxy: userlandProxy,
execRoot: filepath.Join(os.TempDir(), "docker-execroot", id),
}
}
开发者ID:haoshuwei,项目名称:docker,代码行数:35,代码来源:daemon.go
示例14: TestStreamUntilRemoved
func (s *StreamHandlerSuite) TestStreamUntilRemoved(c *check.C) {
var l string
var err error
// Create a second file in the same directory
tbd := filepath.Join(filepath.Dir(s.FileName), "to_be_deleted")
_, err = os.Create(tbd)
c.Check(err, check.IsNil)
res := s.Get(c)
c.Check(res.StatusCode, check.Equals, 200)
r := bufio.NewReader(res.Body)
// Write before remove
s.Printf(c, "hello\n")
// Remove second file - this should not cause a fail
err = os.Remove(tbd)
c.Check(err, check.IsNil)
// Read bytes written before remove
l, err = r.ReadString('\n')
c.Check(err, check.IsNil)
c.Check(l, check.Equals, "hello\n")
// Remove
err = os.Remove(s.FileName)
c.Assert(err, check.IsNil)
// Read EOF
l, err = r.ReadString('\n')
c.Check(err, check.Not(check.IsNil))
c.Check(l, check.Equals, "")
}
开发者ID:cloudfoundry,项目名称:dea_ng,代码行数:35,代码来源:stream_handler_test.go
示例15: TestEventsFilterLabels
func (s *DockerSuite) TestEventsFilterLabels(c *check.C) {
testRequires(c, DaemonIsLinux)
since := daemonTime(c).Unix()
label := "io.docker.testing=foo"
out, _ := dockerCmd(c, "run", "-d", "-l", label, "busybox:latest", "true")
container1 := strings.TrimSpace(out)
out, _ = dockerCmd(c, "run", "-d", "busybox", "true")
container2 := strings.TrimSpace(out)
out, _ = dockerCmd(
c,
"events",
fmt.Sprintf("--since=%d", since),
fmt.Sprintf("--until=%d", daemonTime(c).Unix()),
"--filter", fmt.Sprintf("label=%s", label))
events := strings.Split(strings.TrimSpace(out), "\n")
c.Assert(len(events), checker.Equals, 3)
for _, e := range events {
c.Assert(e, checker.Contains, container1)
c.Assert(e, check.Not(checker.Contains), container2)
}
}
开发者ID:previousnext,项目名称:kube-ingress,代码行数:26,代码来源:docker_cli_events_test.go
示例16: TestStartAndStop
func (s *CheckSuite) TestStartAndStop(c *check.C) {
project := setupTest(c)
container := project.Start(c, "busybox")
c.Assert(container.ID, check.Not(check.Equals), "")
c.Assert(strings.HasPrefix(container.Name, "kermit_"), check.Not(check.Equals), true)
c.Assert(container.State.Running, check.Equals, true,
check.Commentf("expected container to be running, but was in state %v", container.State))
project.Stop(c, container.ID)
container = project.Inspect(c, container.ID)
c.Assert(container.State.Running, check.Equals, false,
check.Commentf("expected container to not be running, but was in state %v", container.State))
}
开发者ID:vdemeester,项目名称:libkermit,代码行数:16,代码来源:simple_test.go
示例17: TestStreamUntilRemoved
func (s *StreamHandlerSuite) TestStreamUntilRemoved(c *check.C) {
var l string
var err error
res := s.Get(c)
c.Check(res.StatusCode, check.Equals, 200)
r := bufio.NewReader(res.Body)
// Write before rename
s.Printf(c, "hello\n")
// Read bytes written before rename
l, err = r.ReadString('\n')
c.Check(err, check.IsNil)
c.Check(l, check.Equals, "hello\n")
// Remove
err = os.Remove(s.FileName)
c.Assert(err, check.IsNil)
// Read EOF
l, err = r.ReadString('\n')
// c.Check(err, check.Equals, io.ErrUnexpectedEOF) LINUX
// c.Check(err, check.Equals, io.EOF) MAC
c.Check(err, check.Not(check.IsNil))
c.Check(l, check.Equals, "")
}
开发者ID:nagyistge,项目名称:dea_ng,代码行数:28,代码来源:stream_handler_test.go
示例18: TestImagesFilterLabelMatch
func (s *DockerSuite) TestImagesFilterLabelMatch(c *check.C) {
testRequires(c, DaemonIsLinux)
imageName1 := "images_filter_test1"
imageName2 := "images_filter_test2"
imageName3 := "images_filter_test3"
image1ID, err := buildImage(imageName1,
`FROM scratch
LABEL match me`, true)
c.Assert(err, check.IsNil)
image2ID, err := buildImage(imageName2,
`FROM scratch
LABEL match="me too"`, true)
c.Assert(err, check.IsNil)
image3ID, err := buildImage(imageName3,
`FROM scratch
LABEL nomatch me`, true)
c.Assert(err, check.IsNil)
out, _ := dockerCmd(c, "images", "--no-trunc", "-q", "-f", "label=match")
out = strings.TrimSpace(out)
c.Assert(out, check.Matches, fmt.Sprintf("[\\s\\w:]*%s[\\s\\w:]*", image1ID))
c.Assert(out, check.Matches, fmt.Sprintf("[\\s\\w:]*%s[\\s\\w:]*", image2ID))
c.Assert(out, check.Not(check.Matches), fmt.Sprintf("[\\s\\w:]*%s[\\s\\w:]*", image3ID))
out, _ = dockerCmd(c, "images", "--no-trunc", "-q", "-f", "label=match=me too")
out = strings.TrimSpace(out)
c.Assert(out, check.Equals, image2ID)
}
开发者ID:Neverous,项目名称:other-docker,代码行数:30,代码来源:docker_cli_images_test.go
示例19: TestCreateUnsetEntrypoint
// Test case for #23498
func (s *DockerSuite) TestCreateUnsetEntrypoint(c *check.C) {
name := "test-entrypoint"
dockerfile := `FROM busybox
ADD entrypoint.sh /entrypoint.sh
RUN chmod 755 /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD echo foobar`
ctx, err := fakeContext(dockerfile, map[string]string{
"entrypoint.sh": `#!/bin/sh
echo "I am an entrypoint"
exec "[email protected]"`,
})
c.Assert(err, check.IsNil)
defer ctx.Close()
_, err = buildImageFromContext(name, ctx, true)
c.Assert(err, check.IsNil)
out, _ := dockerCmd(c, "create", "--entrypoint=", name, "echo", "foo")
id := strings.TrimSpace(out)
c.Assert(id, check.Not(check.Equals), "")
out, _ = dockerCmd(c, "start", "-a", id)
c.Assert(strings.TrimSpace(out), check.Equals, "foo")
}
开发者ID:SUSE,项目名称:docker.mirror,代码行数:26,代码来源:docker_cli_create_test.go
示例20: NewDaemon
// NewDaemon returns a Daemon instance to be used for testing.
// This will create a directory such as d123456789 in the folder specified by $DEST.
// The daemon will not automatically start.
func NewDaemon(c *check.C) *Daemon {
dest := os.Getenv("DEST")
c.Assert(dest, check.Not(check.Equals), "", check.Commentf("Please set the DEST environment variable"))
id := fmt.Sprintf("d%d", time.Now().UnixNano()%100000000)
dir := filepath.Join(dest, id)
daemonFolder, err := filepath.Abs(dir)
c.Assert(err, check.IsNil, check.Commentf("Could not make %q an absolute path", dir))
daemonRoot := filepath.Join(daemonFolder, "root")
c.Assert(os.MkdirAll(daemonRoot, 0755), check.IsNil, check.Commentf("Could not create daemon root %q", dir))
userlandProxy := true
if env := os.Getenv("DOCKER_USERLANDPROXY"); env != "" {
if val, err := strconv.ParseBool(env); err != nil {
userlandProxy = val
}
}
return &Daemon{
Command: "daemon",
id: id,
c: c,
folder: daemonFolder,
root: daemonRoot,
storageDriver: os.Getenv("DOCKER_GRAPHDRIVER"),
userlandProxy: userlandProxy,
}
}
开发者ID:fsoppelsa,项目名称:docker,代码行数:32,代码来源:docker_utils.go
注:本文中的github.com/go-check/check.Not函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论