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:
parent
acf43857a3
commit
4c0d4dd780
1 changed files with 21 additions and 0 deletions
|
@ -1,6 +1,8 @@
|
||||||
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) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue