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) + } +}