mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-06 12:37:49 +00:00
Also ran `gofmt` across the entire project. Things need cleaning up. Signed-off-by: Dave Shanley <dave@quobix.com>
68 lines
1.4 KiB
Go
68 lines
1.4 KiB
Go
// Copyright 2023 Princess B33f Heavy Industries / Dave Shanley
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package v3
|
|
|
|
import (
|
|
"github.com/stretchr/testify/assert"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestEncoding_MarshalYAML(t *testing.T) {
|
|
|
|
explode := true
|
|
encoding := &Encoding{
|
|
ContentType: "application/json",
|
|
Headers: map[string]*Header{"x-pizza-time": {Description: "oh yes please"}},
|
|
Style: "simple",
|
|
Explode: &explode,
|
|
}
|
|
|
|
rend, _ := encoding.Render()
|
|
|
|
desired := `contentType: application/json
|
|
headers:
|
|
x-pizza-time:
|
|
description: oh yes please
|
|
style: simple
|
|
explode: true`
|
|
|
|
assert.Equal(t, desired, strings.TrimSpace(string(rend)))
|
|
|
|
explode = false
|
|
encoding.Explode = &explode
|
|
rend, _ = encoding.Render()
|
|
|
|
desired = `contentType: application/json
|
|
headers:
|
|
x-pizza-time:
|
|
description: oh yes please
|
|
style: simple`
|
|
|
|
assert.Equal(t, desired, strings.TrimSpace(string(rend)))
|
|
|
|
encoding.Explode = nil
|
|
rend, _ = encoding.Render()
|
|
|
|
desired = `contentType: application/json
|
|
headers:
|
|
x-pizza-time:
|
|
description: oh yes please
|
|
style: simple`
|
|
|
|
assert.Equal(t, desired, strings.TrimSpace(string(rend)))
|
|
|
|
encoding.Explode = &explode
|
|
rend, _ = encoding.Render()
|
|
|
|
desired = `contentType: application/json
|
|
headers:
|
|
x-pizza-time:
|
|
description: oh yes please
|
|
style: simple`
|
|
|
|
assert.Equal(t, desired, strings.TrimSpace(string(rend)))
|
|
|
|
}
|