aboutsummaryrefslogtreecommitdiffstats
path: root/storage/memory
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-08-14 18:21:10 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2016-08-14 18:21:10 +0200
commitf6fe29c80d11662a169806dcf413ecdedcb28fa3 (patch)
tree9958034c27521f720f8c5d83c12120ada196f48a /storage/memory
parent91bf16b2336e6f80f0742be729582fe5fbbada83 (diff)
downloadgo-git-f6fe29c80d11662a169806dcf413ecdedcb28fa3.tar.gz
core: Storage, removing err returning *Storages
Diffstat (limited to 'storage/memory')
-rw-r--r--storage/memory/storage.go12
-rw-r--r--storage/memory/storage_test.go28
2 files changed, 16 insertions, 24 deletions
diff --git a/storage/memory/storage.go b/storage/memory/storage.go
index 9c97523..32c2973 100644
--- a/storage/memory/storage.go
+++ b/storage/memory/storage.go
@@ -20,9 +20,9 @@ func NewStorage() *Storage {
}
// ObjectStorage returns the ObjectStorage if not exists creates a new one
-func (s *Storage) ObjectStorage() (core.ObjectStorage, error) {
+func (s *Storage) ObjectStorage() core.ObjectStorage {
if s.o != nil {
- return s.o, nil
+ return s.o
}
s.o = &ObjectStorage{
@@ -33,19 +33,19 @@ func (s *Storage) ObjectStorage() (core.ObjectStorage, error) {
Tags: make(map[core.Hash]core.Object, 0),
}
- return s.o, nil
+ return s.o
}
// ReferenceStorage returns the ReferenceStorage if not exists creates a new one
-func (s *Storage) ReferenceStorage() (core.ReferenceStorage, error) {
+func (s *Storage) ReferenceStorage() core.ReferenceStorage {
if s.r != nil {
- return s.r, nil
+ return s.r
}
r := make(ReferenceStorage, 0)
s.r = &r
- return s.r, nil
+ return s.r
}
// ObjectStorage is the implementation of core.ObjectStorage for memory.Object
diff --git a/storage/memory/storage_test.go b/storage/memory/storage_test.go
index 8e9a524..ac97584 100644
--- a/storage/memory/storage_test.go
+++ b/storage/memory/storage_test.go
@@ -16,28 +16,23 @@ var _ = Suite(&StorageSuite{})
func (s *StorageSuite) TestStorageObjectStorage(c *C) {
storage := NewStorage()
- o, err := storage.ObjectStorage()
- c.Assert(err, IsNil)
- e, err := storage.ObjectStorage()
- c.Assert(err, IsNil)
+ o := storage.ObjectStorage()
+ e := storage.ObjectStorage()
c.Assert(o == e, Equals, true)
}
func (s *StorageSuite) TestStorageReferenceStorage(c *C) {
storage := NewStorage()
- o, err := storage.ReferenceStorage()
- c.Assert(err, IsNil)
- e, err := storage.ReferenceStorage()
- c.Assert(err, IsNil)
+ o := storage.ReferenceStorage()
+ e := storage.ReferenceStorage()
c.Assert(o == e, Equals, true)
}
func (s *StorageSuite) TestObjectStorageSetAndGet(c *C) {
storage := NewStorage()
- os, err := storage.ObjectStorage()
- c.Assert(err, IsNil)
+ os := storage.ObjectStorage()
commit := &core.MemoryObject{}
commit.SetType(core.CommitObject)
@@ -91,8 +86,7 @@ func (s *StorageSuite) TestObjectStorageIter(c *C) {
tag.SetType(core.TagObject)
storage := NewStorage()
- os, err := storage.ObjectStorage()
- c.Assert(err, IsNil)
+ os := storage.ObjectStorage()
os.Set(commit)
os.Set(tree)
@@ -134,10 +128,9 @@ func (s *StorageSuite) TestObjectStorageIter(c *C) {
func (s *StorageSuite) TestReferenceStorageSetAndGet(c *C) {
storage := NewStorage()
- rs, err := storage.ReferenceStorage()
- c.Assert(err, IsNil)
+ rs := storage.ReferenceStorage()
- err = rs.Set(core.NewReferenceFromStrings("foo", "bc9968d75e48de59f0870ffb71f5e160bbbdcf52"))
+ err := rs.Set(core.NewReferenceFromStrings("foo", "bc9968d75e48de59f0870ffb71f5e160bbbdcf52"))
c.Assert(err, IsNil)
err = rs.Set(core.NewReferenceFromStrings("bar", "482e0eada5de4039e6f216b45b3c9b683b83bfa"))
@@ -150,10 +143,9 @@ func (s *StorageSuite) TestReferenceStorageSetAndGet(c *C) {
func (s *StorageSuite) TestReferenceStorageIter(c *C) {
storage := NewStorage()
- rs, err := storage.ReferenceStorage()
- c.Assert(err, IsNil)
+ rs := storage.ReferenceStorage()
- err = rs.Set(core.NewReferenceFromStrings("foo", "bc9968d75e48de59f0870ffb71f5e160bbbdcf52"))
+ err := rs.Set(core.NewReferenceFromStrings("foo", "bc9968d75e48de59f0870ffb71f5e160bbbdcf52"))
c.Assert(err, IsNil)
i, err := rs.Iter()