From c28a43efd74d05f4994d295d7af280bed344f5ec Mon Sep 17 00:00:00 2001
From: Daniel J Walsh <dwalsh@redhat.com>
Date: Tue, 13 Jun 2023 15:56:04 -0400
Subject: [PATCH] Verify podman pull dup image only prints id once

Fixes: #18647

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
---
 test/system/010-images.bats | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/test/system/010-images.bats b/test/system/010-images.bats
index ffcedb9880..ca3fc78dbc 100644
--- a/test/system/010-images.bats
+++ b/test/system/010-images.bats
@@ -330,4 +330,33 @@ Deleted: $pauseID"
     run_podman rm my-container --force -t 0
 }
 
+@test "podman pull image with additional store" {
+    skip_if_remote "only works on local"
+
+    local imstore=$PODMAN_TMPDIR/imagestore
+    local sconf=$PODMAN_TMPDIR/storage.conf
+    cat >$sconf <<EOF
+[storage]
+driver="overlay"
+
+[storage.options]
+additionalimagestores = [ "$imstore/root" ]
+EOF
+
+    skopeo copy containers-storage:$IMAGE \
+           containers-storage:\[overlay@$imstore/root+$imstore/runroot\]$IMAGE
+
+    CONTAINERS_STORAGE_CONF=$sconf run_podman images -a -n --format "{{.Repository}}:{{.Tag}} {{.ReadOnly}}"
+    is "${lines[0]}" "$IMAGE false" "image from readonly store"
+    is "${lines[1]}" "$IMAGE true" "image from readwrite store"
+
+    CONTAINERS_STORAGE_CONF=$sconf run_podman images -a -n --format "{{.Id}}"
+    id=${lines[0]}
+
+    CONTAINERS_STORAGE_CONF=$sconf run_podman pull -q $IMAGE
+    is "$output" "$id" "Should only print one line"
+
+    run_podman --root $imstore/root rmi --all
+}
+
 # vim: filetype=sh