0
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2024-12-23 22:27:38 -05:00

Test makeOnces function

This commit is contained in:
Paulo L F Casaretto 2015-10-19 23:19:12 -02:00
parent acf43857a3
commit 4c0d4dd780

View file

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