Skip to content

Commit d562df6

Browse files
committed
Examples: Improve the test for "valyala/fasthttp"
Exit with error also in case of an error response (such as 406). Related: #114
1 parent 476e382 commit d562df6

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

_examples/fasthttp/cmd/main.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,17 @@ func main() {
5050
defer cancel()
5151

5252
go func() {
53-
es.Info()
54-
if _, err := es.Search(
53+
res, err := es.Search(
5554
es.Search.WithBody(strings.NewReader(`{"query":{"match":{"title":"foo"}}}`)),
5655
es.Search.WithPretty(),
57-
); err != nil {
56+
)
57+
cancel()
58+
if err != nil {
5859
log.Fatalf("Error getting response: %s", err)
5960
}
60-
cancel()
61+
if res.IsError() {
62+
log.Fatalf("Error response: %s", res)
63+
}
6164
}()
6265

6366
select {

0 commit comments

Comments
 (0)