Don't use transactions when direct db access is enough

For read-only action transactions are not necessary and they risk to deadlock
if multiple go-routines try to read the database.
This commit is contained in:
Lorenzo Bolla
2021-08-24 11:15:39 +02:00
parent fd83c1a5bf
commit 2fa3adee1d
4 changed files with 17 additions and 18 deletions
+10
View File
@@ -201,3 +201,13 @@ func (s *LocalRepoCollectionSuite) TestDrop(c *C) {
c.Check(s.collection.Drop(repo1), ErrorMatches, "local repo not found")
}
func (s *LocalRepoCollectionSuite) TestDropNonExisting(c *C) {
repo := NewLocalRepo("local3", "Comment 3")
_, err := s.collection.ByUUID(repo.UUID)
c.Check(err, ErrorMatches, "local repo .* not found")
err = s.collection.Drop(repo)
c.Check(s.collection.Drop(repo), ErrorMatches, "local repo not found")
}