@@ -22,7 +22,6 @@ import (
22
22
"net/http"
23
23
"os"
24
24
"os/exec"
25
- "strings"
26
25
"testing"
27
26
"time"
28
27
@@ -63,8 +62,8 @@ func TestE2E_helloworld(t *testing.T) {
63
62
64
63
out := stdErr .String ()
65
64
fmt .Println (out )
66
- assert .True (t , strings . Contains ( out , "wasm log helloworld: proxy_on_vm_start from Go!" ) )
67
- assert .True (t , strings . Contains ( out , "wasm log helloworld: It's" ) )
65
+ assert .Contains (t , out , "wasm log helloworld: proxy_on_vm_start from Go!" )
66
+ assert .Contains (t , out , "wasm log helloworld: It's" )
68
67
}
69
68
70
69
func TestE2E_http_auth_random (t * testing.T ) {
@@ -88,9 +87,9 @@ func TestE2E_http_auth_random(t *testing.T) {
88
87
89
88
out := stdErr .String ()
90
89
fmt .Println (out )
91
- assert .True (t , strings . Contains ( out , "access forbidden" ) )
92
- assert .True (t , strings . Contains ( out , "access granted" ) )
93
- assert .True (t , strings . Contains ( out , "response header from httpbin: :status: 200" ) )
90
+ assert .Contains (t , out , "access forbidden" )
91
+ assert .Contains (t , out , "access granted" )
92
+ assert .Contains (t , out , "response header from httpbin: :status: 200" )
94
93
}
95
94
96
95
func TestE2E_http_headers (t * testing.T ) {
@@ -112,9 +111,9 @@ func TestE2E_http_headers(t *testing.T) {
112
111
113
112
out := stdErr .String ()
114
113
fmt .Println (out )
115
- assert .True (t , strings . Contains ( out , key ) )
116
- assert .True (t , strings . Contains ( out , value ) )
117
- assert .True (t , strings . Contains ( out , "server: envoy" ) )
114
+ assert .Contains (t , out , key )
115
+ assert .Contains (t , out , value )
116
+ assert .Contains (t , out , "server: envoy" )
118
117
}
119
118
120
119
func TestE2E_http_body (t * testing.T ) {
@@ -123,7 +122,7 @@ func TestE2E_http_body(t *testing.T) {
123
122
require .NoError (t , cmd .Process .Kill ())
124
123
}()
125
124
126
- req , err := http .NewRequest ("GET" , envoyEndpoint , bytes .NewBuffer ([]byte (`{ "example": "body" }` )))
125
+ req , err := http .NewRequest ("GET" , envoyEndpoint + "/anything" , bytes .NewBuffer ([]byte (`{ "example": "body" }` )))
127
126
require .NoError (t , err )
128
127
129
128
r , err := http .DefaultClient .Do (req )
@@ -132,11 +131,15 @@ func TestE2E_http_body(t *testing.T) {
132
131
133
132
out := stdErr .String ()
134
133
fmt .Println (out )
135
- assert .True (t , strings .Contains (out , "body size: 21" ))
136
- assert .True (t , strings .Contains (out , `initial request body: { "example": "body" }` ))
137
- assert .True (t , strings .Contains (out , "on http request body finished" ))
138
- assert .False (t , strings .Contains (out , "failed to set request body" ))
139
- assert .False (t , strings .Contains (out , "failed to get request body" ))
134
+ assert .Contains (t , out , "body size: 21" )
135
+ assert .Contains (t , out , `initial request body: { "example": "body" }` )
136
+ assert .Contains (t , out , "on http request body finished" )
137
+ assert .NotContains (t , out , "failed to set request body" )
138
+ assert .NotContains (t , out , "failed to get request body" )
139
+
140
+ body , err := ioutil .ReadAll (r .Body )
141
+ require .NoError (t , err )
142
+ assert .Contains (t , string (body ), `"another": "body"` )
140
143
}
141
144
142
145
func TestE2E_network (t * testing.T ) {
@@ -166,14 +169,14 @@ func TestE2E_network(t *testing.T) {
166
169
167
170
out := stdErr .String ()
168
171
fmt .Println (out )
169
- assert .True (t , strings . Contains ( out , key ) )
170
- assert .True (t , strings . Contains ( out , value ) )
171
- assert .True (t , strings . Contains ( out , "downstream data received" ) )
172
- assert .True (t , strings . Contains ( out , "new connection!" ) )
173
- assert .True (t , strings . Contains ( out , "downstream connection close!" ) )
174
- assert .True (t , strings . Contains ( out , "upstream data received" ) )
175
- assert .True (t , strings . Contains ( out , "connection complete!" ) )
176
- assert .True (t , strings . Contains ( out , "remote address: 127.0.0.1:8099" ) )
172
+ assert .Contains (t , out , key )
173
+ assert .Contains (t , out , value )
174
+ assert .Contains (t , out , "downstream data received" )
175
+ assert .Contains (t , out , "new connection!" )
176
+ assert .Contains (t , out , "downstream connection close!" )
177
+ assert .Contains (t , out , "upstream data received" )
178
+ assert .Contains (t , out , "connection complete!" )
179
+ assert .Contains (t , out , "remote address: 127.0.0.1:8099" )
177
180
}
178
181
179
182
func TestE2E_metrics (t * testing.T ) {
@@ -203,7 +206,7 @@ func TestE2E_metrics(t *testing.T) {
203
206
204
207
b , err := ioutil .ReadAll (r .Body )
205
208
require .NoError (t , err )
206
- assert .True (t , strings . Contains ( string (b ), fmt .Sprintf ("proxy_wasm_go.request_counter: %d" , count ) ))
209
+ assert .Contains (t , string (b ), fmt .Sprintf ("proxy_wasm_go.request_counter: %d" , count ))
207
210
}
208
211
209
212
func TestE2E_shared_data (t * testing.T ) {
@@ -224,7 +227,7 @@ func TestE2E_shared_data(t *testing.T) {
224
227
225
228
out := stdErr .String ()
226
229
fmt .Println (out )
227
- assert .True (t , strings . Contains ( out , fmt .Sprintf ("shared value: %d" , count ) ))
230
+ assert .Contains (t , out , fmt .Sprintf ("shared value: %d" , count ))
228
231
}
229
232
230
233
func TestE2E_shared_queue (t * testing.T ) {
@@ -247,9 +250,9 @@ func TestE2E_shared_queue(t *testing.T) {
247
250
248
251
out := stdErr .String ()
249
252
fmt .Println (out )
250
- assert .True (t , strings . Contains ( out , "dequeued data: hello" ) )
251
- assert .True (t , strings . Contains ( out , "dequeued data: world" ) )
252
- assert .True (t , strings . Contains ( out , "dequeued data: proxy-wasm" ) )
253
+ assert .Contains (t , out , "dequeued data: hello" )
254
+ assert .Contains (t , out , "dequeued data: world" )
255
+ assert .Contains (t , out , "dequeued data: proxy-wasm" )
253
256
}
254
257
255
258
func TestE2E_vm_plugin_configuration (t * testing.T ) {
@@ -260,6 +263,6 @@ func TestE2E_vm_plugin_configuration(t *testing.T) {
260
263
261
264
out := stdErr .String ()
262
265
fmt .Println (out )
263
- assert .True (t , strings . Contains ( out , "name\" : \" vm configuration" ) )
264
- assert .True (t , strings . Contains ( out , "name\" : \" plugin configuration" ) )
266
+ assert .Contains (t , out , "name\" : \" vm configuration" )
267
+ assert .Contains (t , out , "name\" : \" plugin configuration" )
265
268
}
0 commit comments