mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-09 20:47:44 +00:00
what-changed operational
the code is working, the tests are passing. There is a lot more to check, but it's a good time to bring the feature into main.
This commit is contained in:
@@ -3,18 +3,41 @@
|
||||
|
||||
package what_changed
|
||||
|
||||
//func TestCompareOpenAPIDocuments(t *testing.T) {
|
||||
//
|
||||
// original, _ := ioutil.ReadFile("../test_specs/burgershop.openapi.yaml")
|
||||
// modified, _ := ioutil.ReadFile("../test_specs/burgershop.openapi-modified.yaml")
|
||||
// infoOrig, _ := datamodel.ExtractSpecInfo(original)
|
||||
// infoMod, _ := datamodel.ExtractSpecInfo(modified)
|
||||
//
|
||||
// origDoc, _ := v3.CreateDocument(infoOrig)
|
||||
// modDoc, _ := v3.CreateDocument(infoMod)
|
||||
//
|
||||
// changes := CompareOpenAPIDocuments(origDoc, modDoc)
|
||||
//
|
||||
// assert.Nil(t, changes)
|
||||
//
|
||||
//}
|
||||
import (
|
||||
"github.com/pb33f/libopenapi/datamodel"
|
||||
v3 "github.com/pb33f/libopenapi/datamodel/low/v3"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCompareOpenAPIDocuments(t *testing.T) {
|
||||
|
||||
original, _ := ioutil.ReadFile("../test_specs/burgershop.openapi.yaml")
|
||||
modified, _ := ioutil.ReadFile("../test_specs/burgershop.openapi-modified.yaml")
|
||||
infoOrig, _ := datamodel.ExtractSpecInfo(original)
|
||||
infoMod, _ := datamodel.ExtractSpecInfo(modified)
|
||||
|
||||
origDoc, _ := v3.CreateDocument(infoOrig)
|
||||
modDoc, _ := v3.CreateDocument(infoMod)
|
||||
|
||||
changes := CompareOpenAPIDocuments(origDoc, modDoc)
|
||||
assert.Equal(t, 1, changes.TotalChanges())
|
||||
assert.Equal(t, 0, changes.TotalBreakingChanges())
|
||||
|
||||
}
|
||||
|
||||
func Benchmark_CompareOpenAPIDocuments(b *testing.B) {
|
||||
|
||||
original, _ := ioutil.ReadFile("../test_specs/burgershop.openapi.yaml")
|
||||
modified, _ := ioutil.ReadFile("../test_specs/burgershop.openapi-modified.yaml")
|
||||
|
||||
infoOrig, _ := datamodel.ExtractSpecInfo(original)
|
||||
infoMod, _ := datamodel.ExtractSpecInfo(modified)
|
||||
origDoc, _ := v3.CreateDocument(infoOrig)
|
||||
modDoc, _ := v3.CreateDocument(infoMod)
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
CompareOpenAPIDocuments(origDoc, modDoc)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user