Makes db thread-safe
It was needed for simplicity and various optimization
This commit is contained in:
@@ -17,7 +17,9 @@ var _ = Suite(&AlbumDatabaseSuite{})
|
||||
func (s *AlbumDatabaseSuite) SetUpSuite(c *C) {
|
||||
s.db = OpenAlbumDatabase(filepath.Join(c.MkDir(), "satdb.bar.satellite/db"))
|
||||
for _, a := range albumsDataTest {
|
||||
c.Assert(s.db.AddOrUpdate(&a), IsNil)
|
||||
//we need to copy the value to avoid aliasing
|
||||
aCopied := a
|
||||
c.Assert(s.db.AddOrUpdate(&aCopied), IsNil)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +33,6 @@ func (s *AlbumDatabaseSuite) TestCanDelete(c *C) {
|
||||
}
|
||||
|
||||
func (s *AlbumDatabaseSuite) TestCanGet(c *C) {
|
||||
|
||||
for _, a := range albumsDataTest {
|
||||
fromDb, err := s.db.Get(a.ID)
|
||||
if c.Check(err, IsNil) == true {
|
||||
@@ -41,7 +42,6 @@ func (s *AlbumDatabaseSuite) TestCanGet(c *C) {
|
||||
}
|
||||
|
||||
func (s *AlbumDatabaseSuite) TestCanSort(c *C) {
|
||||
// here
|
||||
start := time.Now()
|
||||
data := []AlbumID{160366, 58595, 15875, 9935, 84448, 46005, 19762, 164, 52100, 8179, 44989, 32043, 22737, 754}
|
||||
sorted, err := s.db.ByPurchaseDate()
|
||||
|
||||
Reference in New Issue
Block a user