summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAnish Athalye <me@anishathalye.com>2016-02-06 13:54:19 -0500
committerAnish Athalye <me@anishathalye.com>2016-02-06 15:23:39 -0500
commitc402396c58114640745dbba132856cfd8cd7f422 (patch)
tree73a1a76674cc573547a1b725b907931e4178e564 /test
parentaaf093b1240d7ea34dd6484ce01438f2329d1a8d (diff)
Add documentation and tests for plugins
Diffstat (limited to 'test')
-rw-r--r--test/tests/plugin-dir.bash29
-rw-r--r--test/tests/plugin.bash28
2 files changed, 57 insertions, 0 deletions
diff --git a/test/tests/plugin-dir.bash b/test/tests/plugin-dir.bash
new file mode 100644
index 0000000..299f144
--- /dev/null
+++ b/test/tests/plugin-dir.bash
@@ -0,0 +1,29 @@
+test_description='directory-based plugin loading works'
+. '../test-lib.bash'
+
+test_expect_success 'setup' '
+mkdir ${DOTFILES}/plugins
+cat > ${DOTFILES}/plugins/test.py <<EOF
+import dotbot
+import os.path
+
+class Test(dotbot.Plugin):
+ def can_handle(self, directive):
+ return directive == "test"
+
+ def handle(self, directive, data):
+ with open(os.path.expanduser("~/flag"), "w") as f:
+ f.write("it works")
+ return True
+EOF
+'
+
+test_expect_success 'run' '
+run_dotbot --plugin-dir plugins <<EOF
+- test: ~
+EOF
+'
+
+test_expect_success 'test' '
+grep "it works" ~/flag
+'
diff --git a/test/tests/plugin.bash b/test/tests/plugin.bash
new file mode 100644
index 0000000..960e9ce
--- /dev/null
+++ b/test/tests/plugin.bash
@@ -0,0 +1,28 @@
+test_description='plugin loading works'
+. '../test-lib.bash'
+
+test_expect_success 'setup' '
+cat > ${DOTFILES}/test.py <<EOF
+import dotbot
+import os.path
+
+class Test(dotbot.Plugin):
+ def can_handle(self, directive):
+ return directive == "test"
+
+ def handle(self, directive, data):
+ with open(os.path.expanduser("~/flag"), "w") as f:
+ f.write("it works")
+ return True
+EOF
+'
+
+test_expect_success 'run' '
+run_dotbot --plugin test.py <<EOF
+- test: ~
+EOF
+'
+
+test_expect_success 'test' '
+grep "it works" ~/flag
+'