mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-09 20:47:44 +00:00
More hardening with digitla ocean
some ref handling was a bit strange, now it's rendering correctly. I have a feeling we will be back to the diff engine at some point soon, it's picking up some strange changes that are so deep in the model, I can't determine what is what, so we will wait for another set of triggers to appear.
This commit is contained in:
@@ -124,6 +124,60 @@ value:
|
||||
|
||||
}
|
||||
|
||||
func TestExample_ExtractExampleValue_Map(t *testing.T) {
|
||||
|
||||
yml := `hot:
|
||||
summer: nights
|
||||
pizza: oven`
|
||||
|
||||
var idxNode yaml.Node
|
||||
_ = yaml.Unmarshal([]byte(yml), &idxNode)
|
||||
|
||||
val := ExtractExampleValue(idxNode.Content[0])
|
||||
if v, ok := val.(map[string]interface{}); ok {
|
||||
if r, rok := v["hot"].(map[string]interface{}); rok {
|
||||
assert.Equal(t, "nights", r["summer"])
|
||||
assert.Equal(t, "oven", r["pizza"])
|
||||
} else {
|
||||
assert.Fail(t, "failed to decode correctly.")
|
||||
}
|
||||
} else {
|
||||
assert.Fail(t, "failed to decode correctly.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestExample_ExtractExampleValue_Slice(t *testing.T) {
|
||||
|
||||
yml := `- hot:
|
||||
summer: nights
|
||||
- hotter:
|
||||
pizza: oven`
|
||||
|
||||
var idxNode yaml.Node
|
||||
_ = yaml.Unmarshal([]byte(yml), &idxNode)
|
||||
|
||||
val := ExtractExampleValue(idxNode.Content[0])
|
||||
if v, ok := val.([]interface{}); ok {
|
||||
for w := range v {
|
||||
if r, rok := v[w].(map[string]interface{}); rok {
|
||||
for k := range r {
|
||||
if k == "hotter" {
|
||||
assert.Equal(t, "oven", r[k].(map[string]interface{})["pizza"])
|
||||
}
|
||||
if k == "hot" {
|
||||
assert.Equal(t, "nights", r[k].(map[string]interface{})["summer"])
|
||||
}
|
||||
}
|
||||
} else {
|
||||
assert.Fail(t, "failed to decode correctly.")
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
assert.Fail(t, "failed to decode correctly.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestExample_Hash(t *testing.T) {
|
||||
|
||||
left := `summary: hot
|
||||
|
||||
Reference in New Issue
Block a user