mirror of
https://github.com/containers/podman.git
synced 2025-06-21 01:19:15 +08:00
Better test and idomatic code.
Adding another check in the `podman search --list-tags --format json` test case. Replacing an anonymous struct by \`listEntryTag\` struct. Signed-off-by: Alexandre Fourcat <afourcat@gmail.com>
This commit is contained in:
@ -26,6 +26,12 @@ type searchOptionsWrapper struct {
|
|||||||
Format string // For go templating
|
Format string // For go templating
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// listEntryTag is a utility structure used for json serialization.
|
||||||
|
type listEntryTag struct {
|
||||||
|
Name string
|
||||||
|
Tags []string
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
searchOptions = searchOptionsWrapper{}
|
searchOptions = searchOptionsWrapper{}
|
||||||
searchDescription = `Search registries for a given image. Can search all the default registries or a specific registry.
|
searchDescription = `Search registries for a given image. Can search all the default registries or a specific registry.
|
||||||
@ -189,11 +195,8 @@ func printJson(v interface{}) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildListTagsJson(searchReport []entities.ImageSearchReport) interface{} {
|
func buildListTagsJson(searchReport []entities.ImageSearchReport) []listEntryTag {
|
||||||
entries := []struct {
|
entries := []listEntryTag{}
|
||||||
Name string
|
|
||||||
Tags []string
|
|
||||||
}{}
|
|
||||||
|
|
||||||
ReportLoop:
|
ReportLoop:
|
||||||
for _, report := range searchReport {
|
for _, report := range searchReport {
|
||||||
@ -203,10 +206,7 @@ ReportLoop:
|
|||||||
continue ReportLoop
|
continue ReportLoop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newElem := struct {
|
newElem := listEntryTag{
|
||||||
Name string
|
|
||||||
Tags []string
|
|
||||||
}{
|
|
||||||
report.Name,
|
report.Name,
|
||||||
[]string{report.Tag},
|
[]string{report.Tag},
|
||||||
}
|
}
|
||||||
|
@ -131,6 +131,7 @@ registries = ['{{.Host}}:{{.Port}}']`
|
|||||||
Expect(search.IsJSONOutputValid()).To(BeTrue())
|
Expect(search.IsJSONOutputValid()).To(BeTrue())
|
||||||
Expect(search.OutputToString()).To(ContainSubstring("docker.io/library/alpine"))
|
Expect(search.OutputToString()).To(ContainSubstring("docker.io/library/alpine"))
|
||||||
Expect(search.OutputToString()).To(ContainSubstring("3.10"))
|
Expect(search.OutputToString()).To(ContainSubstring("3.10"))
|
||||||
|
Expect(search.OutputToString()).To(ContainSubstring("2.7"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman search no-trunc flag", func() {
|
It("podman search no-trunc flag", func() {
|
||||||
|
Reference in New Issue
Block a user