From 1eac4376b25024af9837fddcb867d8e23662bf05 Mon Sep 17 00:00:00 2001 From: Algirdas Matas Date: Fri, 12 Jun 2015 16:56:55 +0300 Subject: [PATCH] Make suite private --- builder.go | 4 +--- steps_test.go | 8 -------- suite.go | 12 +++++++++--- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/builder.go b/builder.go index a1b9bb7..c956f65 100644 --- a/builder.go +++ b/builder.go @@ -21,9 +21,7 @@ import ( ) func main() { - suite := &GodogSuite{ - steps: make(map[*regexp.Regexp]StepHandler), - } + suite := godog.New() {{range $c := .Contexts}} {{$c}}(suite) {{end}} diff --git a/steps_test.go b/steps_test.go index c3be714..d0112a2 100644 --- a/steps_test.go +++ b/steps_test.go @@ -5,14 +5,6 @@ import ( "regexp" ) -//func init() { -//f := StepHandlerFunc(func(args ...interface{}) error { -//log.Println("step triggered") -//return nil -//}) -//Step(regexp.MustCompile("hello"), f) -//} - func SomeContext(g Suite) { f := StepHandlerFunc(func(args ...interface{}) error { log.Println("step triggered") diff --git a/suite.go b/suite.go index 7175ff5..9ed1775 100644 --- a/suite.go +++ b/suite.go @@ -9,14 +9,20 @@ type Suite interface { Step(exp *regexp.Regexp, h StepHandler) } -type GodogSuite struct { +type suite struct { steps map[*regexp.Regexp]StepHandler } -func (s *GodogSuite) Step(exp *regexp.Regexp, h StepHandler) { +func New() *suite { + return &suite{ + steps: make(map[*regexp.Regexp]StepHandler), + } +} + +func (s *suite) Step(exp *regexp.Regexp, h StepHandler) { s.steps[exp] = h } -func (s *GodogSuite) Run() { +func (s *suite) Run() { log.Println("running godoc, num registered steps:", len(s.steps)) }