Exemplo n.º 1
0
// TestRegistration tests the registration of matchers is functioning.
func TestRegistration(t *testing.T) {
	matcher := search.FindMatcher("test")

	t.Log("The test Matcher should be returned.")
	if _, ok := matcher.(testMatcher); !ok {
		t.Fatalf("ERROR : Invalid Matcher : %T", matcher)
	}
}
Exemplo n.º 2
0
// TestSearch tests the search mechanism for using a Matcher
// with the channel response.
func TestSearch(t *testing.T) {
	matcher := search.FindMatcher("test")
	results := make(chan *search.Result, 1)
	var feed search.Feed
	var searchTerm string

	search.Match(matcher, &feed, searchTerm, results)
	result := <-results

	t.Log("The search should return the test results.")
	if result.Field != "Test Field" {
		t.Errorf("ERROR : Expecting[Test Field] Received[%s]", result.Field)
	}

	if result.Content != "Test Content" {
		t.Errorf("ERROR : Expecting[Test Content] Received[%s]", result.Content)
	}
}