mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-06 04:20:11 +00:00
Also ran `gofmt` across the entire project. Things need cleaning up. Signed-off-by: Dave Shanley <dave@quobix.com>
44 lines
824 B
Go
44 lines
824 B
Go
// Copyright 2023 Princess B33f Heavy Industries / Dave Shanley
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package v3
|
|
|
|
import (
|
|
"github.com/stretchr/testify/assert"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestServer_MarshalYAML(t *testing.T) {
|
|
|
|
server := &Server{
|
|
URL: "https://pb33f.io",
|
|
Description: "the b33f",
|
|
}
|
|
|
|
desired := `url: https://pb33f.io
|
|
description: the b33f`
|
|
|
|
rend, _ := server.Render()
|
|
assert.Equal(t, desired, strings.TrimSpace(string(rend)))
|
|
|
|
// mutate
|
|
server.Variables = map[string]*ServerVariable{
|
|
"rainbow": {
|
|
Enum: []string{"one", "two", "three"},
|
|
},
|
|
}
|
|
|
|
desired = `url: https://pb33f.io
|
|
description: the b33f
|
|
variables:
|
|
rainbow:
|
|
enum:
|
|
- one
|
|
- two
|
|
- three`
|
|
|
|
rend, _ = server.Render()
|
|
assert.Equal(t, desired, strings.TrimSpace(string(rend)))
|
|
}
|