Documentation
¶
Overview ¶
Package engtest includes a number of helpers for testing search engines.
engtest aids in testing engines and comparing any number of inputs with their expected outputs. It does this by mocking the HTTP client and then attempting to search as normal.
Considerations for queries ¶
Some search engines don't have stable output and as a result your engine might need to work with several different types of responses; Google is such an engine where sometimes a result is slightly different from the rest and a complete extraction of all data for a result might not happen. While the Google engine is usually capable of finding the title and link, it can have trouble with the description.
As such, try to construct enough test cases to maximize your coverage.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶ added in v0.2.1
type Config struct { // When set, engtest will ignore empty descriptions in search results. IgnoreEmptyDescription bool }
Special configuration options for engtest.
type TestData ¶
type TestData struct { Req request Res response }
Request/response pair for testdata.
type Tester ¶
type Tester struct { Config // contains filtered or unexported fields }
Tester is the contextual struct for testing engines.
func New ¶
New creates a new Tester from an engine name and a base config.
The contents of the configuration struct is not important, however engtest will always set a name based on the test case that is being run and will flip Debug to true.
If a driver is not supported, New panics.
func (*Tester) RunTest ¶
RunTest runs a test for an engine on a specific query.
engtest will initialize the engine, load the test file, and then will perform a query while mocking the other end of the connection.
If -update was passed to go test, then the search queries will actually be performed and their results will be saved to disk.
Directories
¶
Path | Synopsis |
---|---|
git.sr.ht/~cmcevoy/srchd/internal/engtest/tool is a very rudimentary tool to extract requests and responses to search engines from their test files.
|
git.sr.ht/~cmcevoy/srchd/internal/engtest/tool is a very rudimentary tool to extract requests and responses to search engines from their test files. |