Skip to content

Commit

Permalink
Fixed these unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
johnabass committed Sep 1, 2017
1 parent e368ebb commit 4f52351
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/talaria/outbounder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func ExampleOutbounder() {
return
}

o, err := NewOutbounder(&logging.LoggerWriter{ioutil.Discard}, v)
o, err := NewOutbounder(logging.DefaultLogger(), v)
if err != nil {
fmt.Println(err)
return
Expand Down Expand Up @@ -120,7 +120,7 @@ func testOutbounderConfiguration(t *testing.T) {
var (
assert = assert.New(t)
require = require.New(t)
logger = logging.TestLogger(t)
logger = logging.NewTestLogger(nil, t)
configuration = []byte(`{
"method": "PATCH",
"requestTimeout": "30s",
Expand Down
17 changes: 12 additions & 5 deletions src/talaria/workerPool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,25 @@ package main
import (
"bytes"
"errors"
"github.com/Comcast/webpa-common/logging"
"github.com/stretchr/testify/assert"
"io/ioutil"
"net/http"
"net/http/httptest"
"testing"

"github.com/Comcast/webpa-common/logging"
"github.com/stretchr/testify/assert"
)

func testWorkerPoolTransactTransactorError(t *testing.T) {
var (
assert = assert.New(t)
logger = logging.NewTestLogger(nil, t)
expectedRequest = httptest.NewRequest("POST", "/", nil)
envelope = &outboundEnvelope{expectedRequest, func() {}}

wp = &WorkerPool{
logger: logging.DefaultLogger(),
errorLog: logging.Error(logger),
debugLog: logging.Debug(logger),
transactor: func(actualRequest *http.Request) (*http.Response, error) {
assert.Equal(expectedRequest, actualRequest)
return nil, errors.New("expected error")
Expand All @@ -32,11 +35,13 @@ func testWorkerPoolTransactTransactorError(t *testing.T) {
func testWorkerPoolTransactHTTPSuccess(t *testing.T) {
var (
assert = assert.New(t)
logger = logging.NewTestLogger(nil, t)
expectedRequest = httptest.NewRequest("POST", "/", nil)
envelope = &outboundEnvelope{expectedRequest, func() {}}

wp = &WorkerPool{
logger: logging.DefaultLogger(),
errorLog: logging.Error(logger),
debugLog: logging.Debug(logger),
transactor: func(actualRequest *http.Request) (*http.Response, error) {
assert.Equal(expectedRequest, actualRequest)
return &http.Response{
Expand All @@ -54,11 +59,13 @@ func testWorkerPoolTransactHTTPSuccess(t *testing.T) {
func testWorkerPoolTransactHTTPError(t *testing.T) {
var (
assert = assert.New(t)
logger = logging.NewTestLogger(nil, t)
expectedRequest = httptest.NewRequest("POST", "/", nil)
envelope = &outboundEnvelope{expectedRequest, func() {}}

wp = &WorkerPool{
logger: logging.DefaultLogger(),
errorLog: logging.Error(logger),
debugLog: logging.Debug(logger),
transactor: func(actualRequest *http.Request) (*http.Response, error) {
assert.Equal(expectedRequest, actualRequest)
return &http.Response{
Expand Down

0 comments on commit 4f52351

Please sign in to comment.