aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlavio Castelli <fcastelli@suse.com>2017-03-03 21:22:44 +0100
committerAlvaro <alvaro.saurin@gmail.com>2017-03-14 13:23:13 +0100
commit42212d41b0fe9f86c20b65b415fa8ddd319d6e85 (patch)
treeb86c9a9c987d27a3f399301ea4ffbdb14919f9e1
parent7bcecfecfe90390ea14d27c324111a1224b86280 (diff)
downloadterraform-provider-libvirt-42212d41b0fe9f86c20b65b415fa8ddd319d6e85.tar
terraform-provider-libvirt-42212d41b0fe9f86c20b65b415fa8ddd319d6e85.tar.gz
Test coverage for pool sync
-rw-r--r--libvirt/pool_sync_test.go46
1 files changed, 46 insertions, 0 deletions
diff --git a/libvirt/pool_sync_test.go b/libvirt/pool_sync_test.go
new file mode 100644
index 00000000..630ae2a4
--- /dev/null
+++ b/libvirt/pool_sync_test.go
@@ -0,0 +1,46 @@
+package libvirt
+
+import (
+ "testing"
+)
+
+func TestAcquireLock(t *testing.T) {
+ ps := NewLibVirtPoolSync()
+
+ ps.AcquireLock("test")
+
+ _, found := ps.PoolLocks["test"]
+
+ if !found {
+ t.Errorf("lock not found")
+ }
+}
+
+func TestReleaseLock(t *testing.T) {
+ ps := NewLibVirtPoolSync()
+
+ ps.AcquireLock("test")
+
+ _, found := ps.PoolLocks["test"]
+ if !found {
+ t.Errorf("lock not found")
+ }
+
+ ps.ReleaseLock("test")
+ _, found = ps.PoolLocks["test"]
+ if !found {
+ t.Errorf("lock not found")
+ }
+}
+
+func TestReleaseNotExistingLock(t *testing.T) {
+ ps := NewLibVirtPoolSync()
+
+ ps.ReleaseLock("test")
+ _, found := ps.PoolLocks["test"]
+ if found {
+ t.Errorf("lock found")
+ }
+ // moreover there should be no runtime error because
+ // we are not trying to unlock a not-locked mutex
+}