Skip to content

Commit

Permalink
update goccy/go-yaml to v1.15.12
Browse files Browse the repository at this point in the history
  • Loading branch information
goccy committed Dec 20, 2024
1 parent 70b58c9 commit 6b4cd94
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 29 deletions.
6 changes: 3 additions & 3 deletions assert/assertion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,9 @@ deps:
if err == nil {
t.Error("no error")
} else if got, expect := err.Error(), `failed to build assertion: .'{{call <-}}': failed to execute left arrow function: failed to unmarshal argument: [1:1] unknown field "func"
> 1 | func: "{{func-0}}"
^
2 | arg: foo`; got != expect {
> 1 | func: "{{func-0}}"
^
2 | arg: foo`; got != expect {
t.Errorf("expect %q but got %q", expect, got)
}
})
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/bufbuild/protocompile v0.14.1
github.com/cenkalti/backoff/v4 v4.3.0
github.com/fatih/color v1.18.0
github.com/goccy/go-yaml v1.12.0
github.com/goccy/go-yaml v1.15.12
github.com/golang/mock v1.6.0
github.com/google/go-cmp v0.6.0
github.com/hashicorp/go-multierror v1.1.1
Expand Down Expand Up @@ -41,5 +41,4 @@ require (
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/xerrors v0.0.0-20240716161551-93cc26a95ae9 // indirect
)
14 changes: 2 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no=
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE=
github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=
github.com/goccy/go-yaml v1.12.0 h1:/1WHjnMsI1dlIBQutrvSMGZRQufVO3asrHfTwfACoPM=
github.com/goccy/go-yaml v1.12.0/go.mod h1:wKnAMd44+9JAAnGQpWVEgBzGt3YuTaQ4uXoHvE4m7WU=
github.com/goccy/go-yaml v1.15.12 h1:KLUSwfrUcTU6F8sAkf23OIPYC6aFVMNFSu4btROEm6w=
github.com/goccy/go-yaml v1.15.12/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA=
github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
Expand Down Expand Up @@ -55,8 +49,6 @@ github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfn
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-encoding v0.0.2 h1:OC1L+QXLJge9n7yIE3R5Os/UNasUeFvK3Sa4NjbDi6c=
Expand Down Expand Up @@ -130,8 +122,6 @@ golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20240716161551-93cc26a95ae9 h1:LLhsEBxRTBLuKlQxFBYUOU8xyFgXv6cOTp2HASDlsDk=
golang.org/x/xerrors v0.0.0-20240716161551-93cc26a95ae9/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E=
Expand Down
4 changes: 2 additions & 2 deletions mock/protocol/grpc/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestUnaryHandler_failure(t *testing.T) {
Expect: yamlutil.RawMessage("-"),
},
},
expect: "failed to unmarshal: [1:1] string was used where mapping is expected",
expect: "failed to unmarshal: [1:1] sequence was used where mapping is expected",
},
"invalid expect service": {
mocks: []protocol.Mock{
Expand Down Expand Up @@ -124,7 +124,7 @@ func TestUnaryHandler_failure(t *testing.T) {
svcName: svcName,
method: md,
decode: func(_ any) error { return nil },
expect: ".response: failed to unmarshal response: [1:1] string was used where mapping is expected",
expect: ".response: failed to unmarshal response: [1:1] sequence was used where mapping is expected",
},
"failed to execute template of response": {
mocks: []protocol.Mock{
Expand Down
8 changes: 4 additions & 4 deletions schema/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ func TestLoadConfig(t *testing.T) {
"invalid version": {
path: "testdata/config/invalid-version.yaml",
expect: `invalid version: [2:3] cannot unmarshal []interface {} into Go value of type string
1 | schemaVersion:
> 2 | - config
^
3 | - v1`,
1 | schemaVersion:
> 2 | - config
^
3 | - v1`,
},
"invalid scenarios": {
path: "testdata/config/invalid-scenarios.yaml",
Expand Down
5 changes: 3 additions & 2 deletions schema/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,9 @@ func TestLoadScenarios(t *testing.T) {
"invalid": {
path: "testdata/invalid.yaml",
expect: `failed to decode YAML: [1:8] cannot unmarshal yaml.MapSlice into Go struct field Scenario.Title of type string
> 1 | title: {}
^`,
> 1 | title: {}
^
`,
},
"unknown schema version": {
path: "testdata/unknown-schema-version.yaml",
Expand Down
2 changes: 1 addition & 1 deletion schema/testdata/broken.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
-
:
4 changes: 4 additions & 0 deletions schema/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ func readDocsWithSchemaVersionFromBytes(b []byte) ([]*docWithSchemaVersion, erro
if len(f.Docs) == 0 {
return nil, nil
}
if len(f.Docs) == 1 && f.Docs[0].Body == nil {
// YAML interprets an empty string as null, so if docs body is nil, it should be treated as empty content.
return nil, nil
}

docs := []*docWithSchemaVersion{}
for _, doc := range f.Docs {
Expand Down
4 changes: 2 additions & 2 deletions schema/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ func TestReadDocWithSchemaVersions(t *testing.T) {
},
"broken YAML": {
path: "testdata/broken.yaml",
expect: `[1:1] empty sequence entry
> 1 | -
expect: `[1:1] unexpected key name
> 1 | :
^
`,
},
Expand Down
5 changes: 4 additions & 1 deletion template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,10 @@ func (t *Template) executeParameterExpr(ctx context.Context, e *ast.ParameterExp
}

// Left arrow function arguments must be a string in YAML.
b, err := yaml.Marshal(v)
// If the `v` is a map or slice(array) instance, directly concatenating the output string would result in something like
// "a: key: value", which is invalid YAML.
// To resolve this problem, flow mode is used to create valid YAML, such as 'a: {key: value}'.
b, err := yaml.MarshalWithOptions(v, yaml.Flow(true))
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 6b4cd94

Please sign in to comment.