Skip to content

Commit

Permalink
added missing test coverage
Browse files Browse the repository at this point in the history
Signed-off-by: quobix <dave@quobix.com>
  • Loading branch information
daveshanley committed Jan 20, 2024
1 parent 799f5e2 commit 442b048
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions what-changed/model/operation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}

0 comments on commit 442b048

Please sign in to comment.