start stop test
This commit is contained in:
parent
d9f6dcc9a4
commit
cf7b9bd0cc
|
@ -1,8 +1,9 @@
|
||||||
package realize
|
package realize
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
|
||||||
"os"
|
"os"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type mockRealize struct {
|
type mockRealize struct {
|
||||||
|
@ -14,11 +15,24 @@ type mockRealize struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRealize_Stop(t *testing.T) {
|
func TestRealize_Stop(t *testing.T) {
|
||||||
m := mockRealize{}
|
r := Realize{}
|
||||||
m.exit = make(chan os.Signal, 2)
|
r.exit = make(chan os.Signal, 2)
|
||||||
close(m.exit)
|
r.Stop()
|
||||||
_, ok := <-m.exit
|
_, ok := <-r.exit
|
||||||
if ok != false {
|
if ok != false {
|
||||||
t.Error("Unexpected error", "channel should be closed")
|
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()
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue