mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Add go fmt
This commit is contained in:
committed by
Reed Allman
parent
9a7141967c
commit
81e39b210d
@@ -14,15 +14,13 @@ import (
|
||||
"gitlab-odx.oracle.com/odx/functions/api/models"
|
||||
)
|
||||
|
||||
|
||||
type BoltLogDatastore struct {
|
||||
callLogsBucket []byte
|
||||
db *bolt.DB
|
||||
log logrus.FieldLogger
|
||||
datastore models.Datastore
|
||||
db *bolt.DB
|
||||
log logrus.FieldLogger
|
||||
datastore models.Datastore
|
||||
}
|
||||
|
||||
|
||||
func NewBolt(url *url.URL) (models.FnLog, error) {
|
||||
dir := filepath.Dir(url.Path)
|
||||
log := logrus.WithFields(logrus.Fields{"logdb": url.Scheme, "dir": dir})
|
||||
@@ -60,8 +58,8 @@ func NewBolt(url *url.URL) (models.FnLog, error) {
|
||||
|
||||
fnl := &BoltLogDatastore{
|
||||
callLogsBucket: callLogsBucketName,
|
||||
db: db,
|
||||
log: log,
|
||||
db: db,
|
||||
log: log,
|
||||
}
|
||||
log.WithFields(logrus.Fields{"prefix": bucketPrefix, "file": url.Path}).Debug("BoltDB initialized")
|
||||
|
||||
@@ -71,7 +69,7 @@ func NewBolt(url *url.URL) (models.FnLog, error) {
|
||||
func (fnl *BoltLogDatastore) InsertLog(ctx context.Context, callID string, callLog string) error {
|
||||
log := &models.FnCallLog{
|
||||
CallID: callID,
|
||||
Log: callLog,
|
||||
Log: callLog,
|
||||
}
|
||||
id := []byte(callID)
|
||||
err := fnl.db.Update(
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
const tmpLogDb = "/tmp/func_test_log.db"
|
||||
const tmpDatastore = "/tmp/func_test_datastore.db"
|
||||
|
||||
|
||||
func TestDatastore(t *testing.T) {
|
||||
os.Remove(tmpLogDb)
|
||||
os.Remove(tmpDatastore)
|
||||
|
||||
@@ -2,9 +2,9 @@ package logs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"github.com/Sirupsen/logrus"
|
||||
"gitlab-odx.oracle.com/odx/functions/api/models"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
func New(dbURL string) (models.FnLog, error) {
|
||||
|
||||
@@ -2,13 +2,13 @@ package logs
|
||||
|
||||
import (
|
||||
"context"
|
||||
"gitlab-odx.oracle.com/odx/functions/api/models"
|
||||
"github.com/pkg/errors"
|
||||
"gitlab-odx.oracle.com/odx/functions/api/models"
|
||||
)
|
||||
|
||||
type mock struct {
|
||||
Logs map[string]*models.FnCallLog
|
||||
ds models.Datastore
|
||||
ds models.Datastore
|
||||
}
|
||||
|
||||
func NewMock() models.FnLog {
|
||||
@@ -28,7 +28,7 @@ func (m *mock) SetDatastore(ctx context.Context, ds models.Datastore) {
|
||||
}
|
||||
|
||||
func (m *mock) InsertLog(ctx context.Context, callID string, callLog string) error {
|
||||
m.Logs[callID] = &models.FnCallLog{CallID: callID, Log:callLog}
|
||||
m.Logs[callID] = &models.FnCallLog{CallID: callID, Log: callLog}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
package testing
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
"context"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"gitlab-odx.oracle.com/odx/functions/api/models"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"gitlab-odx.oracle.com/odx/functions/api/id"
|
||||
"gitlab-odx.oracle.com/odx/functions/api/models"
|
||||
)
|
||||
|
||||
|
||||
var testApp = &models.App{
|
||||
Name: "Test",
|
||||
}
|
||||
@@ -63,7 +62,7 @@ func Test(t *testing.T, fnl models.FnLog, ds models.Datastore) {
|
||||
}
|
||||
logEntry, err := fnl.GetLog(ctx, task.ID)
|
||||
if !strings.Contains(logEntry.Log, logText) {
|
||||
t.Fatalf("Test GetLog(ctx, task.ID, logText): unexpected error, log mismatch. " +
|
||||
t.Fatalf("Test GetLog(ctx, task.ID, logText): unexpected error, log mismatch. "+
|
||||
"Expected: `%v`. Got `%v`.", logText, logEntry.Log)
|
||||
}
|
||||
})
|
||||
@@ -80,7 +79,7 @@ func Test(t *testing.T, fnl models.FnLog, ds models.Datastore) {
|
||||
}
|
||||
logEntry, err := fnl.GetLog(ctx, task.ID)
|
||||
if !strings.Contains(logEntry.Log, logText) {
|
||||
t.Fatalf("Test GetLog(ctx, task.ID, logText): unexpected error, log mismatch. " +
|
||||
t.Fatalf("Test GetLog(ctx, task.ID, logText): unexpected error, log mismatch. "+
|
||||
"Expected: `%v`. Got `%v`.", logText, logEntry.Log)
|
||||
}
|
||||
err = fnl.DeleteLog(ctx, task.ID)
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
)
|
||||
|
||||
type FnLog interface {
|
||||
|
||||
InsertLog(ctx context.Context, callID string, callLog string) error
|
||||
GetLog(ctx context.Context, callID string) (*models.FnCallLog, error)
|
||||
DeleteLog(ctx context.Context, callID string) error
|
||||
@@ -21,7 +20,6 @@ func NewValidator(fnl FnLog) models.FnLog {
|
||||
return &validator{fnl}
|
||||
}
|
||||
|
||||
|
||||
func (v *validator) InsertLog(ctx context.Context, callID string, callLog string) error {
|
||||
return v.fnl.InsertLog(ctx, callID, callLog)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user