Add test for delete
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
af126dc59f
commit
de279c6fe3
@ -65,7 +65,7 @@ func (s *MemoryFileStore) Get(id string) (*File, error) {
|
|||||||
|
|
||||||
func (s *MemoryFileStore) Delete(id string) error {
|
func (s *MemoryFileStore) Delete(id string) error {
|
||||||
s.lock.Lock()
|
s.lock.Lock()
|
||||||
defer s.lock.RUnlock()
|
defer s.lock.Unlock()
|
||||||
delete(s.data, id)
|
delete(s.data, id)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -59,5 +59,18 @@ func RunFilestoreTest(s gpaste.FileStore, t *testing.T) {
|
|||||||
if ids[0] != id {
|
if ids[0] != id {
|
||||||
t.Fatalf("ID is wrong. Got %s want %s", ids[0], id)
|
t.Fatalf("ID is wrong. Got %s want %s", ids[0], id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete
|
||||||
|
if err := s.Delete(id); err != nil {
|
||||||
|
t.Fatalf("Error deleting file: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
ids, err = s.List()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Error listing after delete: %s", err)
|
||||||
|
}
|
||||||
|
if len(ids) != 0 {
|
||||||
|
t.Fatalf("List after delete has wrong length: %d", len(ids))
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user