move test to the daemon

Signed-off-by: Victor Vieux <vieux@docker.com>
This commit is contained in:
Victor Vieux 2015-01-16 21:49:46 +00:00
parent 0e9acf7684
commit c6309229a0
2 changed files with 18 additions and 0 deletions

View file

@ -11,6 +11,8 @@ import (
"github.com/docker/docker/pkg/parsers/filters"
)
var acceptedImageFilterTags = map[string]struct{}{"dangling": {}}
func (s *TagStore) CmdImages(job *engine.Job) engine.Status {
var (
allImages map[string]*image.Image
@ -22,6 +24,12 @@ func (s *TagStore) CmdImages(job *engine.Job) engine.Status {
if err != nil {
return job.Error(err)
}
for name := range imageFilters {
if _, ok := acceptedImageFilterTags[name]; !ok {
return job.Errorf("Invalid filter '%s'", name)
}
}
if i, ok := imageFilters["dangling"]; ok {
for _, value := range i {
if strings.ToLower(value) == "true" {

View file

@ -67,6 +67,16 @@ func TestImagesOrderedByCreationDate(t *testing.T) {
logDone("images - ordering by creation date")
}
func TestImagesErrorWithInvalidFilterNameTest(t *testing.T) {
imagesCmd := exec.Command(dockerBinary, "images", "-f", "FOO=123")
out, _, err := runCommandWithOutput(imagesCmd)
if !strings.Contains(out, "Invalid filter") {
t.Fatalf("error should occur when listing images with invalid filter name FOO, %s, %v", out, err)
}
logDone("images - invalid filter name check working")
}
func TestImagesFilterWhiteSpaceTrimmingAndLowerCasingWorking(t *testing.T) {
imageName := "images_filter_test"
defer deleteAllContainers()