From 4c0d4dd780d0439f03d1dd7fb07329587bd8c031 Mon Sep 17 00:00:00 2001 From: Paulo L F Casaretto Date: Mon, 19 Oct 2015 23:19:12 -0200 Subject: [PATCH] Test makeOnces function --- config/config_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/config/config_test.go b/config/config_test.go index 75678419..5c5fd132 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -1,6 +1,8 @@ package config import ( + "reflect" + "sync" "testing" "github.com/mholt/caddy/server" @@ -62,3 +64,22 @@ func TestResolveAddr(t *testing.T) { } } } + +func TestMakeOnces(t *testing.T) { + directives := []directive{ + {"dummy", nil}, + {"dummy2", nil}, + } + directiveOrder = directives + onces := makeOnces() + if len(onces) != len(directives) { + t.Errorf("onces had len %d , expected %d", len(onces), len(directives)) + } + expected := map[string]*sync.Once{ + "dummy": new(sync.Once), + "dummy2": new(sync.Once), + } + if !reflect.DeepEqual(onces, expected) { + t.Errorf("onces was %v, expected %v", onces, expected) + } +}