index: export NewMemoryIndex

Change-Id: Iaa6d3268ce0f6c531e37c97799deeb31c11eabdb
This commit is contained in:
Brad Fitzpatrick 2012-11-04 12:18:11 +01:00
parent 0ccf9ba3f1
commit 17a3faf2df
3 changed files with 6 additions and 9 deletions

View File

@ -23,7 +23,3 @@ func ExpReverseTimeString(s string) string {
func ExpUnreverseTimeString(s string) string {
return unreverseTimeString(s)
}
func ExpNewMemoryIndex() *Index {
return newMemoryIndex()
}

View File

@ -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 (

View File

@ -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: