Skip to content

Commit

Permalink
Using third party library for yaml to JSON conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
mattrmiller committed Sep 5, 2018
1 parent 33545da commit e224b0f
Show file tree
Hide file tree
Showing 11 changed files with 997 additions and 65 deletions.
8 changes: 7 additions & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,7 @@
[[constraint]]
name = "github.com/tidwall/gjson"
version = "^1.1.3"

[[constraint]]
name = "github.com/ghodss/yaml"
version = "^1.0.0"
14 changes: 10 additions & 4 deletions manatest/testfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package manatest
import (
"errors"
"fmt"
yaml2 "github.com/ghodss/yaml"
"github.com/mattrmiller/go-mana-test/console"
"gopkg.in/resty.v1"
"gopkg.in/yaml.v2"
Expand Down Expand Up @@ -133,11 +134,16 @@ func (testFile *TestFile) Validate() error {

// Convert request body to json
if testFile.ReqBody != nil {
body, err := ConvertYamlToJSON(testFile.ReqBody)
yamlBytes, err := yaml.Marshal(testFile.ReqBody)
if err != nil {
return errors.New("unable to unmarshal JSON body")
return fmt.Errorf("unable to unmarshal YAML request body: %s", err)
}
testFile.ReqBody = body
body, err := yaml2.YAMLToJSON(yamlBytes)
if err != nil {
return fmt.Errorf("unable to unmarshal JSON request body: %s", err)
}

testFile.ReqBody = string(body)
}

// Validate headers
Expand All @@ -150,7 +156,7 @@ func (testFile *TestFile) Validate() error {

// -- Value
if len(header.Value) == 0 {
return errors.New("test file header must have 'value' fieldt")
return errors.New("test file header must have 'value' field")
}
}

Expand Down
39 changes: 0 additions & 39 deletions manatest/yaml.go

This file was deleted.

21 changes: 0 additions & 21 deletions manatest/yaml_test.go

This file was deleted.

20 changes: 20 additions & 0 deletions vendor/github.com/ghodss/yaml/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions vendor/github.com/ghodss/yaml/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 50 additions & 0 deletions vendor/github.com/ghodss/yaml/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

121 changes: 121 additions & 0 deletions vendor/github.com/ghodss/yaml/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e224b0f

Please sign in to comment.