Skip to content

Commit

Permalink
Update gopkg.in/yaml.v2 to v3 (#883)
Browse files Browse the repository at this point in the history
  • Loading branch information
vcheung-stripe committed May 31, 2022
1 parent acd8564 commit b92c7ed
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 35 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@ require (
google.golang.org/protobuf v1.27.1
gopkg.in/ini.v1 v1.63.2 // indirect
gopkg.in/src-d/go-git.v4 v4.13.1
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v2 v2.4.0 // indirect
)

require (
github.com/hashicorp/go-hclog v0.14.1
github.com/hashicorp/go-plugin v1.4.3
github.com/joho/godotenv v1.4.0
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
)

require (
Expand Down Expand Up @@ -79,5 +80,4 @@ require (
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/src-d/go-billy.v4 v4.3.2 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)
24 changes: 12 additions & 12 deletions pkg/playback/interactions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,19 +205,19 @@ func TestSaveAndCloseToYaml(t *testing.T) {
method: POST
body: hello world
headers:
Test:
- header 1
Test:
- header 1
url:
scheme: ""
opaque: ""
user: null
host: ""
path: ""
rawpath: ""
forcequery: false
rawquery: ""
fragment: ""
rawfragment: ""
scheme: ""
opaque: ""
user: null
host: ""
path: ""
rawpath: ""
forcequery: false
rawquery: ""
fragment: ""
rawfragment: ""
response:
headers: {}
body: ""
Expand Down
16 changes: 8 additions & 8 deletions pkg/playback/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import (
"github.com/stretchr/testify/assert"
)

const defaultLocalAddress = "localhost:8080"
const defaultLocalWebhookAddress = "localhost:8888"
const defaultLocalAddress = "127.0.0.1:8080"
const defaultLocalWebhookAddress = "127.0.0.1:8888"

func assertHTTPResponsesAreEqual(t *testing.T, resp1 *http.Response, resp2 *http.Response) error {
// Read the response bodies
Expand Down Expand Up @@ -130,16 +130,16 @@ func TestSimpleRecordReplayServerSeparately(t *testing.T) {
<-serverReady

// Send it 2 requests
res1, err := http.Get("http://localhost:8080/")
res1, err := http.Get("http://127.0.0.1:8080/")
assert.NoError(t, err)
assert.Equal(t, mockResponse1.StatusCode, res1.StatusCode)

res2, err := http.Get("http://localhost:8080/")
res2, err := http.Get("http://127.0.0.1:8080/")
assert.NoError(t, err)
assert.Equal(t, mockResponse2.StatusCode, res2.StatusCode)

// Shutdown record server
resShutdown, err := http.Get("http://localhost:8080/playback/cassette/eject")
resShutdown, err := http.Get("http://127.0.0.1:8080/playback/cassette/eject")
server.Shutdown(context.Background())
assert.NoError(t, err)
defer resShutdown.Body.Close()
Expand All @@ -160,9 +160,9 @@ func TestSimpleRecordReplayServerSeparately(t *testing.T) {
time.Sleep(10 * time.Millisecond)

// Send it the same 2 requests:
replay1, err := http.Get("http://localhost:8080/")
replay1, err := http.Get("http://127.0.0.1:8080/")
assert.NoError(t, err)
replay2, err := http.Get("http://localhost:8080/")
replay2, err := http.Get("http://127.0.0.1:8080/")
assert.NoError(t, err)

// Assert that the original responses and replayed responses are the same
Expand Down Expand Up @@ -205,7 +205,7 @@ func TestPlaybackSingleRunCreateCustomerAndStandaloneCharge(t *testing.T) {
remoteURL = ts.URL

// -- Setup Playback server
addressString := "localhost:13111"
addressString := "127.0.0.1:13111"
cassetteFilepath := "test_record_replay_single_run.yaml"

tempCassetteDir, err := ioutil.TempDir("", "playback-test-data-")
Expand Down
2 changes: 1 addition & 1 deletion pkg/playback/yaml_serializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"net/http"
"net/url"

"gopkg.in/yaml.v2"
"gopkg.in/yaml.v3"
)

// YAMLSerializer encodes/persists cassettes to files and decodes yaml cassette files.
Expand Down
65 changes: 53 additions & 12 deletions pkg/playback/yaml_serializer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"testing"

"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v2"
"gopkg.in/yaml.v3"
)

func request() httpRequest {
Expand All @@ -33,16 +33,16 @@ func TestSerializeReq(t *testing.T) {
body: hello world
headers: {}
url:
scheme: ""
opaque: ""
user: null
host: ""
path: ""
rawpath: ""
forcequery: false
rawquery: ""
fragment: ""
rawfragment: ""
scheme: ""
opaque: ""
user: null
host: ""
path: ""
rawpath: ""
forcequery: false
rawquery: ""
fragment: ""
rawfragment: ""
`

req := request()
Expand Down Expand Up @@ -125,7 +125,48 @@ func TestEncodeCassette(t *testing.T) {
t.Fatal(err)
}

expected := "- type: 1\n request:\n method: POST\n body: hello world\n headers: {}\n url:\n scheme: \"\"\n opaque: \"\"\n user: null\n host: \"\"\n path: \"\"\n rawpath: \"\"\n forcequery: false\n rawquery: \"\"\n fragment: \"\"\n rawfragment: \"\"\n response:\n headers: {}\n body: response body\n status_code: 200\n- type: 0\n request:\n method: POST\n body: hello world\n headers: {}\n url:\n scheme: \"\"\n opaque: \"\"\n user: null\n host: \"\"\n path: \"\"\n rawpath: \"\"\n forcequery: false\n rawquery: \"\"\n fragment: \"\"\n rawfragment: \"\"\n response:\n headers: {}\n body: response body\n status_code: 200\n"
expected :=
`- type: 1
request:
method: POST
body: hello world
headers: {}
url:
scheme: ""
opaque: ""
user: null
host: ""
path: ""
rawpath: ""
forcequery: false
rawquery: ""
fragment: ""
rawfragment: ""
response:
headers: {}
body: response body
status_code: 200
- type: 0
request:
method: POST
body: hello world
headers: {}
url:
scheme: ""
opaque: ""
user: null
host: ""
path: ""
rawpath: ""
forcequery: false
rawquery: ""
fragment: ""
rawfragment: ""
response:
headers: {}
body: response body
status_code: 200
`

assert.Equal(t, expected, string(encoded))
}
Expand Down

0 comments on commit b92c7ed

Please sign in to comment.