fn: clean api tests: removed multi log (#801)

fn-test-utils covers this, with sleep in between.
This commit is contained in:
Tolga Ceylan
2018-02-27 21:03:03 -08:00
committed by GitHub
parent b1827b5bfb
commit 820baf36dc
7 changed files with 114 additions and 153 deletions

View File

@@ -1,30 +1,32 @@
package logs
import (
"bytes"
"context"
"io"
"io/ioutil"
"github.com/fnproject/fn/api/models"
)
type mock struct {
Logs map[string]io.Reader
Logs map[string][]byte
}
func NewMock() models.LogStore {
return &mock{make(map[string]io.Reader)}
return &mock{make(map[string][]byte)}
}
func (m *mock) InsertLog(ctx context.Context, appName, callID string, callLog io.Reader) error {
m.Logs[callID] = callLog
return nil
bytes, err := ioutil.ReadAll(callLog)
m.Logs[callID] = bytes
return err
}
func (m *mock) GetLog(ctx context.Context, appName, callID string) (io.Reader, error) {
logEntry := m.Logs[callID]
if logEntry == nil {
logEntry, ok := m.Logs[callID]
if !ok {
return nil, models.ErrCallLogNotFound
}
return logEntry, nil
return bytes.NewReader(logEntry), nil
}