From 8a09ba967a636bbdb9cc76c922e5cfc7f0c82626 Mon Sep 17 00:00:00 2001 From: Taeer Bar-Yam Date: Mon, 9 Sep 2024 10:13:23 -0400 Subject: [PATCH] test image gets uploaded to garage --- tests/pixelfed-garage.nix | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tests/pixelfed-garage.nix b/tests/pixelfed-garage.nix index e3f72f2..ded7778 100644 --- a/tests/pixelfed-garage.nix +++ b/tests/pixelfed-garage.nix @@ -125,9 +125,9 @@ pkgs.nixosTest { imagemagick ]; environment.variables = { - # AWS_ACCESS_KEY_ID = config.services.garage.ensureKeys.pixelfed.id; - # AWS_SECRET_ACCESS_KEY = config.services.garage.ensureKeys.pixelfed.secret; POST_MEDIA = ./fediversity.png; + AWS_ACCESS_KEY_ID = config.services.garage.ensureKeys.pixelfed.id; + AWS_SECRET_ACCESS_KEY = config.services.garage.ensureKeys.pixelfed.secret; }; # chrome does not like being run as root users.users.selenium = { @@ -161,5 +161,20 @@ pkgs.nixosTest { image_check = re.match(".*#FF0500.*", displayed_colors, re.S) if image_check is None: raise Exception("cannot detect the uploaded image on pixelfed page.") + + with subtest("access garage"): + server.succeed("mc alias set garage http://s3.garage.localhost:3900 --api s3v4 --path off $AWS_ACCESS_KEY_ID $AWS_SECRET_ACCESS_KEY") + server.succeed("mc ls garage/pixelfed") + + with subtest("access image in garage"): + image = server.succeed("mc find garage --regex '\.png' --ignore '*_thumb.png'") + image = image.rstrip() + if image == "": + raise Exception("image posted to mastodon did not get stored in garage") + server.succeed(f"mc cat {image} >/garage-image.png") + garage_image_hash = server.succeed("identify -quiet -format '%#' /garage-image.png") + image_hash = server.succeed("identify -quiet -format '%#' $POST_MEDIA") + if garage_image_hash != image_hash: + raise Exception("image stored in garage did not match image uploaded") ''; }