2026-04-14 00:41:35 +03:00
|
|
|
//go:build integration
|
|
|
|
|
// +build integration
|
|
|
|
|
|
2023-06-23 04:08:00 +03:00
|
|
|
package yandex
|
|
|
|
|
|
|
|
|
|
import (
|
2026-04-20 05:53:13 +03:00
|
|
|
"context"
|
2023-06-23 04:08:00 +03:00
|
|
|
"testing"
|
|
|
|
|
|
2023-06-23 04:16:45 +03:00
|
|
|
"github.com/karust/openserp/core"
|
2026-04-14 00:41:35 +03:00
|
|
|
"github.com/karust/openserp/testutil"
|
2026-04-14 02:05:58 +03:00
|
|
|
"github.com/karust/openserp/testutil/ithelper"
|
2023-06-23 04:08:00 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestSearchYandex(t *testing.T) {
|
2026-04-14 00:41:35 +03:00
|
|
|
testutil.RequireIntegration(t)
|
2023-06-23 04:08:00 +03:00
|
|
|
|
2026-04-14 02:05:58 +03:00
|
|
|
browser := ithelper.CreateBrowser(t)
|
2023-06-28 22:20:19 +03:00
|
|
|
yand := New(*browser, core.SearchEngineOptions{})
|
2023-06-23 04:08:00 +03:00
|
|
|
|
|
|
|
|
query := core.Query{Text: "HEY", Limit: 10}
|
2026-04-20 05:53:13 +03:00
|
|
|
results, err := yand.Search(context.Background(), query)
|
2026-04-14 02:05:58 +03:00
|
|
|
ithelper.HandleError(t, "yandex web search", err)
|
2023-06-23 04:08:00 +03:00
|
|
|
|
|
|
|
|
if len(results) == 0 {
|
|
|
|
|
t.Fatalf("[SearchYandex] returned empty result")
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-07-05 18:42:14 +03:00
|
|
|
|
|
|
|
|
func TestImageYandex(t *testing.T) {
|
2026-04-14 00:41:35 +03:00
|
|
|
testutil.RequireIntegration(t)
|
|
|
|
|
|
2026-04-14 02:05:58 +03:00
|
|
|
browser := ithelper.CreateBrowser(t)
|
2023-07-05 18:42:14 +03:00
|
|
|
yand := New(*browser, core.SearchEngineOptions{})
|
|
|
|
|
|
2024-05-12 01:41:53 +03:00
|
|
|
query := core.Query{Text: "furry tiger", Limit: 30}
|
2026-04-20 05:53:13 +03:00
|
|
|
results, err := yand.SearchImage(context.Background(), query)
|
2026-04-14 02:05:58 +03:00
|
|
|
ithelper.HandleError(t, "yandex image search", err)
|
2023-07-05 18:42:14 +03:00
|
|
|
|
2026-04-14 00:41:35 +03:00
|
|
|
if len(results) == 0 {
|
2023-07-05 18:42:14 +03:00
|
|
|
t.Fatalf("[ImageYandex] returned empty result")
|
|
|
|
|
}
|
|
|
|
|
}
|