mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
c8529fde5f
Signed-off-by: Antonio Murdaca <me@runcom.ninja>
71 lines
1.8 KiB
Go
71 lines
1.8 KiB
Go
package docker
|
|
|
|
import "testing"
|
|
|
|
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!")
|
|
}
|
|
}
|
|
|
|
func TestImagesFilter(t *testing.T) {
|
|
eng := NewTestEngine(t)
|
|
defer nuke(mkDaemonFromEngine(eng, t))
|
|
|
|
if err := eng.Job("tag", unitTestImageName, "utest", "tag1").Run(); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
if err := eng.Job("tag", unitTestImageName, "utest/docker", "tag2").Run(); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
if err := eng.Job("tag", unitTestImageName, "utest:5000/docker", "tag3").Run(); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
images := getImages(eng, t, false, "utest*/*")
|
|
|
|
if len(images[0].RepoTags) != 2 {
|
|
t.Fatal("incorrect number of matches returned")
|
|
}
|
|
|
|
images = getImages(eng, t, false, "utest")
|
|
|
|
if len(images[0].RepoTags) != 1 {
|
|
t.Fatal("incorrect number of matches returned")
|
|
}
|
|
|
|
images = getImages(eng, t, false, "utest*")
|
|
|
|
if len(images[0].RepoTags) != 1 {
|
|
t.Fatal("incorrect number of matches returned")
|
|
}
|
|
|
|
images = getImages(eng, t, false, "*5000*/*")
|
|
|
|
if len(images[0].RepoTags) != 1 {
|
|
t.Fatal("incorrect number of matches returned")
|
|
}
|
|
}
|