fix: continued moving everything to orderedmaps plus cleaned up most the tests

This commit is contained in:
Tristan Cartledge
2023-12-01 17:37:07 +00:00
parent 0f3d0cb28f
commit a4ad09aab3
169 changed files with 3435 additions and 3764 deletions

View File

@@ -17,7 +17,6 @@ import (
)
func TestNewExample(t *testing.T) {
var cNode yaml.Node
yml := `summary: an example
@@ -37,18 +36,23 @@ x-hack: code`
// build high
highExample := NewExample(&lowExample)
var xHack string
_ = highExample.Extensions.GetOrZero("x-hack").Decode(&xHack)
var example string
_ = highExample.Value.Decode(&example)
assert.Equal(t, "an example", highExample.Summary)
assert.Equal(t, "something more", highExample.Description)
assert.Equal(t, "https://pb33f.io", highExample.ExternalValue)
assert.Equal(t, "code", highExample.Extensions["x-hack"])
assert.Equal(t, "a thing", highExample.Value)
assert.Equal(t, "code", xHack)
assert.Equal(t, "a thing", example)
assert.Equal(t, 4, highExample.GoLow().ExternalValue.ValueNode.Line)
assert.NotNil(t, highExample.GoLowUntyped())
// render the example as YAML
rendered, _ := highExample.Render()
assert.Equal(t, strings.TrimSpace(string(rendered)), yml)
assert.Equal(t, yml, strings.TrimSpace(string(rendered)))
}
func TestExtractExamples(t *testing.T) {
@@ -71,11 +75,9 @@ func TestExtractExamples(t *testing.T) {
)
assert.Equal(t, "herbs", ExtractExamples(examplesMap).GetOrZero("green").Summary)
}
func ExampleNewExample() {
// create some example yaml (or can be JSON, it does not matter)
yml := `summary: something interesting
description: something more interesting with detail
@@ -98,5 +100,4 @@ x-hack: code`
fmt.Print(highExample.ExternalValue)
// Output: https://pb33f.io
}