|
@@ -414,7 +414,7 @@ func TestPsListContainersFilterName(t *testing.T) {
|
|
|
|
|
|
func TestPsListContainersFilterLabel(t *testing.T) {
|
|
|
// start container
|
|
|
- runCmd := exec.Command(dockerBinary, "run", "-d", "-l", "match=me", "busybox")
|
|
|
+ runCmd := exec.Command(dockerBinary, "run", "-d", "-l", "match=me", "-l", "second=tag", "busybox")
|
|
|
out, _, err := runCommandWithOutput(runCmd)
|
|
|
if err != nil {
|
|
|
t.Fatal(out, err)
|
|
@@ -445,6 +445,26 @@ func TestPsListContainersFilterLabel(t *testing.T) {
|
|
|
t.Fatalf("Expected id %s, got %s for exited filter, output: %q", firstID, containerOut, out)
|
|
|
}
|
|
|
|
|
|
+ // filter containers by two labels
|
|
|
+ runCmd = exec.Command(dockerBinary, "ps", "-a", "-q", "--no-trunc", "--filter=label=match=me", "--filter=label=second=tag")
|
|
|
+ if out, _, err = runCommandWithOutput(runCmd); err != nil {
|
|
|
+ t.Fatal(out, err)
|
|
|
+ }
|
|
|
+ containerOut = strings.TrimSpace(out)
|
|
|
+ if containerOut != firstID {
|
|
|
+ t.Fatalf("Expected id %s, got %s for exited filter, output: %q", firstID, containerOut, out)
|
|
|
+ }
|
|
|
+
|
|
|
+ // filter containers by two labels, but expect not found because of AND behavior
|
|
|
+ runCmd = exec.Command(dockerBinary, "ps", "-a", "-q", "--no-trunc", "--filter=label=match=me", "--filter=label=second=tag-no")
|
|
|
+ if out, _, err = runCommandWithOutput(runCmd); err != nil {
|
|
|
+ t.Fatal(out, err)
|
|
|
+ }
|
|
|
+ containerOut = strings.TrimSpace(out)
|
|
|
+ if containerOut != "" {
|
|
|
+ t.Fatalf("Expected nothing, got %s for exited filter, output: %q", containerOut, out)
|
|
|
+ }
|
|
|
+
|
|
|
// filter containers by exact key
|
|
|
runCmd = exec.Command(dockerBinary, "ps", "-a", "-q", "--no-trunc", "--filter=label=match")
|
|
|
if out, _, err = runCommandWithOutput(runCmd); err != nil {
|