Skip to content

Commit

Permalink
Merge pull request #212 from imdario/dcc/issue-206
Browse files Browse the repository at this point in the history
Upgrade yaml to v3
  • Loading branch information
darccio committed May 25, 2022
2 parents 39ebbbb + f86e6f6 commit 80c13e1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -170,7 +170,7 @@ func main() {

Note: if test are failing due missing package, please execute:

go get gopkg.in/yaml.v2
go get gopkg.in/yaml.v3

### Transformers

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -2,4 +2,4 @@ module github.com/imdario/mergo

go 1.13

require gopkg.in/yaml.v2 v2.3.0
require gopkg.in/yaml.v3 v3.0.0
4 changes: 2 additions & 2 deletions go.sum
@@ -1,4 +1,4 @@
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0 h1:hjy8E9ON/egN1tAYqKb61G10WtihqetD4sz2H+8nIeA=
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
10 changes: 5 additions & 5 deletions mergo_test.go
Expand Up @@ -13,7 +13,7 @@ import (
"time"

"github.com/imdario/mergo"
"gopkg.in/yaml.v2"
"gopkg.in/yaml.v3"
)

type simpleTest struct {
Expand Down Expand Up @@ -603,18 +603,18 @@ func TestMapsWithNilPointer(t *testing.T) {
func TestYAMLMaps(t *testing.T) {
thing := loadYAML("testdata/thing.yml")
license := loadYAML("testdata/license.yml")
ft := thing["fields"].(map[interface{}]interface{})
fl := license["fields"].(map[interface{}]interface{})
ft := thing["fields"].(map[string]interface{})
fl := license["fields"].(map[string]interface{})
// license has one extra field (site) and another already existing in thing (author) that Mergo won't override.
expectedLength := len(ft) + len(fl) - 1
if err := mergo.Merge(&license, thing); err != nil {
t.Error(err.Error())
}
currentLength := len(license["fields"].(map[interface{}]interface{}))
currentLength := len(license["fields"].(map[string]interface{}))
if currentLength != expectedLength {
t.Errorf(`thing not merged in license properly, license must have %d elements instead of %d`, expectedLength, currentLength)
}
fields := license["fields"].(map[interface{}]interface{})
fields := license["fields"].(map[string]interface{})
if _, ok := fields["id"]; !ok {
t.Errorf(`thing not merged in license properly, license must have a new id field from thing`)
}
Expand Down

0 comments on commit 80c13e1

Please sign in to comment.