Snapshot dropping.

This commit is contained in:
Andrey Smirnov
2014-01-29 17:13:42 +04:00
parent 1803252f33
commit e49afbcd2d
2 changed files with 47 additions and 0 deletions
+21
View File
@@ -170,3 +170,24 @@ func (s *SnapshotCollectionSuite) TestFindByRemoteRepoSource(c *C) {
c.Check(s.collection.ByRemoteRepoSource(repo3), DeepEquals, []*Snapshot{})
}
func (s *SnapshotCollectionSuite) TestDrop(c *C) {
s.collection.Add(s.snapshot1)
s.collection.Add(s.snapshot2)
snap, _ := s.collection.ByUUID(s.snapshot1.UUID)
c.Check(snap, Equals, s.snapshot1)
err := s.collection.Drop(s.snapshot1)
c.Check(err, IsNil)
_, err = s.collection.ByUUID(s.snapshot1.UUID)
c.Check(err, ErrorMatches, "snapshot .* not found")
collection := NewSnapshotCollection(s.db)
_, err = collection.ByUUID(s.snapshot1.UUID)
c.Check(err, ErrorMatches, "snapshot .* not found")
c.Check(func() { s.collection.Drop(s.snapshot1) }, Panics, "snapshot not found!")
}