Skip to content

Commit

Permalink
Added more tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
daveshanley committed Aug 7, 2024
1 parent 07ff746 commit c3eb16d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions datamodel/low/v3/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ func (co *Components) FindLink(link string) *low.ValueReference[*Link] {
return low.FindItemInOrderedMap[*Link](link, co.Links.Value)
}

func (co *Components) FindPathItem(path string) *low.ValueReference[*PathItem] {
return low.FindItemInOrderedMap[*PathItem](path, co.PathItems.Value)
}

func (co *Components) FindCallback(callback string) *low.ValueReference[*Callback] {
return low.FindItemInOrderedMap[*Callback](callback, co.Callbacks.Value)
}
Expand Down
10 changes: 7 additions & 3 deletions datamodel/low/v3/components_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ var testComponentsYaml = `
eighteen:
'{raference}':
post:
description: eighteen of many`
description: eighteen of many
pathItems:
/nineteen:
get:
description: nineteen of many`

func TestComponents_Build_Success(t *testing.T) {
var idxNode yaml.Node
Expand Down Expand Up @@ -96,13 +100,13 @@ func TestComponents_Build_Success(t *testing.T) {
assert.Equal(t, "thirteen of many", n.FindSecurityScheme("thirteen").Value.Description.Value)
assert.Equal(t, "fourteen of many", n.FindSecurityScheme("fourteen").Value.Description.Value)
assert.Equal(t, "fifteen of many", n.FindLink("fifteen").Value.Description.Value)
assert.Equal(t, "sixteen of many", n.FindLink("sixteen").Value.Description.Value)
assert.Equal(t, "seventeen of many",
n.FindCallback("seventeen").Value.FindExpression("{reference}").Value.Post.Value.Description.Value)
assert.Equal(t, "eighteen of many",
n.FindCallback("eighteen").Value.FindExpression("{raference}").Value.Post.Value.Description.Value)
assert.Equal(t, "nineteen of many", n.FindPathItem("/nineteen").Value.Get.Value.Description.Value)

assert.Equal(t, "76328a0e32a9989471d335734af04a37bdfad333cf8cd8aa8065998c3a1489a2",
assert.Equal(t, "c3f868ba89e4c5260831e1fc99dfcacc6e7e63299430bbb88dcfffd06d633e1c",
low.GenerateHashString(&n))
}

Expand Down

0 comments on commit c3eb16d

Please sign in to comment.