summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/tests/except-multi.bash21
-rw-r--r--test/tests/except.bash31
-rw-r--r--test/tests/only-multi.bash20
-rw-r--r--test/tests/only.bash31
4 files changed, 103 insertions, 0 deletions
diff --git a/test/tests/except-multi.bash b/test/tests/except-multi.bash
new file mode 100644
index 0000000..4193e66
--- /dev/null
+++ b/test/tests/except-multi.bash
@@ -0,0 +1,21 @@
+test_description='--except with multiple arguments'
+. '../test-lib.bash'
+
+test_expect_success 'setup' '
+ln -s ${DOTFILES}/nonexistent ~/bad && touch ${DOTFILES}/y
+'
+
+test_expect_success 'run' '
+run_dotbot --except clean shell <<EOF
+- clean: ["~"]
+- shell:
+ - echo "x" > ~/x
+- link:
+ ~/y: y
+EOF
+'
+
+test_expect_success 'test' '
+[ "$(readlink ~/bad | cut -d/ -f4-)" = "dotfiles/nonexistent" ] &&
+ ! test -f ~/x && test -f ~/y
+'
diff --git a/test/tests/except.bash b/test/tests/except.bash
new file mode 100644
index 0000000..356eaef
--- /dev/null
+++ b/test/tests/except.bash
@@ -0,0 +1,31 @@
+test_description='--except'
+. '../test-lib.bash'
+
+test_expect_success 'setup' '
+echo "apple" > ${DOTFILES}/x
+'
+
+test_expect_success 'run' '
+run_dotbot --except link <<EOF
+- shell:
+ - echo "pear" > ~/y
+- link:
+ ~/x: x
+EOF
+'
+
+test_expect_success 'test' '
+grep "pear" ~/y && ! test -f ~/x
+'
+
+test_expect_success 'run 2' '
+run_dotbot --except shell <<EOF
+- shell:
+ - echo "pear" > ~/z
+- link:
+ ~/x: x
+'
+
+test_expect_success 'test' '
+grep "apple" ~/x && ! test -f ~/z
+'
diff --git a/test/tests/only-multi.bash b/test/tests/only-multi.bash
new file mode 100644
index 0000000..e8d8362
--- /dev/null
+++ b/test/tests/only-multi.bash
@@ -0,0 +1,20 @@
+test_description='--only with multiple arguments'
+. '../test-lib.bash'
+
+test_expect_success 'setup' '
+ln -s ${DOTFILES}/nonexistent ~/bad && touch ${DOTFILES}/y
+'
+
+test_expect_success 'run' '
+run_dotbot --only clean shell <<EOF
+- clean: ["~"]
+- shell:
+ - echo "x" > ~/x
+- link:
+ ~/y: y
+EOF
+'
+
+test_expect_success 'test' '
+! test -f ~/bad && grep "x" ~/x && ! test -f ~/y
+'
diff --git a/test/tests/only.bash b/test/tests/only.bash
new file mode 100644
index 0000000..5222881
--- /dev/null
+++ b/test/tests/only.bash
@@ -0,0 +1,31 @@
+test_description='--only'
+. '../test-lib.bash'
+
+test_expect_success 'setup' '
+echo "apple" > ${DOTFILES}/x
+'
+
+test_expect_success 'run' '
+run_dotbot --only shell <<EOF
+- shell:
+ - echo "pear" > ~/y
+- link:
+ ~/x: x
+EOF
+'
+
+test_expect_success 'test' '
+grep "pear" ~/y && ! test -f ~/x
+'
+
+test_expect_success 'run 2' '
+run_dotbot --only link <<EOF
+- shell:
+ - echo "pear" > ~/z
+- link:
+ ~/x: x
+'
+
+test_expect_success 'test' '
+grep "apple" ~/x && ! test -f ~/z
+'