Swagger v2 high model at 100% coverage.

This commit is contained in:
Dave Shanley
2022-09-11 21:09:16 -04:00
parent 02633ad333
commit d2b974829d
6 changed files with 421 additions and 12 deletions

View File

@@ -39,3 +39,27 @@ x-hack: code`
assert.Equal(t, "a thing", highExample.Value)
assert.Equal(t, 4, highExample.GoLow().ExternalValue.ValueNode.Line)
}
func TestExtractExamples(t *testing.T) {
var cNode yaml.Node
yml := `summary: herbs`
_ = yaml.Unmarshal([]byte(yml), &cNode)
// build low
var lowExample lowbase.Example
_ = lowmodel.BuildModel(&cNode, &lowExample)
_ = lowExample.Build(cNode.Content[0], nil)
examplesMap := make(map[lowmodel.KeyReference[string]]lowmodel.ValueReference[*lowbase.Example])
examplesMap[lowmodel.KeyReference[string]{
Value: "green",
}] = lowmodel.ValueReference[*lowbase.Example]{
Value: &lowExample,
}
assert.Equal(t, "herbs", ExtractExamples(examplesMap)["green"].Summary)
}