mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
@@ -27,12 +27,12 @@ func (m *mock) SetDatastore(ctx context.Context, ds models.Datastore) {
|
||||
m.ds = ds
|
||||
}
|
||||
|
||||
func (m *mock) InsertLog(ctx context.Context, callID string, callLog string) error {
|
||||
func (m *mock) InsertLog(ctx context.Context, appName, callID, callLog string) error {
|
||||
m.Logs[callID] = &models.CallLog{CallID: callID, Log: callLog}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mock) GetLog(ctx context.Context, callID string) (*models.CallLog, error) {
|
||||
func (m *mock) GetLog(ctx context.Context, appName, callID string) (*models.CallLog, error) {
|
||||
logEntry := m.Logs[callID]
|
||||
if logEntry == nil {
|
||||
return nil, errors.New("Call log not found")
|
||||
@@ -41,7 +41,7 @@ func (m *mock) GetLog(ctx context.Context, callID string) (*models.CallLog, erro
|
||||
return m.Logs[callID], nil
|
||||
}
|
||||
|
||||
func (m *mock) DeleteLog(ctx context.Context, callID string) error {
|
||||
func (m *mock) DeleteLog(ctx context.Context, appName, callID string) error {
|
||||
delete(m.Logs, callID)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ func Test(t *testing.T, fnl models.LogStore, ds models.Datastore) {
|
||||
if err != nil {
|
||||
t.Fatalf("Test InsertCall(ctx, &call): unexpected error `%v`", err)
|
||||
}
|
||||
err = fnl.InsertLog(ctx, call.ID, "test")
|
||||
err = fnl.InsertLog(ctx, call.AppName, call.ID, "test")
|
||||
if err != nil {
|
||||
t.Fatalf("Test InsertLog(ctx, call.ID, logText): unexpected error during inserting log `%v`", err)
|
||||
}
|
||||
@@ -56,11 +56,11 @@ func Test(t *testing.T, fnl models.LogStore, ds models.Datastore) {
|
||||
if err != nil {
|
||||
t.Fatalf("Test InsertCall(ctx, &call): unexpected error `%v`", err)
|
||||
}
|
||||
err = fnl.InsertLog(ctx, call.ID, logText)
|
||||
err = fnl.InsertLog(ctx, call.AppName, call.ID, logText)
|
||||
if err != nil {
|
||||
t.Fatalf("Test InsertLog(ctx, call.ID, logText): unexpected error during inserting log `%v`", err)
|
||||
}
|
||||
logEntry, err := fnl.GetLog(ctx, call.ID)
|
||||
logEntry, err := fnl.GetLog(ctx, call.AppName, call.ID)
|
||||
if !strings.Contains(logEntry.Log, logText) {
|
||||
t.Fatalf("Test GetLog(ctx, call.ID, logText): unexpected error, log mismatch. "+
|
||||
"Expected: `%v`. Got `%v`.", logText, logEntry.Log)
|
||||
@@ -73,16 +73,16 @@ func Test(t *testing.T, fnl models.LogStore, ds models.Datastore) {
|
||||
if err != nil {
|
||||
t.Fatalf("Test InsertCall(ctx, &call): unexpected error `%v`", err)
|
||||
}
|
||||
err = fnl.InsertLog(ctx, call.ID, logText)
|
||||
err = fnl.InsertLog(ctx, call.AppName, call.ID, logText)
|
||||
if err != nil {
|
||||
t.Fatalf("Test InsertLog(ctx, call.ID, logText): unexpected error during inserting log `%v`", err)
|
||||
}
|
||||
logEntry, err := fnl.GetLog(ctx, call.ID)
|
||||
logEntry, err := fnl.GetLog(ctx, call.AppName, call.ID)
|
||||
if !strings.Contains(logEntry.Log, logText) {
|
||||
t.Fatalf("Test GetLog(ctx, call.ID, logText): unexpected error, log mismatch. "+
|
||||
"Expected: `%v`. Got `%v`.", logText, logEntry.Log)
|
||||
}
|
||||
err = fnl.DeleteLog(ctx, call.ID)
|
||||
err = fnl.DeleteLog(ctx, call.AppName, call.ID)
|
||||
if err != nil {
|
||||
t.Fatalf("Test DeleteLog(ctx, call.ID): unexpected error during deleting log `%v`", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user