mirror of
https://github.com/podman-container-tools/podman.git
synced 2026-08-08 18:05:41 +00:00
* --format "table {{.field..." will print fields out in a table with
headings. Table keyword is removed, spaces between fields are
converted to tabs
* Update parse.MatchesJSONFormat()'s regex to be more inclusive
* Add report.Headers(), obtain all the field names to be used as
column headers, a map of field name to column headers may be provided
to override the field names
* Update several commands to use new functions
Signed-off-by: Jhon Honce <jhonce@redhat.com>
45 lines
931 B
Go
45 lines
931 B
Go
package parse
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"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 . }}", true},
|
|
{" {{ json . }} ", true},
|
|
{"{{ json .", false},
|
|
{"json . }}", false},
|
|
{"{{.ID }} json .", false},
|
|
{"json .", false},
|
|
{"{{json.}}", false},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
assert.Equal(t, tt.expected, MatchesJSONFormat(tt.input))
|
|
}
|
|
|
|
for _, tc := range tests {
|
|
tc := tc
|
|
label := "MatchesJSONFormat/" + strings.ReplaceAll(tc.input, " ", "_")
|
|
t.Run(label, func(t *testing.T) {
|
|
t.Parallel()
|
|
assert.Equal(t, tc.expected, MatchesJSONFormat(tc.input), fmt.Sprintf("Scanning %q failed", tc.input))
|
|
})
|
|
}
|
|
}
|