@@ -3,20 +3,19 @@ package main
3
3
import (
4
4
"bytes"
5
5
"context"
6
+ "github.com/buger/goreplay/proto"
6
7
"os"
7
8
"os/exec"
8
9
"strings"
9
10
"sync/atomic"
10
11
"syscall"
11
12
"testing"
12
-
13
- "github.com/buger/goreplay/proto"
14
13
)
15
14
16
15
const echoSh = "./examples/middleware/echo.sh"
17
16
const tokenModifier = "go run ./examples/middleware/token_modifier.go"
18
17
19
- var noDebug = append (syscall .Environ (), "GOR_TEST=1" )
18
+ var withDebug = append (syscall .Environ (), "GOR_TEST=1" )
20
19
21
20
func initMiddleware (cmd * exec.Cmd , cancl context.CancelFunc , l PluginReader , c func (error )) * Middleware {
22
21
var m Middleware
@@ -52,7 +51,7 @@ func initCmd(command string, env []string) (*exec.Cmd, context.CancelFunc) {
52
51
func TestMiddlewareEarlyClose (t * testing.T ) {
53
52
quit := make (chan struct {})
54
53
in := NewTestInput ()
55
- cmd , cancl := initCmd (echoSh , noDebug )
54
+ cmd , cancl := initCmd (echoSh , withDebug )
56
55
midd := initMiddleware (cmd , cancl , in , func (err error ) {
57
56
if err != nil {
58
57
if e , ok := err .(* exec.ExitError ); ok {
@@ -93,7 +92,7 @@ func TestTokenMiddleware(t *testing.T) {
93
92
quit := make (chan struct {})
94
93
in := NewTestInput ()
95
94
in .skipHeader = true
96
- cmd , cancl := initCmd (tokenModifier , noDebug )
95
+ cmd , cancl := initCmd (tokenModifier , withDebug )
97
96
midd := initMiddleware (cmd , cancl , in , func (err error ) {})
98
97
req := []byte ("1 932079936fa4306fc308d67588178d17d823647c 1439818823587396305 200\n GET /token HTTP/1.1\r \n Host: example.org\r \n \r \n " )
99
98
res := []byte ("2 932079936fa4306fc308d67588178d17d823647c 1439818823587396305 200\n HTTP/1.1 200 OK\r \n Content-Length: 10\r \n Content-Type: text/plain; charset=utf-8\r \n \r \n 17d823647c" )
@@ -103,7 +102,7 @@ func TestTokenMiddleware(t *testing.T) {
103
102
if msg .Meta [0 ] == '1' && ! bytes .Equal (payloadID (msg .Meta ), payloadID (req )) {
104
103
token , _ , _ := proto .PathParam (msg .Data , []byte ("token" ))
105
104
if ! bytes .Equal (token , proto .Body (rep )) {
106
- t .Error ("expected the token to be equal to the replayed responses 's token" )
105
+ t .Errorf ("expected the token %s to be equal to the replayed response 's token %s" , token , proto . Body ( rep ) )
107
106
}
108
107
}
109
108
atomic .AddUint32 (& count , 1 )
@@ -131,7 +130,7 @@ func TestMiddlewareWithPrettify(t *testing.T) {
131
130
Settings .PrettifyHTTP = true
132
131
quit := make (chan struct {})
133
132
in := NewTestInput ()
134
- cmd , cancl := initCmd (echoSh , noDebug )
133
+ cmd , cancl := initCmd (echoSh , withDebug )
135
134
midd := initMiddleware (cmd , cancl , in , func (err error ) {})
136
135
var b1 = []byte ("POST / HTTP/1.1\r \n Host: example.org\r \n Transfer-Encoding: chunked\r \n \r \n 4\r \n Wiki\r \n 5\r \n pedia\r \n E\r \n in\r \n \r \n chunks.\r \n 0\r \n \r \n " )
137
136
var b2 = []byte ("POST / HTTP/1.1\r \n Host: example.org\r \n Content-Length: 25\r \n \r \n Wikipedia in\r \n \r \n chunks." )
0 commit comments