Skip to content

Commit e70bc27

Browse files
Merge pull request #21 from speakeasy-api/update-tests
chore: update SDK with latest test-suite output
2 parents 84dcccd + d17760b commit e70bc27

22 files changed

+176
-55
lines changed

harbuilder.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"bytes"
55
"context"
66
"net/http"
7-
"net/http/httptest"
87
"net/url"
98
"sort"
109
"strconv"
@@ -131,17 +130,9 @@ func (h *harBuilder) getHarRequest(ctx context.Context, cw *captureWriter, r *ht
131130

132131
reqCookies := getHarCookies(r.Cookies(), time.Time{}, c.requestCookieMasks)
133132

134-
hw := httptest.NewRecorder()
135-
136-
for k, vv := range r.Header {
137-
for _, v := range vv {
138-
hw.Header().Set(k, v)
139-
}
140-
}
141-
142133
b := bytes.NewBuffer([]byte{})
143134
headerSize := -1
144-
if err := hw.Header().Write(b); err != nil {
135+
if err := r.Header.Write(b); err != nil {
145136
log.From(ctx).Error("speakeasy-sdk: failed to read length of request headers", zap.Error(err))
146137
} else {
147138
headerSize = b.Len()

middleware_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func TestSpeakeasy_Middleware_Capture_Success(t *testing.T) {
151151
assert.Equal(t, testApiID, req.ApiId)
152152
assert.Equal(t, testVersionID, req.VersionId)
153153

154-
assert.Equal(t, tt.WantHAR, req.Har)
154+
assert.JSONEq(t, tt.WantHAR, req.Har)
155155
captured = true
156156
wg.Done()
157157
}),
@@ -646,7 +646,7 @@ func TestSpeakeasy_GinMiddleware_Success(t *testing.T) {
646646
ApiID: testApiID,
647647
VersionID: testVersionID,
648648
GRPCDialer: dialer(func(ctx context.Context, req *ingest.IngestRequest) {
649-
assert.Equal(t, tt.WantHAR, req.Har)
649+
assert.JSONEq(t, tt.WantHAR, req.Har)
650650
captured = true
651651
wg.Done()
652652
}),
@@ -886,7 +886,7 @@ func TestSpeakeasy_EchoMiddleware_Success(t *testing.T) {
886886
ApiID: testApiID,
887887
VersionID: testVersionID,
888888
GRPCDialer: dialer(func(ctx context.Context, req *ingest.IngestRequest) {
889-
assert.Equal(t, tt.WantHAR, req.Har)
889+
assert.JSONEq(t, tt.WantHAR, req.Har)
890890
captured = true
891891
wg.Done()
892892
}),

speakeasy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const (
2929
)
3030

3131
var (
32-
speakeasyVersion = "1.3.0" // TODO get this from CI
32+
speakeasyVersion = "1.3.4" // TODO get this from CI
3333
serverURL = "grpc.prod.speakeasyapi.dev:443"
3434

3535
defaultInstance *Speakeasy

testdata/captures_basic_request_and_no_response_body_output.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "1.2",
44
"creator": {
55
"name": "speakeasy-go-sdk",
6-
"version": "1.3.0"
6+
"version": "1.3.4"
77
},
88
"entries": [
99
{

testdata/captures_basic_request_and_response_output.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "1.2",
44
"creator": {
55
"name": "speakeasy-go-sdk",
6-
"version": "1.3.0"
6+
"version": "1.3.4"
77
},
88
"entries": [
99
{

testdata/captures_basic_request_and_response_with_different_content_types_output.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "1.2",
44
"creator": {
55
"name": "speakeasy-go-sdk",
6-
"version": "1.3.0"
6+
"version": "1.3.4"
77
},
88
"entries": [
99
{

testdata/captures_basic_request_and_response_with_no_response_header_set_output.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "1.2",
44
"creator": {
55
"name": "speakeasy-go-sdk",
6-
"version": "1.3.0"
6+
"version": "1.3.4"
77
},
88
"entries": [
99
{
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"name": "captures basic request and response with repeat headers",
3+
"fields": {
4+
"max_capture_size": 9437184
5+
},
6+
"args": {
7+
"method": "GET",
8+
"url": "http://test.com/test",
9+
"response_status": 200,
10+
"response_body": "test",
11+
"headers": [
12+
{
13+
"key": "Vary",
14+
"values": ["Origin"]
15+
},
16+
{
17+
"key": "Vary",
18+
"values": ["Access-Control-Request-Method"]
19+
},
20+
{
21+
"key": "Vary",
22+
"values": ["Access-Control-Request-Headers"]
23+
}
24+
],
25+
"response_headers": [
26+
{
27+
"key": "Vary",
28+
"values": ["Origin"]
29+
},
30+
{
31+
"key": "Vary",
32+
"values": ["Access-Control-Request-Method"]
33+
},
34+
{
35+
"key": "Vary",
36+
"values": ["Access-Control-Request-Headers"]
37+
},
38+
{
39+
"key": "Content-Type",
40+
"values": ["application/octet-stream"]
41+
},
42+
{
43+
"key": "Content-Length",
44+
"values": ["4"]
45+
}
46+
]
47+
}
48+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
{
2+
"log": {
3+
"comment": "request capture for http://test.com/test",
4+
"creator": {
5+
"name": "speakeasy-go-sdk",
6+
"version": "1.3.4"
7+
},
8+
"version": "1.2",
9+
"entries": [
10+
{
11+
"startedDateTime": "2020-01-01T00:00:00Z",
12+
"time": 1,
13+
"request": {
14+
"method": "GET",
15+
"url": "http://test.com/test",
16+
"httpVersion": "HTTP/1.1",
17+
"cookies": [],
18+
"headers": [
19+
{
20+
"name": "Vary",
21+
"value": "Origin"
22+
},
23+
{
24+
"name": "Vary",
25+
"value": "Access-Control-Request-Method"
26+
},
27+
{
28+
"name": "Vary",
29+
"value": "Access-Control-Request-Headers"
30+
}
31+
],
32+
"queryString": [],
33+
"headersSize": 89,
34+
"bodySize": -1
35+
},
36+
"response": {
37+
"status": 200,
38+
"statusText": "OK",
39+
"httpVersion": "HTTP/1.1",
40+
"cookies": [],
41+
"headers": [
42+
{
43+
"name": "Content-Length",
44+
"value": "4"
45+
},
46+
{
47+
"name": "Content-Type",
48+
"value": "application/octet-stream"
49+
},
50+
{
51+
"name": "Vary",
52+
"value": "Origin"
53+
},
54+
{
55+
"name": "Vary",
56+
"value": "Access-Control-Request-Method"
57+
},
58+
{
59+
"name": "Vary",
60+
"value": "Access-Control-Request-Headers"
61+
}
62+
],
63+
"content": {
64+
"size": 4,
65+
"mimeType": "application/octet-stream",
66+
"text": "test"
67+
},
68+
"redirectURL": "",
69+
"headersSize": 148,
70+
"bodySize": 4
71+
},
72+
"cache": {},
73+
"timings": {
74+
"send": -1,
75+
"wait": -1,
76+
"receive": -1
77+
},
78+
"serverIPAddress": "test.com"
79+
}
80+
]
81+
}
82+
}

testdata/captures_basic_request_with_nano_precision_output.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "1.2",
44
"creator": {
55
"name": "speakeasy-go-sdk",
6-
"version": "1.3.0"
6+
"version": "1.3.4"
77
},
88
"entries": [
99
{

0 commit comments

Comments
 (0)