From 420754b0a00450345f0597e4926a8eb3bc99d416 Mon Sep 17 00:00:00 2001 From: Alberto Bertogli Date: Sun, 25 Feb 2018 03:24:57 +0000 Subject: [PATCH] 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 ++++++ internal/dovecot/dovecot_test.go | 8 ++++++++ 2 files changed, 14 insertions(+) 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 {