Skip to content
This repository has been archived by the owner on Oct 27, 2020. It is now read-only.

Commit

Permalink
linting...
Browse files Browse the repository at this point in the history
  • Loading branch information
GRECO, FRANK committed Aug 9, 2017
1 parent d5b9acf commit 9264ab0
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion steps/mockplugins_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
package steps

import (
"errors"
"context"
"errors"
"net/http"

"github.com/northwesternmutual/kanali/controller"
Expand Down
2 changes: 1 addition & 1 deletion steps/pluginsonrequest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ func TestPluginsOnRequestGetName(t *testing.T) {

func TestDoOnRequest(t *testing.T) {
assert.Equal(t, doOnRequest(context.Background(), spec.APIProxy{}, controller.Controller{}, nil, opentracing.StartSpan("test span"), fakePanicPlugin{}).Error(), "OnRequest paniced")
assert.Equal(t, doOnRequest(context.Background(), spec.APIProxy{}, controller.Controller{}, nil, opentracing.StartSpan("test span"), fakeErrorPlugin{}).Error(), "error")
assert.Equal(t, doOnRequest(context.Background(), spec.APIProxy{}, controller.Controller{}, nil, opentracing.StartSpan("test span"), fakeErrorPlugin{}).Error(), "error")
assert.Nil(t, doOnRequest(context.Background(), spec.APIProxy{}, controller.Controller{}, nil, opentracing.StartSpan("test span"), fakeSuccessPlugin{}))
}
4 changes: 2 additions & 2 deletions steps/pluginsonresponse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ func TestPluginsOnResponseGetName(t *testing.T) {

func TestDoOnResponse(t *testing.T) {
assert.Equal(t, doOnResponse(context.Background(), spec.APIProxy{}, controller.Controller{}, nil, nil, opentracing.StartSpan("test span"), fakePanicPlugin{}).Error(), "OnResponse paniced")
assert.Equal(t, doOnResponse(context.Background(), spec.APIProxy{}, controller.Controller{}, nil, nil, opentracing.StartSpan("test span"), fakeErrorPlugin{}).Error(), "error")
assert.Nil(t, doOnResponse(context.Background(), spec.APIProxy{}, controller.Controller{}, nil, nil, opentracing.StartSpan("test span"), fakeSuccessPlugin{}))
assert.Equal(t, doOnResponse(context.Background(), spec.APIProxy{}, controller.Controller{}, nil, nil, opentracing.StartSpan("test span"), fakeErrorPlugin{}).Error(), "error")
assert.Nil(t, doOnResponse(context.Background(), spec.APIProxy{}, controller.Controller{}, nil, nil, opentracing.StartSpan("test span"), fakeSuccessPlugin{}))
}
54 changes: 27 additions & 27 deletions steps/writeresponse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
package steps

import (
"bytes"
"bytes"
"context"
"io/ioutil"
"net/http"
"net/http/httptest"
"testing"
"context"
"net/http"
"io/ioutil"
"net/http/httptest"

opentracing "github.com/opentracing/opentracing-go"
"github.com/stretchr/testify/assert"
opentracing "github.com/opentracing/opentracing-go"
)

func TestWriteResponseGetName(t *testing.T) {
Expand All @@ -38,25 +38,25 @@ func TestWriteResponseGetName(t *testing.T) {
}

func TestWriteResponseDo(t *testing.T) {
step := WriteResponseStep{}
writer := httptest.NewRecorder()
response := &httptest.ResponseRecorder{
Code: 200,
HeaderMap: http.Header{
"One": []string{"two"},
"Three": []string{"four"},
},
Body: bytes.NewBuffer([]byte("this is my mock response body")),
}
err := step.Do(context.Background(), nil, writer, nil, response.Result(), opentracing.StartSpan("test span"))
defer writer.Result().Body.Close()
assert.Nil(t, err)
assert.Equal(t, writer.Result().StatusCode, 200)
assert.Equal(t, writer.Result().Status, "OK")
assert.Equal(t, len(writer.Result().Header), 2)
assert.Equal(t, writer.Result().Header.Get("one"), "two")
assert.Equal(t, writer.Result().Header.Get("three"), "four")
bodyBytes, err := ioutil.ReadAll(writer.Result().Body)
assert.Nil(t, err)
assert.Equal(t, string(bodyBytes), "this is my mock response body")
step := WriteResponseStep{}
writer := httptest.NewRecorder()
response := &httptest.ResponseRecorder{
Code: 200,
HeaderMap: http.Header{
"One": []string{"two"},
"Three": []string{"four"},
},
Body: bytes.NewBuffer([]byte("this is my mock response body")),
}
err := step.Do(context.Background(), nil, writer, nil, response.Result(), opentracing.StartSpan("test span"))
defer writer.Result().Body.Close()
assert.Nil(t, err)
assert.Equal(t, writer.Result().StatusCode, 200)
assert.Equal(t, writer.Result().Status, "OK")
assert.Equal(t, len(writer.Result().Header), 2)
assert.Equal(t, writer.Result().Header.Get("one"), "two")
assert.Equal(t, writer.Result().Header.Get("three"), "four")
bodyBytes, err := ioutil.ReadAll(writer.Result().Body)
assert.Nil(t, err)
assert.Equal(t, string(bodyBytes), "this is my mock response body")
}

0 comments on commit 9264ab0

Please sign in to comment.