summaryrefslogtreecommitdiff
path: root/subplot
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-04-09 17:47:58 +0300
committerLars Wirzenius <liw@liw.fi>2021-04-09 17:47:58 +0300
commita742941804dd6f4b1ea3f39dfe3c7072b4b50e6b (patch)
tree286d2c03c2346b195c2989488d4da1e967a7c2e9 /subplot
parentd0b0245edbb2f6ed8285358d83b98f3334bf1b12 (diff)
downloadobnam2-a742941804dd6f4b1ea3f39dfe3c7072b4b50e6b.tar.gz
refactor: make tests install a config in the default location
This way, every step doesn't need to specify a --config option to the Obnam client.
Diffstat (limited to 'subplot')
-rw-r--r--subplot/client.py33
-rw-r--r--subplot/client.yaml4
2 files changed, 13 insertions, 24 deletions
diff --git a/subplot/client.py b/subplot/client.py
index 90642f3..1ddc772 100644
--- a/subplot/client.py
+++ b/subplot/client.py
@@ -26,38 +26,27 @@ def configure_client(ctx, filename=None):
config["server_url"] = ctx["server_url"]
logging.debug(f"client config {filename}: {config}")
+ dirname = os.path.expanduser("~/.config/obnam")
+ if not os.path.exists(dirname):
+ os.makedirs(dirname)
+ filename = os.path.join(dirname, "obnam.yaml")
+ logging.debug(f"configure_client: filename={filename}")
with open(filename, "w") as f:
yaml.safe_dump(config, stream=f)
-def run_obnam_restore(ctx, filename=None, genid=None, todir=None):
- genid = ctx["vars"][genid]
- run_obnam_restore_with_genref(ctx, filename=filename, genref=genid, todir=todir)
+def run_obnam_restore(ctx, genid=None, todir=None):
+ runcmd_run = globals()["runcmd_run"]
+ genref = ctx["vars"][genid]
+ runcmd_run(ctx, ["env", "RUST_LOG=obnam", "obnam", "restore", genref, todir])
-def run_obnam_restore_with_genref(ctx, filename=None, genref=None, todir=None):
- runcmd_run = globals()["runcmd_run"]
- runcmd_run(
- ctx,
- [
- "env",
- "RUST_LOG=obnam",
- "obnam",
- "--config",
- filename,
- "restore",
- genref,
- todir,
- ],
- )
-
-
-def run_obnam_get_chunk(ctx, filename=None, gen_id=None, todir=None):
+def run_obnam_get_chunk(ctx, gen_id=None, todir=None):
runcmd_run = globals()["runcmd_run"]
gen_id = ctx["vars"][gen_id]
logging.debug(f"run_obnam_get_chunk: gen_id={gen_id}")
- runcmd_run(ctx, ["obnam", "--config", filename, "get-chunk", gen_id])
+ runcmd_run(ctx, ["obnam", "get-chunk", gen_id])
def capture_generation_id(ctx, varname=None):
diff --git a/subplot/client.yaml b/subplot/client.yaml
index eba9212..8c76e9f 100644
--- a/subplot/client.yaml
+++ b/subplot/client.yaml
@@ -5,10 +5,10 @@
- given: "a client config based on {filename}"
function: configure_client
-- when: "I invoke obnam --config {filename} restore <{genid}> {todir}"
+- when: "I invoke obnam restore <{genid}> {todir}"
function: run_obnam_restore
-- when: "I invoke obnam --config {filename} get-chunk <{gen_id}>"
+- when: "I invoke obnam get-chunk <{gen_id}>"
function: run_obnam_get_chunk
- then: "backup generation is {varname}"