From 442b048575ae5e19dd033c10b51187b641303e89 Mon Sep 17 00:00:00 2001 From: quobix Date: Fri, 19 Jan 2024 19:35:17 -0500 Subject: [PATCH] added missing test coverage Signed-off-by: quobix --- what-changed/model/operation_test.go | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/what-changed/model/operation_test.go b/what-changed/model/operation_test.go index 782a30da..cc237f31 100644 --- a/what-changed/model/operation_test.go +++ b/what-changed/model/operation_test.go @@ -1675,3 +1675,32 @@ parameters: assert.Len(t, extChanges.GetAllChanges(), 1) assert.Equal(t, 1, extChanges.TotalBreakingChanges()) } + +func TestComparePathItem_V2_AddRequiredParam(t *testing.T) { + + left := `operationId: listBurgerDressings` + + right := `operationId: listBurgerDressings +parameters: + - in: head + name: burgerId + required: true` + + var lNode, rNode yaml.Node + _ = yaml.Unmarshal([]byte(left), &lNode) + _ = yaml.Unmarshal([]byte(right), &rNode) + + // create low level objects + var lDoc v2.Operation + var rDoc v2.Operation + _ = 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) + + // compare. + extChanges := CompareOperations(&lDoc, &rDoc) + assert.Equal(t, 1, extChanges.TotalChanges()) + assert.Len(t, extChanges.GetAllChanges(), 1) + assert.Equal(t, 1, extChanges.TotalBreakingChanges()) +}