spiegel_podman/cmd/podman/parse/json_test.go
Valentin Rothberg 1fb32b9b2f version/info: format: allow more json variants
Allow more variants to yield json output for `podman version` and
`podman info`.  Instead of comparing strings, use a regex and add
unit and e2e tests.

Fixes: #6927
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-07-22 14:42:53 -04:00

30 lines
537 B
Go

package parse
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestMatchesJSONFormat(t *testing.T) {
tests := []struct {
input string
expected bool
}{
{"json", true},
{" json", true},
{"json ", true},
{" json ", true},
{"{{json .}}", true},
{"{{ json .}}", true},
{"{{json . }}", true},
{" {{ json . }} ", true},
{"{{json }}", false},
{"{{json .", false},
{"json . }}", false},
}
for _, tt := range tests {
assert.Equal(t, tt.expected, MatchesJSONFormat(tt.input))
}
}