mirror of
https://github.com/podman-container-tools/podman.git
synced 2026-08-08 01:45:43 +00:00
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>
30 lines
537 B
Go
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))
|
|
}
|
|
}
|