mirror of
https://github.com/karust/openserp.git
synced 2026-08-24 17:00:06 +08:00
45 lines
921 B
Go
45 lines
921 B
Go
package yandex
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/karust/openserp/core"
|
|
)
|
|
|
|
var browser *core.Browser
|
|
|
|
func init() {
|
|
opts := core.BrowserOpts{IsHeadless: false, IsLeakless: false, Timeout: time.Second * 15, LeavePageOpen: true}
|
|
browser, _ = core.NewBrowser(opts)
|
|
}
|
|
|
|
func TestSearchYandex(t *testing.T) {
|
|
|
|
yand := New(*browser, core.SearchEngineOptions{})
|
|
|
|
query := core.Query{Text: "HEY", Limit: 10}
|
|
results, err := yand.Search(query)
|
|
if err != nil {
|
|
t.Fatalf("Cannot [SearchYandex]: %s", err)
|
|
}
|
|
|
|
if len(results) == 0 {
|
|
t.Fatalf("[SearchYandex] returned empty result")
|
|
}
|
|
}
|
|
|
|
func TestImageYandex(t *testing.T) {
|
|
yand := New(*browser, core.SearchEngineOptions{})
|
|
|
|
query := core.Query{Text: "furry tiger", Limit: 90}
|
|
results, err := yand.SearchImage(query)
|
|
if err != nil {
|
|
t.Fatalf("Cannot [ImageYandex]: %s", err)
|
|
}
|
|
|
|
if len(results) < 90 {
|
|
t.Fatalf("[ImageYandex] returned empty result")
|
|
}
|
|
}
|