Skip to content

Commit

Permalink
More test improvements
Browse files Browse the repository at this point in the history
for issue #14
  • Loading branch information
NHOrus committed Apr 13, 2016
1 parent 2daccfa commit 5710e3d
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,13 @@ func TestDispatcherThrough(t *testing.T) {
sig := make(chan os.Signal)

go in.dispatcher(sig, out)
in <- Image{}
in <- Image{Score: 1}
select {
case tval, ok := <-out:
if !ok {
t.Fatal("Out channel is closed prematurely")
}
if tval.Imgid == 0 &&
tval.URL == "" &&
tval.Filename == "" &&
tval.Score == 0 &&
tval.Faves == 0 {
} else {
if (tval != Image{Score: 1}) {
t.Error("Pass through dispatcher mangles image")
}
default:
Expand All @@ -37,9 +32,9 @@ func TestDispatcherClose(t *testing.T) {

go in.dispatcher(sig, out)

close(in)
sig <- os.Interrupt
_, ok := <-out
if ok {
t.Error("Channel open and passes data when it should be closed. Or blocking")
t.Error("Channel open and passes data when it should be closed")
}
}

0 comments on commit 5710e3d

Please sign in to comment.