git » chasquid » commit 420754b

auth, dovecot: Add missing Reload tests

author Alberto Bertogli
2018-02-25 03:24:57 UTC
committer Alberto Bertogli
2018-03-02 19:37:37 UTC
parent 61d2961ee92c2aabb55404e9eb073dd62165c66c

auth, dovecot: Add missing Reload tests

auth.wrapNoErrorBackend.Reload and dovecot.Reload were not being tested;
this patch fixes that by adding a simple test for each.

internal/auth/auth_test.go +6 -0
internal/dovecot/dovecot_test.go +8 -0

diff --git a/internal/auth/auth_test.go b/internal/auth/auth_test.go
index 8ebc70f..0a1a124 100644
--- a/internal/auth/auth_test.go
+++ b/internal/auth/auth_test.go
@@ -269,4 +269,10 @@ func TestReload(t *testing.T) {
 		t.Errorf("unexpected reload counts: %d %d %d != 2 2 2",
 			be1.reloadCount, be2.reloadCount, fallback.reloadCount)
 	}
+
+	a2 := NewAuthenticator()
+	a2.Register("domain", WrapNoErrorBackend(userdb.New("/dev/null")))
+	if err = a2.Reload(); err != nil {
+		t.Errorf("unexpected error reloading wrapped backend: %v", err)
+	}
 }
diff --git a/internal/dovecot/dovecot_test.go b/internal/dovecot/dovecot_test.go
index 3fbba86..4fcbfc7 100644
--- a/internal/dovecot/dovecot_test.go
+++ b/internal/dovecot/dovecot_test.go
@@ -96,6 +96,14 @@ func TestAutodetect(t *testing.T) {
 	cL.Close()
 }
 
+func TestReload(t *testing.T) {
+	// Make sure Reload does not fail.
+	a := Auth{}
+	if err := a.Reload(); err != nil {
+		t.Errorf("Reload failed")
+	}
+}
+
 func mustListen(t *testing.T, path string) *net.UnixListener {
 	addr, err := net.ResolveUnixAddr("unix", path)
 	if err != nil {