mirror of
https://github.com/dolthub/dolt.git
synced 2026-01-24 03:09:22 -06:00
48 lines
905 B
Go
48 lines
905 B
Go
package chunks
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"github.com/attic-labs/noms/Godeps/_workspace/src/github.com/stretchr/testify/assert"
|
|
"github.com/attic-labs/noms/ref"
|
|
)
|
|
|
|
func assertInputInStore(input string, ref ref.Ref, s ChunkStore, assert *assert.Assertions) {
|
|
chunk := s.Get(ref)
|
|
assert.False(chunk.IsEmpty())
|
|
assert.Equal(input, string(chunk.Data()))
|
|
}
|
|
|
|
func assertInputNotInStore(input string, ref ref.Ref, s ChunkStore, assert *assert.Assertions) {
|
|
data := s.Get(ref)
|
|
assert.Nil(data)
|
|
}
|
|
|
|
type TestStore struct {
|
|
MemoryStore
|
|
Reads int
|
|
Writes int
|
|
}
|
|
|
|
func NewTestStore() *TestStore {
|
|
return &TestStore{
|
|
MemoryStore: MemoryStore{
|
|
mu: &sync.Mutex{},
|
|
},
|
|
}
|
|
}
|
|
|
|
func (s *TestStore) Get(ref ref.Ref) Chunk {
|
|
s.Reads++
|
|
return s.MemoryStore.Get(ref)
|
|
}
|
|
|
|
func (s *TestStore) Has(ref ref.Ref) bool {
|
|
return s.MemoryStore.Has(ref)
|
|
}
|
|
|
|
func (s *TestStore) Put(c Chunk) {
|
|
s.Writes++
|
|
s.MemoryStore.Put(c)
|
|
}
|