In the next few pages, we will be constructing two completely different Indexer implementations. In a similar fashion to the link graph component, we will again devise a shared test suite that will help us verify that both implementations behave in exactly the same way.
The SuiteBase definition for our shared indexer tests can be found in the Chapter06/textindexer/index/indextest package and depends on the gocheck [11] framework that we introduced in Chapter 4, The Art of Testing. The suite defines tests for the following groups of index operations:
- Document indexing tests: These tests are designed to verify that the indexer component successfully processes valid documents and rejects any document that does not define the required set of document attributes (for example, it includes an empty link ID).
- Document lookup tests: These tests validate that we can look up a previously indexed document via its link ID and that the returned document model is identical to the document that was passed and indexed.
- Keyword search tests: A series of tests designed to verify that keyword searches yield the correct set of documents.
- Exact phrase search tests: Yet another series of tests that verifies that exact phrase searches yield the correct set of documents.
- PageRank score update tests: These tests exercise the PageRank score update code path and verify that changes to the score values for indexed documents are reflected in the order of returned search results.
To create a test suite for an actual indexer implementation, all we have to do is the following:
- Define a new test suite that embeds SuiteBase
- Provide a suite setup helper that creates the appropriate indexer instance and then invokes the SetIndexer method exposed by SuiteBase to wire the indexer to the base test suite