mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-09 20:47:44 +00:00
Churning through v3 models now.
mutations everywhere, for everyone!
This commit is contained in:
43
datamodel/high/v3/server_variable_test.go
Normal file
43
datamodel/high/v3/server_variable_test.go
Normal file
@@ -0,0 +1,43 @@
|
||||
// Copyright 2023 Princess B33f Heavy Industries / Dave Shanley
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v3
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestServerVariable_MarshalYAML(t *testing.T) {
|
||||
|
||||
svar := &ServerVariable{
|
||||
Enum: []string{"one", "two", "three"},
|
||||
Description: "money day",
|
||||
}
|
||||
|
||||
desired := `enum:
|
||||
- one
|
||||
- two
|
||||
- three
|
||||
description: money day`
|
||||
|
||||
svarRend, _ := svar.Render()
|
||||
|
||||
assert.Equal(t, desired, strings.TrimSpace(string(svarRend)))
|
||||
|
||||
// mutate
|
||||
|
||||
svar.Default = "is moments away"
|
||||
|
||||
desired = `enum:
|
||||
- one
|
||||
- two
|
||||
- three
|
||||
default: is moments away
|
||||
description: money day`
|
||||
|
||||
svarRend, _ = svar.Render()
|
||||
|
||||
assert.Equal(t, desired, strings.TrimSpace(string(svarRend)))
|
||||
}
|
||||
Reference in New Issue
Block a user