mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-13 23:47:31 -06:00
more work on test rig
This commit is contained in:
parent
9a57dac5a1
commit
7ab9e78b44
18 changed files with 514 additions and 47 deletions
|
|
@ -15,22 +15,41 @@ import (
|
|||
func NewInMem(c *config.Config, log *logrus.Logger) (Storage, error) {
|
||||
return &inMemStorage{
|
||||
stored: make(map[string][]byte),
|
||||
log: log,
|
||||
}, nil
|
||||
}
|
||||
|
||||
type inMemStorage struct {
|
||||
stored map[string][]byte
|
||||
log *logrus.Logger
|
||||
}
|
||||
|
||||
func (s *inMemStorage) StoreFileAt(path string, data []byte) error {
|
||||
l := s.log.WithField("func", "StoreFileAt")
|
||||
l.Debugf("storing at path %s", path)
|
||||
s.stored[path] = data
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *inMemStorage) RetrieveFileFrom(path string) ([]byte, error) {
|
||||
l := s.log.WithField("func", "RetrieveFileFrom")
|
||||
l.Debugf("retrieving from path %s", path)
|
||||
d, ok := s.stored[path]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("no data found at path %s", path)
|
||||
}
|
||||
return d, nil
|
||||
}
|
||||
|
||||
func (s *inMemStorage)ListKeys() ([]string, error) {
|
||||
keys := []string{}
|
||||
for k := range s.stored {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
return keys, nil
|
||||
}
|
||||
|
||||
func (s *inMemStorage) RemoveFileAt(path string) error {
|
||||
delete(s.stored, path)
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue