mirror of https://github.com/containers/podman.git
Merge pull request #7141 from rhafer/image_descr_test
Add test case for description being present in search result
This commit is contained in:
commit
bfd34542f4
|
@ -638,6 +638,7 @@ func SearchImages(w http.ResponseWriter, r *http.Request) {
|
||||||
query := struct {
|
query := struct {
|
||||||
Term string `json:"term"`
|
Term string `json:"term"`
|
||||||
Limit int `json:"limit"`
|
Limit int `json:"limit"`
|
||||||
|
NoTrunc bool `json:"noTrunc"`
|
||||||
Filters []string `json:"filters"`
|
Filters []string `json:"filters"`
|
||||||
TLSVerify bool `json:"tlsVerify"`
|
TLSVerify bool `json:"tlsVerify"`
|
||||||
}{
|
}{
|
||||||
|
@ -650,7 +651,8 @@ func SearchImages(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
options := image.SearchOptions{
|
options := image.SearchOptions{
|
||||||
Limit: query.Limit,
|
Limit: query.Limit,
|
||||||
|
NoTrunc: query.NoTrunc,
|
||||||
}
|
}
|
||||||
if _, found := r.URL.Query()["tlsVerify"]; found {
|
if _, found := r.URL.Query()["tlsVerify"]; found {
|
||||||
options.InsecureSkipTLSVerify = types.NewOptionalBool(!query.TLSVerify)
|
options.InsecureSkipTLSVerify = types.NewOptionalBool(!query.TLSVerify)
|
||||||
|
@ -677,7 +679,7 @@ func SearchImages(w http.ResponseWriter, r *http.Request) {
|
||||||
for i := range searchResults {
|
for i := range searchResults {
|
||||||
reports[i].Index = searchResults[i].Index
|
reports[i].Index = searchResults[i].Index
|
||||||
reports[i].Name = searchResults[i].Name
|
reports[i].Name = searchResults[i].Name
|
||||||
reports[i].Description = searchResults[i].Index
|
reports[i].Description = searchResults[i].Description
|
||||||
reports[i].Stars = searchResults[i].Stars
|
reports[i].Stars = searchResults[i].Stars
|
||||||
reports[i].Official = searchResults[i].Official
|
reports[i].Official = searchResults[i].Official
|
||||||
reports[i].Automated = searchResults[i].Automated
|
reports[i].Automated = searchResults[i].Automated
|
||||||
|
|
|
@ -972,6 +972,10 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error {
|
||||||
// type: integer
|
// type: integer
|
||||||
// description: maximum number of results
|
// description: maximum number of results
|
||||||
// - in: query
|
// - in: query
|
||||||
|
// name: noTrunc
|
||||||
|
// type: boolean
|
||||||
|
// description: do not truncate any of the result strings
|
||||||
|
// - in: query
|
||||||
// name: filters
|
// name: filters
|
||||||
// type: string
|
// type: string
|
||||||
// description: |
|
// description: |
|
||||||
|
|
|
@ -439,6 +439,7 @@ func Search(ctx context.Context, term string, opts entities.ImageSearchOptions)
|
||||||
params := url.Values{}
|
params := url.Values{}
|
||||||
params.Set("term", term)
|
params.Set("term", term)
|
||||||
params.Set("limit", strconv.Itoa(opts.Limit))
|
params.Set("limit", strconv.Itoa(opts.Limit))
|
||||||
|
params.Set("noTrunc", strconv.FormatBool(opts.NoTrunc))
|
||||||
for _, f := range opts.Filters {
|
for _, f := range opts.Filters {
|
||||||
params.Set("filters", f)
|
params.Set("filters", f)
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
|
@ -98,6 +99,15 @@ registries = ['{{.Host}}:{{.Port}}']`
|
||||||
Expect(search.LineInOutputContains("quay.io/libpod/gate")).To(BeTrue())
|
Expect(search.LineInOutputContains("quay.io/libpod/gate")).To(BeTrue())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman search image with description", func() {
|
||||||
|
search := podmanTest.Podman([]string{"search", "quay.io/libpod/whalesay"})
|
||||||
|
search.WaitWithDefaultTimeout()
|
||||||
|
Expect(search.ExitCode()).To(Equal(0))
|
||||||
|
output := fmt.Sprintf("%s", search.Out.Contents())
|
||||||
|
match, _ := regexp.MatchString(`(?m)^quay.io\s+quay.io/libpod/whalesay\s+Static image used for automated testing.+$`, output)
|
||||||
|
Expect(match).To(BeTrue())
|
||||||
|
})
|
||||||
|
|
||||||
It("podman search format flag", func() {
|
It("podman search format flag", func() {
|
||||||
search := podmanTest.Podman([]string{"search", "--format", "table {{.Index}} {{.Name}}", "alpine"})
|
search := podmanTest.Podman([]string{"search", "--format", "table {{.Index}} {{.Name}}", "alpine"})
|
||||||
search.WaitWithDefaultTimeout()
|
search.WaitWithDefaultTimeout()
|
||||||
|
|
Loading…
Reference in New Issue