From cf7b9bd0ccb5bbc40385b39c4dbb4bf3af88441e Mon Sep 17 00:00:00 2001 From: asoseil Date: Wed, 22 Nov 2017 14:05:16 +0100 Subject: [PATCH] start stop test --- realize/cli_test.go | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/realize/cli_test.go b/realize/cli_test.go index 7fb4365..022aa30 100644 --- a/realize/cli_test.go +++ b/realize/cli_test.go @@ -1,8 +1,9 @@ package realize import ( - "testing" "os" + "testing" + "time" ) type mockRealize struct { @@ -14,11 +15,24 @@ type mockRealize struct { } func TestRealize_Stop(t *testing.T) { - m := mockRealize{} - m.exit = make(chan os.Signal, 2) - close(m.exit) - _, ok := <-m.exit + r := Realize{} + r.exit = make(chan os.Signal, 2) + r.Stop() + _, ok := <-r.exit if ok != false { t.Error("Unexpected error", "channel should be closed") } } + +func TestRealize_Start(t *testing.T) { + r := Realize{} + go func(){ + time.Sleep(100) + close(r.exit) + _, ok := <-r.exit + if ok != false { + t.Error("Unexpected error", "channel should be closed") + } + }() + r.Start() +}