mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-20 15:57:13 +08:00
Couple more controller tests
This commit is contained in:
parent
a0e93009f0
commit
e62b222372
|
@ -3,7 +3,18 @@ package config
|
|||
import "testing"
|
||||
|
||||
func TestController(t *testing.T) {
|
||||
c := controller{parser: new(parser)}
|
||||
p := &parser{filename: "test"}
|
||||
c := newController(p)
|
||||
|
||||
if c == nil || c.parser == nil {
|
||||
t.Fatal("Expected newController to return a non-nil controller with a non-nil parser")
|
||||
}
|
||||
if c.dispenser.cursor != -1 {
|
||||
t.Errorf("Dispenser not initialized properly; expecting cursor at -1, got %d", c.dispenser.cursor)
|
||||
}
|
||||
if c.dispenser.filename != p.filename {
|
||||
t.Errorf("Dispenser's filename should be same as parser's (%s); got '%s'", p.filename, c.dispenser.filename)
|
||||
}
|
||||
|
||||
c.Startup(func() error { return nil })
|
||||
if n := len(c.parser.cfg.Startup); n != 1 {
|
||||
|
|
Loading…
Reference in New Issue
Block a user