Add test for delete
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Torjus Håkestad 2022-01-15 21:31:32 +01:00
parent af126dc59f
commit de279c6fe3
3 changed files with 14 additions and 1 deletions

View File

@ -65,7 +65,7 @@ func (s *MemoryFileStore) Get(id string) (*File, error) {
func (s *MemoryFileStore) Delete(id string) error {
s.lock.Lock()
defer s.lock.RUnlock()
defer s.lock.Unlock()
delete(s.data, id)
return nil
}

View File

@ -59,5 +59,18 @@ func RunFilestoreTest(s gpaste.FileStore, t *testing.T) {
if 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))
}
})
}