Merge branch 'main' into ordered-libopenapi

This commit is contained in:
Tristan Cartledge
2023-12-01 17:57:05 +00:00
14 changed files with 174704 additions and 54215 deletions

View File

@@ -107,6 +107,38 @@ biscuit:
assert.Equal(t, 1, extChanges.TotalBreakingChanges())
}
// codecov seems to get upset with this not being covered.
// so lets run the damn thing a few hundred thousand times.
func BenchmarkCompareSecurityRequirement_Remove(b *testing.B) {
left := `auth:
- pizza
- pie`
right := `auth:
- pie
- pizza
biscuit:
- digestive`
var lNode, rNode yaml.Node
_ = yaml.Unmarshal([]byte(left), &lNode)
_ = yaml.Unmarshal([]byte(right), &rNode)
for i := 0; i < b.N; i++ {
var lDoc base.SecurityRequirement
var rDoc base.SecurityRequirement
_ = low.BuildModel(lNode.Content[0], &lDoc)
_ = low.BuildModel(rNode.Content[0], &rDoc)
_ = lDoc.Build(context.Background(), nil, lNode.Content[0], nil)
_ = rDoc.Build(context.Background(), nil, rNode.Content[0], nil)
extChanges := CompareSecurityRequirement(&rDoc, &lDoc)
assert.Equal(b, 1, extChanges.TotalChanges())
assert.Len(b, extChanges.GetAllChanges(), 1)
assert.Equal(b, 1, extChanges.TotalBreakingChanges())
}
}
func TestCompareSecurityRequirement_SwapOut_V2(t *testing.T) {
left := `cheese: