Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps updated so error messages can contain the : char #32

Merged
merged 2 commits into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ require (
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)

replace github.com/alexeyco/binder v0.0.0-20180729220023-2a21303f588a => github.com/kpacha/binder v0.0.0-20220707194437-6013d1173c4d
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB7
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/kpacha/binder v0.0.0-20220707194437-6013d1173c4d h1:oItRdKLkFNuQvc9M3PkMYW9+sPvfrj7jqcs6IQ5zptc=
github.com/kpacha/binder v0.0.0-20220707194437-6013d1173c4d/go.mod h1:NXKMtJUiS0DhPY7BQ6GzFEfgQ1OG8QhgtA9P0qbWCj4=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
Expand Down
18 changes: 11 additions & 7 deletions proxy/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"net/url"
"strings"
"testing"
Expand All @@ -26,6 +26,10 @@ func TestProxyFactory_errorHTTP(t *testing.T) {
testProxyFactoryError(t, `custom_error('expect me', 404)`, "expect me", true, 404)
}

func TestProxyFactory_errorHTTPJson(t *testing.T) {
testProxyFactoryError(t, `custom_error('{"msg":"expect me"}', 404)`, `{"msg":"expect me"}`, true, 404)
}

func testProxyFactoryError(t *testing.T, code, errMsg string, isHTTP bool, statusCode int) {
buff := bytes.NewBuffer(make([]byte, 1024))
logger, err := logging.NewLogger("ERROR", buff, "pref")
Expand Down Expand Up @@ -63,7 +67,7 @@ func testProxyFactoryError(t *testing.T, code, errMsg string, isHTTP bool, statu
Params: map[string]string{"Id": "42"},
Headers: map[string][]string{},
URL: URL,
Body: ioutil.NopCloser(strings.NewReader("initial req content")),
Body: io.NopCloser(strings.NewReader("initial req content")),
})

if resp != nil {
Expand Down Expand Up @@ -151,7 +155,7 @@ func TestProxyFactory(t *testing.T) {
if req.URL.String() != "https://some.host.tld/path/to/resource?and=querystring&more=true" {
t.Errorf("unexpected URL: %s", req.URL.String())
}
b, err := ioutil.ReadAll(req.Body)
b, err := io.ReadAll(req.Body)
if err != nil {
t.Error(err)
}
Expand Down Expand Up @@ -228,7 +232,7 @@ func TestProxyFactory(t *testing.T) {
Params: map[string]string{"Id": "42"},
Headers: map[string][]string{},
URL: URL,
Body: ioutil.NopCloser(strings.NewReader("initial req content")),
Body: io.NopCloser(strings.NewReader("initial req content")),
})
if err != nil {
t.Errorf("unexpected error %s", err.Error())
Expand Down Expand Up @@ -298,7 +302,7 @@ func TestProxyFactory(t *testing.T) {
t.Errorf("unexpected response %s", string(b))
}

b, err = ioutil.ReadAll(resp.Io)
b, err = io.ReadAll(resp.Io)
if err != nil {
t.Error(err)
}
Expand Down Expand Up @@ -374,7 +378,7 @@ func Test_Issue7(t *testing.T) {
Params: map[string]string{"Id": "42"},
Headers: map[string][]string{},
URL: URL,
Body: ioutil.NopCloser(strings.NewReader("initial req content")),
Body: io.NopCloser(strings.NewReader("initial req content")),
})

if err != nil {
Expand Down Expand Up @@ -433,7 +437,7 @@ responseData:set("id", responseData:get("id")+1)
Params: map[string]string{"Id": "42"},
Headers: map[string][]string{},
URL: URL,
Body: ioutil.NopCloser(strings.NewReader("initial req content")),
Body: io.NopCloser(strings.NewReader("initial req content")),
})

if err != nil {
Expand Down