summaryrefslogtreecommitdiff
path: root/subplot/client.py
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2020-12-06 10:01:36 +0200
committerLars Wirzenius <liw@liw.fi>2020-12-06 18:36:53 +0200
commit7dfd06673384077157186ef88a554b7a2876d87e (patch)
treebd131f92684b56ff4ab781044be84ec8303079ec /subplot/client.py
parente322d41557d43c027ae36bb24d9399944ed2a05f (diff)
downloadobnam2-7dfd06673384077157186ef88a554b7a2876d87e.tar.gz
test: change backup/restore smoke test to verify metadata
Diffstat (limited to 'subplot/client.py')
-rw-r--r--subplot/client.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/subplot/client.py b/subplot/client.py
index acdc48a..75baa8f 100644
--- a/subplot/client.py
+++ b/subplot/client.py
@@ -47,6 +47,35 @@ def capture_generation_id(ctx, varname=None):
ctx["vars"] = v
+def create_manifest_of_live(ctx, dirname=None, manifest=None):
+ _create_manifest_of_directory(ctx, dirname=dirname, manifest=manifest)
+
+
+def create_manifest_of_restored(ctx, dirname=None, restored=None, manifest=None):
+ _create_manifest_of_directory(
+ ctx, dirname=os.path.join(restored, "./" + dirname), manifest=manifest
+ )
+
+
+def _create_manifest_of_directory(ctx, dirname=None, manifest=None):
+ runcmd_run = globals()["runcmd_run"]
+ runcmd_get_exit_code = globals()["runcmd_get_exit_code"]
+ runcmd_get_stdout = globals()["runcmd_get_stdout"]
+
+ runcmd_run(ctx, ["summain", dirname])
+ assert runcmd_get_exit_code(ctx) == 0
+ stdout = runcmd_get_stdout(ctx)
+ open(manifest, "w").write(stdout)
+
+
+def files_match(ctx, first=None, second=None):
+ assert_eq = globals()["assert_eq"]
+
+ f = open(first).read()
+ s = open(first).read()
+ assert_eq(f, s)
+
+
def live_and_restored_data_match(ctx, live=None, restore=None):
subprocess.check_call(["diff", "-rq", f"{live}/.", f"{restore}/{live}/."])