in internal/webserver_test_helper/webserver_test_helper.go [167:199]
func (h *WebserverHelper) Search(repoID uint32, term string) (SearchResponse, error) {
query := searchQuery{
Q: term,
RepoIDs: []uint32{repoID},
Opts: searchOpts{
TotalMaxMatchCount: 20,
NumContextLines: 0,
},
}
queryJSON, err := json.Marshal(query)
if err != nil {
return SearchResponse{}, err
}
res, err := http.Post(h.searchURL(), "application/json", bytes.NewBuffer(queryJSON)) //nolint:bodyclose,noctx
if err != nil {
return SearchResponse{}, err
}
if res.StatusCode != http.StatusOK {
return SearchResponse{}, errors.New("search failed with non OK")
}
var result SearchResponse
dec := json.NewDecoder(res.Body)
if err := dec.Decode(&result); err != nil {
return SearchResponse{}, err
}
return result, nil
}