2018-06-27 18:19:36 +00:00
|
|
|
package utils
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"testing"
|
|
|
|
|
2018-07-10 02:27:23 +00:00
|
|
|
logTest "github.com/sirupsen/logrus/hooks/test"
|
2018-06-27 18:19:36 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestHandleServiceErrors(t *testing.T) {
|
2018-07-10 02:27:23 +00:00
|
|
|
hook := logTest.NewGlobal()
|
2018-06-27 18:19:36 +00:00
|
|
|
done := make(chan struct{})
|
|
|
|
errChan := make(chan error)
|
|
|
|
|
|
|
|
go HandleServiceErrors(done, errChan)
|
|
|
|
|
|
|
|
errChan <- errors.New("something wrong")
|
|
|
|
done <- struct{}{}
|
2018-07-10 02:27:23 +00:00
|
|
|
msg := hook.LastEntry().Message
|
|
|
|
want := "something wrong"
|
|
|
|
if msg != want {
|
|
|
|
t.Errorf("incorrect log, expected %s, got %s", want, msg)
|
|
|
|
}
|
2018-06-27 18:19:36 +00:00
|
|
|
}
|