github.com/snyk/vervet/v3@v3.7.0/util_test.go (about)

     1  package vervet_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	qt "github.com/frankban/quicktest"
     7  	"github.com/ghodss/yaml"
     8  
     9  	"github.com/snyk/vervet/v3"
    10  	"github.com/snyk/vervet/v3/testdata"
    11  )
    12  
    13  func TestToSpecYAML(t *testing.T) {
    14  	c := qt.New(t)
    15  	doc, err := vervet.NewDocumentFile(testdata.Path("resources/_examples/hello-world/2021-06-01/spec.yaml"))
    16  	c.Assert(err, qt.IsNil)
    17  	yamlBuf, err := vervet.ToSpecYAML(doc)
    18  	c.Assert(err, qt.IsNil)
    19  	doc2 := map[string]interface{}{}
    20  	err = yaml.Unmarshal(yamlBuf, &doc2)
    21  	c.Assert(err, qt.IsNil)
    22  	c.Assert(doc2["openapi"], qt.Equals, "3.0.3")
    23  }