reflector.go/store/memory_test.go
Alex Grintsvayg 4535122a06 starting to put together the pieces
- prism start command
- more configs for prism when assembling the pieces
- cluster notifies on membership change, determines hash range, announces hashes
2018-06-14 22:30:38 -04:00

47 lines
964 B
Go

package store
import (
"bytes"
"testing"
"github.com/lbryio/lbry.go/errors"
)
func TestMemoryBlobStore_Put(t *testing.T) {
s := MemoryBlobStore{}
blob := []byte("abcdefg")
err := s.Put("abc", blob)
if err != nil {
t.Errorf("Expected no error, got %v", err)
}
}
func TestMemoryBlobStore_Get(t *testing.T) {
s := MemoryBlobStore{}
hash := "abc"
blob := []byte("abcdefg")
err := s.Put(hash, blob)
if err != nil {
t.Error("error getting memory blob - ", err)
}
gotBlob, err := s.Get(hash)
if err != nil {
t.Errorf("Expected no error, got %v", err)
}
if !bytes.Equal(gotBlob, blob) {
t.Error("Got blob that is different from expected blob")
}
missingBlob, err := s.Get("nonexistent hash")
if err == nil {
t.Errorf("Expected ErrBlobNotFound, got nil")
}
if !errors.Is(err, ErrBlobNotFound) {
t.Errorf("Received unexpected error: %v", err)
}
if !bytes.Equal(missingBlob, []byte{}) {
t.Error("Got blob that is not empty")
}
}