From e62b2223722a8029c3cb035fe86c66b43aa09eaa Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Sat, 21 Mar 2015 15:11:31 -0600 Subject: [PATCH] Couple more controller tests --- config/controller_test.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/config/controller_test.go b/config/controller_test.go index 6b6b13c31..78cb11e78 100644 --- a/config/controller_test.go +++ b/config/controller_test.go @@ -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 {