Commit 4c0d4dd7 authored by Paulo L F Casaretto's avatar Paulo L F Casaretto

Test makeOnces function

parent acf43857
package config package config
import ( import (
"reflect"
"sync"
"testing" "testing"
"github.com/mholt/caddy/server" "github.com/mholt/caddy/server"
...@@ -62,3 +64,22 @@ func TestResolveAddr(t *testing.T) { ...@@ -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)
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment