From 9435e5b79b3dacca61118b159b06fa38cb1ac0d8 Mon Sep 17 00:00:00 2001 From: Ed Santiago Date: Mon, 1 Mar 2021 10:47:48 -0700 Subject: APIv2 tests: make more maintainable While I wasn't looking, some completely unreadable cruft crept in here, and it's totally my fault: I never knew you could pass JSON to a GET query. Everyone who DID know that, did so, but had to URL-escape it into a completely gobbledygook mess to make curl happy. Solution: trivial, do the URL-escaping in 't' itself. I just never realized that was needed. I'm so sorry. I hope this helps. Signed-off-by: Ed Santiago --- test/apiv2/30-volumes.at | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) (limited to 'test/apiv2/30-volumes.at') diff --git a/test/apiv2/30-volumes.at b/test/apiv2/30-volumes.at index b38810039..cf4b3d3ea 100644 --- a/test/apiv2/30-volumes.at +++ b/test/apiv2/30-volumes.at @@ -45,18 +45,17 @@ t GET libpod/volumes/json 200 \ .[0].Name~.* \ .[0].Mountpoint~.* \ .[0].CreatedAt~[0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}.* -# -G --data-urlencode 'filters={"name":["foo1"]}' -t GET libpod/volumes/json?filters=%7B%22name%22%3A%5B%22foo1%22%5D%7D 200 length=1 .[0].Name=foo1 -# -G --data-urlencode 'filters={"name":["foo1","foo2"]}' -t GET libpod/volumes/json?filters=%7B%22name%22%3A%20%5B%22foo1%22%2C%20%22foo2%22%5D%7D 200 length=2 .[0].Name=foo1 .[1].Name=foo2 -# -G --data-urlencode 'filters={"name":["nonexistent"]}' -t GET libpod/volumes/json?filters=%7B%22name%22%3A%5B%22nonexistent%22%5D%7D 200 length=0 -# -G --data-urlencode 'filters={"label":["testlabel"]}' -t GET libpod/volumes/json?filters=%7B%22label%22:%5B%22testlabel%22%5D%7D 200 length=2 -# -G --data-urlencode 'filters={"label":["testlabel=testonly"]}' -t GET libpod/volumes/json?filters=%7B%22label%22:%5B%22testlabel=testonly%22%5D%7D 200 length=1 -# -G --data-urlencode 'filters={"label":["testlabel1=testonly"]}' -t GET libpod/volumes/json?filters=%7B%22label%22:%5B%22testlabel1=testonly%22%5D%7D 200 length=1 +t GET libpod/volumes/json?filters='{"name":["foo1"]}' 200 \ + length=1 \ + .[0].Name=foo1 +t GET libpod/volumes/json?filters='{"name":%20["foo1",%20"foo2"]}' 200 \ + length=2 \ + .[0].Name=foo1 \ + .[1].Name=foo2 +t GET libpod/volumes/json?filters='{"name":["nonexistent"]}' 200 length=0 +t GET libpod/volumes/json?filters='{"label":["testlabel"]}' 200 length=2 +t GET libpod/volumes/json?filters='{"label":["testlabel=testonly"]}' 200 length=1 +t GET libpod/volumes/json?filters='{"label":["testlabel1=testonly"]}' 200 length=1 ## inspect volume t GET libpod/volumes/foo1/json 200 \ @@ -79,16 +78,12 @@ t DELETE libpod/volumes/foo1 404 \ .response=404 ## Prune volumes with label matching 'testlabel1=testonly' -# -G --data-urlencode 'filters={"label":["testlabel1=testonly"]}' -t POST libpod/volumes/prune?filters=%7B%22label%22:%5B%22testlabel1=testonly%22%5D%7D "" 200 -# -G --data-urlencode 'filters={"label":["testlabel1=testonly"]}' -t GET libpod/volumes/json?filters=%7B%22label%22:%5B%22testlabel1=testonly%22%5D%7D 200 length=0 +t POST libpod/volumes/prune?filters='{"label":["testlabel1=testonly"]}' "" 200 +t GET libpod/volumes/json?filters='{"label":["testlabel1=testonly"]}' 200 length=0 ## Prune volumes with label matching 'testlabel' -# -G --data-urlencode 'filters={"label":["testlabel"]}' -t POST libpod/volumes/prune?filters=%7B%22label%22:%5B%22testlabel%22%5D%7D "" 200 -# -G --data-urlencode 'filters={"label":["testlabel"]}' -t GET libpod/volumes/json?filters=%7B%22label%22:%5B%22testlabel%22%5D%7D 200 length=0 +t POST libpod/volumes/prune?filters='{"label":["testlabel"]}' "" 200 +t GET libpod/volumes/json?filters='{"label":["testlabel"]}' 200 length=0 ## Prune volumes t POST libpod/volumes/prune "" 200 -- cgit v1.2.3-54-g00ecf