Skip to content

Commit

Permalink
Merge pull request #778 from kenjones-cisco/test/improve-nsqlookupd-c…
Browse files Browse the repository at this point in the history
…overage

nsqlookupd: improve test coverage
  • Loading branch information
mreiferson authored Aug 3, 2016
2 parents f8db159 + 231c9ef commit facca8a
Show file tree
Hide file tree
Showing 8 changed files with 697 additions and 219 deletions.
6 changes: 3 additions & 3 deletions internal/test/assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ func Equal(t *testing.T, expected, actual interface{}) {
}

func NotEqual(t *testing.T, expected, actual interface{}) {
if !reflect.DeepEqual(expected, actual) {
if reflect.DeepEqual(expected, actual) {
_, file, line, _ := runtime.Caller(1)
t.Logf("\033[31m%s:%d:\n\n\tvalue should not equal %#v\033[39m\n\n",
filepath.Base(file), line, actual)
t.Logf("\033[31m%s:%d:\n\n\tnexp: %#v\n\n\tgot: %#v\033[39m\n\n",
filepath.Base(file), line, expected, actual)
t.FailNow()
}
}
Expand Down
22 changes: 22 additions & 0 deletions internal/test/logger.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package test

import (
"github.com/nsqio/nsq/internal/app"
)

type tbLog interface {
Log(...interface{})
}

type testLogger struct {
tbLog
}

func (tl *testLogger) Output(maxdepth int, s string) error {
tl.Log(s)
return nil
}

func NewTestLogger(tbl tbLog) app.Logger {
return &testLogger{tbl}
}
Loading

0 comments on commit facca8a

Please sign in to comment.