1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/integration/server_test.go

72 lines
1.8 KiB
Go
Raw Normal View History

2013-05-06 16:59:33 +02:00
package docker
import "testing"
2013-05-06 16:59:33 +02:00
func TestCreateNumberHostname(t *testing.T) {
eng := NewTestEngine(t)
defer mkDaemonFromEngine(eng, t).Nuke()
config, _, _, err := parseRun([]string{"-h", "web.0", unitTestImageID, "echo test"})
if err != nil {
t.Fatal(err)
}
createTestContainer(eng, config, t)
}
func TestRunWithTooLowMemoryLimit(t *testing.T) {
eng := NewTestEngine(t)
defer mkDaemonFromEngine(eng, t).Nuke()
// Try to create a container with a memory limit of 1 byte less than the minimum allowed limit.
job := eng.Job("create")
job.Setenv("Image", unitTestImageID)
job.Setenv("Memory", "524287")
job.Setenv("CpuShares", "1000")
job.SetenvList("Cmd", []string{"/bin/cat"})
if err := job.Run(); err == nil {
t.Errorf("Memory limit is smaller than the allowed limit. Container creation should've failed!")
}
}
2013-09-06 16:16:10 -04:00
func TestImagesFilter(t *testing.T) {
eng := NewTestEngine(t)
defer nuke(mkDaemonFromEngine(eng, t))
2013-09-06 16:16:10 -04:00
2013-12-11 17:52:41 -08:00
if err := eng.Job("tag", unitTestImageName, "utest", "tag1").Run(); err != nil {
2013-09-06 16:16:10 -04:00
t.Fatal(err)
}
2013-12-11 17:52:41 -08:00
if err := eng.Job("tag", unitTestImageName, "utest/docker", "tag2").Run(); err != nil {
2013-09-06 16:16:10 -04:00
t.Fatal(err)
}
2013-12-11 17:52:41 -08:00
if err := eng.Job("tag", unitTestImageName, "utest:5000/docker", "tag3").Run(); err != nil {
2013-09-06 16:16:10 -04:00
t.Fatal(err)
}
images := getImages(eng, t, false, "utest*/*")
2013-09-06 16:16:10 -04:00
if len(images[0].RepoTags) != 2 {
2013-09-06 16:16:10 -04:00
t.Fatal("incorrect number of matches returned")
}
images = getImages(eng, t, false, "utest")
2013-09-06 16:16:10 -04:00
if len(images[0].RepoTags) != 1 {
2013-09-06 16:16:10 -04:00
t.Fatal("incorrect number of matches returned")
}
images = getImages(eng, t, false, "utest*")
2013-09-06 16:16:10 -04:00
if len(images[0].RepoTags) != 1 {
2013-09-06 16:16:10 -04:00
t.Fatal("incorrect number of matches returned")
}
images = getImages(eng, t, false, "*5000*/*")
2013-09-06 16:16:10 -04:00
if len(images[0].RepoTags) != 1 {
2013-09-06 16:16:10 -04:00
t.Fatal("incorrect number of matches returned")
}
}