From 8ff88f52d883ab463e752745d64d0cc2379a7930 Mon Sep 17 00:00:00 2001
From: Lukas Braun <lukas.braun@fau.de>
Date: Mon, 9 Oct 2017 20:56:06 +0200
Subject: [PATCH] goatherd_test: Check if userlocks entry exists before
 (un-)locked

---
 goatherd_test.go | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/goatherd_test.go b/goatherd_test.go
index b357b2a..0cec2a5 100644
--- a/goatherd_test.go
+++ b/goatherd_test.go
@@ -278,8 +278,8 @@ func handleConnT(t *testing.T) {
 		if answer != "" {
 			t.Error("answer:", answer)
 		}
-		if faildelay.userlocks["dummy user"] != nil {
-			t.Error("userlock created for dummy user")
+		if _, ok := faildelay.userlocks["dummy user"]; ok {
+			t.Error("userlock entry created for dummy user")
 		}
 	})
 
@@ -296,8 +296,10 @@ func handleConnT(t *testing.T) {
 		if answer != "FAIL" {
 			t.Error("answer:", answer)
 		}
-		if faildelay.userlocks[username] == nil {
-			t.Error("userlock not in map")
+		if ul, ok := faildelay.userlocks[username]; !ok {
+			t.Error("no entry in userlocks")
+		} else if ul != delay {
+			t.Error("entry in userlocks is not the returned lock")
 		}
 	})
 
@@ -311,7 +313,9 @@ func handleConnT(t *testing.T) {
 		if delay != nil {
 			t.Fail()
 		}
-		if *faildelay.userlocks[username] != unlocked {
+		if ul, ok := faildelay.userlocks[username]; !ok {
+			t.Error("no entry in userlocks")
+		} else if *ul != unlocked {
 			t.Error("userlock not unlocked")
 		}
 		if answer != "OK" {
-- 
GitLab