From b55fe48bd8542400a5bc32f0e87c53ed6715dd60 Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Wed, 10 Jun 2020 16:02:12 +1000 Subject: [PATCH] Update to latest go-yaml library, updated test w.r.t. formatting and comment handling fixes --- cmd/compare_test.go | 6 +++--- cmd/delete_test.go | 4 ++-- cmd/merge_test.go | 16 ++++++++-------- cmd/new_test.go | 2 +- cmd/prefix_test.go | 4 ++-- cmd/read_test.go | 40 ++++++++++++++++++++-------------------- cmd/write_test.go | 20 ++++++++++---------- go.mod | 6 +++--- go.sum | 13 ++++++------- 9 files changed, 55 insertions(+), 56 deletions(-) diff --git a/cmd/compare_test.go b/cmd/compare_test.go index 0d409af..630c550 100644 --- a/cmd/compare_test.go +++ b/cmd/compare_test.go @@ -40,9 +40,9 @@ func TestComparePrettyCmd(t *testing.T) { } expectedOutput := ` a: simple # just the best b: - - 1 --- 2 -+- 3 + - 1 +- - 2 ++ - 3 c: test: 1 ` diff --git a/cmd/delete_test.go b/cmd/delete_test.go index faeba60..d5f3291 100644 --- a/cmd/delete_test.go +++ b/cmd/delete_test.go @@ -94,8 +94,8 @@ b: expectedOutput := `a: 2 b: hi: - - name: fred - - name: sam + - name: fred + - name: sam ` test.AssertResult(t, expectedOutput, result.Output) } diff --git a/cmd/merge_test.go b/cmd/merge_test.go index e4d2ada..23e18c6 100644 --- a/cmd/merge_test.go +++ b/cmd/merge_test.go @@ -101,10 +101,10 @@ func TestMergeAppendArraysCmd(t *testing.T) { t.Error(result.Error) } expectedOutput := `people: -- name: Barry - age: 21 -- name: Roger - age: 44 + - name: Barry + age: 21 + - name: Roger + age: 44 ` test.AssertResult(t, expectedOutput, result.Output) } @@ -146,8 +146,8 @@ another: document: here a: simple # just the best b: -- 1 -- 2 + - 1 + - 2 c: test: 1 --- @@ -317,8 +317,8 @@ func TestMergeAllowEmptyTargetCmd(t *testing.T) { } expectedOutput := `a: simple # just the best b: -- 1 -- 2 + - 1 + - 2 c: test: 1 ` diff --git a/cmd/new_test.go b/cmd/new_test.go index 4c20195..de53020 100644 --- a/cmd/new_test.go +++ b/cmd/new_test.go @@ -25,7 +25,7 @@ func TestNewArrayCmd(t *testing.T) { t.Error(result.Error) } expectedOutput := `b: -- 3 + - 3 ` test.AssertResult(t, expectedOutput, result.Output) } diff --git a/cmd/prefix_test.go b/cmd/prefix_test.go index 9cc18c6..ee5c198 100644 --- a/cmd/prefix_test.go +++ b/cmd/prefix_test.go @@ -41,8 +41,8 @@ func TestPrefixCmdArray(t *testing.T) { t.Error(result.Error) } expectedOutput := `- d: - - b: - c: 3 + - b: + c: 3 ` test.AssertResult(t, expectedOutput, result.Output) } diff --git a/cmd/read_test.go b/cmd/read_test.go index 61b59de..57ae7bc 100644 --- a/cmd/read_test.go +++ b/cmd/read_test.go @@ -871,13 +871,13 @@ func TestReadPrettyPrintCmd(t *testing.T) { b: c: 2 d: - - 3 - - 4 + - 3 + - 4 e: - - name: fred - value: 3 - - name: sam - value: 4 + - name: fred + value: 3 + - name: sam + value: 4 ` test.AssertResult(t, expectedOutput, result.Output) } @@ -892,13 +892,13 @@ func TestReadPrettyPrintWithIndentCmd(t *testing.T) { b: c: 2 d: - - 3 - - 4 + - 3 + - 4 e: - - name: fred - value: 3 - - name: sam - value: 4 + - name: fred + value: 3 + - name: sam + value: 4 ` test.AssertResult(t, expectedOutput, result.Output) } @@ -914,8 +914,8 @@ func TestReadCmd_ArrayYaml_NoPath(t *testing.T) { hosts: lalaland name: "Apply smth" roles: - - lala - - land + - lala + - land serial: 1 - become: false gather_facts: true @@ -934,8 +934,8 @@ gather_facts: false hosts: lalaland name: "Apply smth" roles: -- lala -- land + - lala + - land serial: 1 ` test.AssertResult(t, expectedOutput, result.Output) @@ -952,8 +952,8 @@ gather_facts: false hosts: lalaland name: "Apply smth" roles: -- lala -- land + - lala + - land serial: 1 become: false gather_facts: true @@ -973,8 +973,8 @@ func TestReadCmd_ArrayYaml_SplatWithKeyAndValueCmd(t *testing.T) { hosts: lalaland name: "Apply smth" roles: - - lala - - land + - lala + - land serial: 1 '[1]': become: false diff --git a/cmd/write_test.go b/cmd/write_test.go index 7ed192a..f653ca3 100644 --- a/cmd/write_test.go +++ b/cmd/write_test.go @@ -261,9 +261,9 @@ func TestWriteAutoCreateCmd(t *testing.T) { t.Error(result.Error) } expectedOutput := `applications: -- name: app - env: - hello: world + - name: app + env: + hello: world ` test.AssertResult(t, expectedOutput, result.Output) } @@ -476,8 +476,8 @@ func TestWriteCmd_Append(t *testing.T) { t.Error(result.Error) } expectedOutput := `b: -- foo -- 7 + - foo + - 7 ` test.AssertResult(t, expectedOutput, result.Output) } @@ -508,8 +508,8 @@ func TestWriteCmd_AppendInlinePretty(t *testing.T) { t.Error(result.Error) } expectedOutput := `b: -- foo -- 7 + - foo + - 7 ` test.AssertResult(t, expectedOutput, result.Output) } @@ -527,7 +527,7 @@ func TestWriteCmd_AppendEmptyArray(t *testing.T) { } expectedOutput := `a: 2 b: -- v + - v ` test.AssertResult(t, expectedOutput, result.Output) } @@ -546,8 +546,8 @@ func TestWriteCmd_SplatArray(t *testing.T) { t.Error(result.Error) } expectedOutput := `b: -- c: new -- c: new + - c: new + - c: new ` test.AssertResult(t, expectedOutput, result.Output) } diff --git a/go.mod b/go.mod index cc48ad6..ead6b24 100644 --- a/go.mod +++ b/go.mod @@ -2,16 +2,16 @@ module github.com/mikefarah/yq/v3 require ( github.com/fatih/color v1.9.0 - github.com/goccy/go-yaml v1.4.3 + github.com/goccy/go-yaml v1.7.5 github.com/kylelemons/godebug v1.1.0 github.com/mattn/go-colorable v0.1.6 // indirect github.com/pkg/errors v0.9.1 github.com/spf13/cobra v1.0.0 github.com/spf13/pflag v1.0.5 // indirect - golang.org/x/sys v0.0.0-20200413165638-669c56c373c4 // indirect + golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980 // indirect golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 // indirect gopkg.in/op/go-logging.v1 v1.0.0-20160211212156-b2cb9fa56473 - gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c + gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c ) go 1.14 diff --git a/go.sum b/go.sum index 856f2cd..8b61967 100644 --- a/go.sum +++ b/go.sum @@ -29,8 +29,8 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/goccy/go-yaml v1.4.3 h1:+1jK1ost1TBEfWjciIMU8rciBq0poxurgS7XvLgQInM= -github.com/goccy/go-yaml v1.4.3/go.mod h1:PsEEJ29nIFZL07P/c8dv4P6rQkVFFXafQee85U+ERHA= +github.com/goccy/go-yaml v1.7.5 h1:dWvj+p3BG11S/GlUzwzt1WZz0lhBTzTIDtmXT/ZOaPY= +github.com/goccy/go-yaml v1.7.5/go.mod h1:wS4gNoLalDSJxo/SpngzPQ2BN4uuZVLCmbM4S3vd4+Y= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= @@ -144,8 +144,8 @@ golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193 golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200413165638-669c56c373c4 h1:opSr2sbRXk5X5/givKrrKj9HXxFpW2sdCiP8MJSKLQY= -golang.org/x/sys v0.0.0-20200413165638-669c56c373c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980 h1:OjiUf46hAmXblsZdnoSXsEUSKU8r1UEzcL5RVZ4gO9Y= +golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -175,7 +175,6 @@ gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bl gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.0-20191120175047-4206685974f2/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c h1:grhR+C34yXImVGp7EzNk+DTIk+323eIUWOmEevy6bDo= +gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=