summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--roles/sane_debian_system/subplot.md15
-rw-r--r--subplot/subplot.py18
-rw-r--r--subplot/subplot.yaml9
3 files changed, 40 insertions, 2 deletions
diff --git a/roles/sane_debian_system/subplot.md b/roles/sane_debian_system/subplot.md
index b9c47e9..af2a53f 100644
--- a/roles/sane_debian_system/subplot.md
+++ b/roles/sane_debian_system/subplot.md
@@ -25,3 +25,18 @@ sane_debian_system_version: 0
debian_codename: buster
hostname: saneone
~~~
+
+## Checks that debian codename is set
+
+~~~scenario
+given a host running Debian
+when I use role sane_debian_system
+and I use variables from sane2.yml
+and I try to run the playbook
+then the command fails
+and stdout contains "debian_codename"
+~~~
+
+~~~{#sane2.yml .file .yaml}
+sane_debian_system_version: 0
+~~~
diff --git a/subplot/subplot.py b/subplot/subplot.py
index 596e8dd..537c353 100644
--- a/subplot/subplot.py
+++ b/subplot/subplot.py
@@ -84,9 +84,8 @@ def set_vars_file(ctx, filename=None):
f.write(data)
-def run_playbook(ctx):
+def try_playbook(ctx):
runcmd = globals()["runcmd"]
- exit_code_zero = globals()["exit_code_zero"]
assert_ne = globals()["assert_ne"]
srcdir = globals()["srcdir"]
@@ -128,4 +127,19 @@ def run_playbook(ctx):
]
runcmd(ctx, argv, env=env)
+
+
+def command_fails(ctx):
+ exit_code_nonzero = globals()["exit_code_nonzero"]
+ exit_code_nonzero(ctx)
+
+
+def run_playbook(ctx):
+ exit_code_zero = globals()["exit_code_zero"]
+ try_playbook(ctx)
exit_code_zero(ctx)
+
+
+def xstdout_contains(ctx, text=None):
+ stdout_contains = globals()["stdout_contains"]
+ stdout_contains(ctx, pattern=text)
diff --git a/subplot/subplot.yaml b/subplot/subplot.yaml
index 01c85f5..5993feb 100644
--- a/subplot/subplot.yaml
+++ b/subplot/subplot.yaml
@@ -13,3 +13,12 @@
- when: I run the playbook
function: run_playbook
+
+- when: I try to run the playbook
+ function: try_playbook
+
+- then: the command fails
+ function: command_fails
+
+- then: stdout contains "{text:text}"
+ function: xstdout_contains