Couple more controller tests

This commit is contained in:
Matthew Holt 2015-03-21 15:11:31 -06:00
parent a0e93009f0
commit e62b222372

View File

@ -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 {