test expected log messag and returned arguments separately
@@ -42,7 +42,7 @@ func TestIntegration_FormParams(t *testing.T) {
post: "x=X+1&x=X%202&y=Y",
expArgs: `"Args":{}`,
expCT: `"Content-Type":["application/x-www-form-urlencoded"]`,
- expErr: "",
+ expErr: "form_params: method mismatch: DELETE",
},
{
file: "01_couper.hcl",
@@ -51,7 +51,7 @@ func TestIntegration_FormParams(t *testing.T) {
post: "",
expArgs: `"Args":{}`,
expCT: `"Content-Type":["text/plain"]`,
- expErr: "",
+ expErr: "form_params: method mismatch: GET",
},
{
file: "01_couper.hcl",
@@ -87,7 +87,7 @@ func TestIntegration_FormParams(t *testing.T) {
post: "",
expArgs: `"Args":{}`,
expCT: `"Content-Type":["text/plain"]`,
- expErr: "",
+ expErr: "form_params: method mismatch: GET",
},
{
file: "03_couper.hcl",
@@ -139,12 +139,11 @@ func TestIntegration_FormParams(t *testing.T) {
t.Fatalf("%d: Expected status 200, given %d", i, res.StatusCode)
}
- if tc.expErr != "" {
if hook.Entries[0].Message != tc.expErr {
t.Logf("%v", hook)
t.Errorf("%d: Expected message log: %s", i, tc.expErr)
}
- } else {
+
resBytes, err := ioutil.ReadAll(res.Body)
helper.Must(err)
@@ -157,7 +156,6 @@ func TestIntegration_FormParams(t *testing.T) {
if !bytes.Contains(resBytes, []byte(tc.expCT)) {
t.Errorf("%d: \nwant: \n%s\nin: \n%s", i, tc.expCT, resBytes)
}
- }
})
}
}
