git » libfiu » commit 3a43154

tests: Add a test for cache invalidation

author Alberto Bertogli
2015-08-02 13:42:53 UTC
committer Alberto Bertogli
2015-08-02 13:51:28 UTC
parent daa8a5c4ba3b9669d2f4869fc43b84da5e08ab2f

tests: Add a test for cache invalidation

This patch adds some tests which perform operations that rely on cache
invalidation working correctly.

tests/test-cache_invalidation.py +22 -0

diff --git a/tests/test-cache_invalidation.py b/tests/test-cache_invalidation.py
new file mode 100644
index 0000000..ad2954a
--- /dev/null
+++ b/tests/test-cache_invalidation.py
@@ -0,0 +1,22 @@
+"""
+Tests to make sure cache invalidation works.
+"""
+
+import fiu
+
+# Unknown - add - fail - remove - not fail.
+# The initial unknown is relevant because it places a negative match in the
+# cache.
+assert not fiu.fail('p1')
+fiu.enable('p1')
+assert fiu.fail('p1')
+fiu.disable('p1')
+assert not fiu.fail('p1')
+
+# Same as above, but with wildcards.
+assert not fiu.fail('p2/x')
+fiu.enable('p2/*')
+assert fiu.fail('p2/x')
+fiu.disable('p2/*')
+assert not fiu.fail('p2/x')
+