You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2015/09/12 00:00:28 UTC
[03/16] lucy git commit: Add test utility functions.
Add test utility functions.
Add Go versions of `createIndex`, `createSchema`.
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/71a17b05
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/71a17b05
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/71a17b05
Branch: refs/heads/master
Commit: 71a17b05c10302769f335ff18103d875ac2fb255
Parents: 3d4a0b6
Author: Marvin Humphrey <ma...@rectangular.com>
Authored: Tue Aug 11 19:38:59 2015 -0700
Committer: Marvin Humphrey <ma...@rectangular.com>
Committed: Wed Sep 9 17:32:23 2015 -0700
----------------------------------------------------------------------
go/lucy/lucy_test.go | 43 +++++++++++++++++++++++++++++++++++++++++--
1 file changed, 41 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy/blob/71a17b05/go/lucy/lucy_test.go
----------------------------------------------------------------------
diff --git a/go/lucy/lucy_test.go b/go/lucy/lucy_test.go
index 82ba878..c0c743e 100644
--- a/go/lucy/lucy_test.go
+++ b/go/lucy/lucy_test.go
@@ -20,8 +20,47 @@ import "git-wip-us.apache.org/repos/asf/lucy-clownfish.git/runtime/go/clownfish"
import "testing"
import "reflect"
-func TestStuff(t *testing.T) {
- NewSchema()
+type testDoc struct {
+ Content string
+}
+
+// Build a RAM index, using the supplied array of strings as source material.
+// The index will have a single field: "content".
+func createTestIndex(values ...string) Folder {
+ folder := NewRAMFolder("")
+ schema := createTestSchema()
+ indexerArgs := &OpenIndexerArgs{
+ Schema: schema,
+ Index: folder,
+ Create: true,
+ }
+ indexer, err := OpenIndexer(indexerArgs)
+ if err != nil {
+ panic(err)
+ }
+ defer indexer.Close()
+
+ for _, val := range values {
+ err := indexer.AddDoc(&testDoc{val})
+ if err != nil {
+ panic(err)
+ }
+ }
+ err = indexer.Commit()
+ if err != nil {
+ panic(err)
+ }
+
+ return folder
+}
+
+func createTestSchema() Schema {
+ schema := NewSchema()
+ analyzer := NewStandardTokenizer()
+ fieldType := NewFullTextType(analyzer)
+ fieldType.SetHighlightable(true)
+ schema.SpecField("content", fieldType)
+ return schema
}
func TestOpenIndexer(t *testing.T) {