From 75617fe5eb927b890e36ff032ee39424ee829b7b Mon Sep 17 00:00:00 2001
From: ibizaman <ibizapeanut@gmail.com>
Date: Wed, 29 May 2024 14:43:12 -0700
Subject: [PATCH] wait for nextcloud-cron to finish in test

---
 test/vm/nextcloud.nix | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/test/vm/nextcloud.nix b/test/vm/nextcloud.nix
index b1d7d8d..76bc3ec 100644
--- a/test/vm/nextcloud.nix
+++ b/test/vm/nextcloud.nix
@@ -13,6 +13,7 @@ let
     import json
     import os
     import pathlib
+    import time
 
     start_all()
     server.wait_for_unit("phpfpm-nextcloud.service")
@@ -47,7 +48,12 @@ let
         server.systemctl("start nextcloud-cron.service")
 
         # If the service failed, then we're not happy.
-        server.require_unit_state("nextcloud-cron", "inactive")
+        status = "active"
+        while status == "active":
+            status = server.get_unit_info("nextcloud-cron")["ActiveState"]
+            time.sleep(5)
+        if status != "inactive":
+            raise Exception("Cron job did not finish correctly")
 
         if not find_in_logs("nextcloud-cron", "nextcloud-cron.service: Deactivated successfully."):
             raise Exception("Nextcloud cron job did not finish successfully.")