47 lines
938 B
Go
47 lines
938 B
Go
package blob
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"testing"
|
|
|
|
"cdr.dev/slog"
|
|
"forge.cadoles.com/arcad/edge/pkg/app"
|
|
"forge.cadoles.com/arcad/edge/pkg/bus/memory"
|
|
"forge.cadoles.com/arcad/edge/pkg/module"
|
|
"forge.cadoles.com/arcad/edge/pkg/storage/driver/sqlite"
|
|
"github.com/pkg/errors"
|
|
"gitlab.com/wpetit/goweb/logger"
|
|
)
|
|
|
|
func TestBlobModule(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
if testing.Verbose() {
|
|
logger.SetLevel(slog.LevelDebug)
|
|
}
|
|
|
|
bus := memory.NewBus()
|
|
store := sqlite.NewBlobStore(":memory:?_pragma=foreign_keys(1)&_pragma=busy_timeout=60000")
|
|
|
|
server := app.NewServer(
|
|
module.ContextModuleFactory(),
|
|
module.ConsoleModuleFactory(),
|
|
ModuleFactory(bus, store),
|
|
)
|
|
|
|
script := "testdata/blob.js"
|
|
|
|
data, err := os.ReadFile(script)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
ctx := context.Background()
|
|
if err := server.Start(ctx, script, string(data)); err != nil {
|
|
t.Fatalf("%+v", errors.WithStack(err))
|
|
}
|
|
|
|
defer server.Stop()
|
|
}
|