From 17a3faf2df1fa71eb36d799147d3aa729bcf6e1f Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Sun, 4 Nov 2012 12:18:11 +0100 Subject: [PATCH] index: export NewMemoryIndex Change-Id: Iaa6d3268ce0f6c531e37c97799deeb31c11eabdb --- pkg/index/export_test.go | 4 ---- pkg/index/index_test.go | 6 +++--- pkg/index/memindex.go | 5 +++-- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/pkg/index/export_test.go b/pkg/index/export_test.go index 6f1a719ef..90f754802 100644 --- a/pkg/index/export_test.go +++ b/pkg/index/export_test.go @@ -23,7 +23,3 @@ func ExpReverseTimeString(s string) string { func ExpUnreverseTimeString(s string) string { return unreverseTimeString(s) } - -func ExpNewMemoryIndex() *Index { - return newMemoryIndex() -} diff --git a/pkg/index/index_test.go b/pkg/index/index_test.go index f782aff76..2f7e6d078 100644 --- a/pkg/index/index_test.go +++ b/pkg/index/index_test.go @@ -44,15 +44,15 @@ func TestReverseTimeString(t *testing.T) { } func TestIndex_Memory(t *testing.T) { - indextest.Index(t, index.ExpNewMemoryIndex) + indextest.Index(t, index.NewMemoryIndex) } func TestPathsOfSignerTarget_Memory(t *testing.T) { - indextest.PathsOfSignerTarget(t, index.ExpNewMemoryIndex) + indextest.PathsOfSignerTarget(t, index.NewMemoryIndex) } func TestFiles_Memory(t *testing.T) { - indextest.Files(t, index.ExpNewMemoryIndex) + indextest.Files(t, index.NewMemoryIndex) } var ( diff --git a/pkg/index/memindex.go b/pkg/index/memindex.go index ab7c5ecc2..e0d2ba991 100644 --- a/pkg/index/memindex.go +++ b/pkg/index/memindex.go @@ -32,7 +32,8 @@ func init() { blobserver.StorageConstructor(newMemoryIndexFromConfig)) } -func newMemoryIndex() *Index { +// NewMemoryIndex returns an Index backed only by memory, for use in tests. +func NewMemoryIndex() *Index { db := memdb.New(nil) memStorage := &memKeys{db: db} return New(memStorage) @@ -48,7 +49,7 @@ func newMemoryIndexFromConfig(ld blobserver.Loader, config jsonconfig.Obj) (blob return nil, err } - ix := newMemoryIndex() + ix := NewMemoryIndex() ix.BlobSource = sto // Good enough, for now: