mirror of
https://github.com/caddyserver/caddy.git
synced 2025-02-13 19:46:43 +01:00
32 lines
733 B
Go
32 lines
733 B
Go
|
package caddy
|
||
|
|
||
|
import (
|
||
|
"reflect"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestRegister(t *testing.T) {
|
||
|
directives := []directive{
|
||
|
{"dummy", nil},
|
||
|
{"dummy2", nil},
|
||
|
}
|
||
|
directiveOrder = directives
|
||
|
RegisterDirective("foo", nil, "dummy")
|
||
|
if len(directiveOrder) != 3 {
|
||
|
t.Fatal("Should have 3 directives now")
|
||
|
}
|
||
|
getNames := func() (s []string) {
|
||
|
for _, d := range directiveOrder {
|
||
|
s = append(s, d.name)
|
||
|
}
|
||
|
return s
|
||
|
}
|
||
|
if !reflect.DeepEqual(getNames(), []string{"dummy", "foo", "dummy2"}) {
|
||
|
t.Fatalf("directive order doesn't match: %s", getNames())
|
||
|
}
|
||
|
RegisterDirective("bar", nil, "ASDASD")
|
||
|
if !reflect.DeepEqual(getNames(), []string{"dummy", "foo", "dummy2", "bar"}) {
|
||
|
t.Fatalf("directive order doesn't match: %s", getNames())
|
||
|
}
|
||
|
}
|