45 lines
916 B
Go
45 lines
916 B
Go
package blob
|
|
|
|
import (
|
|
"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()
|
|
|
|
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),
|
|
)
|
|
|
|
data, err := os.ReadFile("testdata/blob.js")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
if err := server.Load("testdata/blob.js", string(data)); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
defer server.Stop()
|
|
|
|
if err := server.Start(); err != nil {
|
|
t.Fatalf("%+v", errors.WithStack(err))
|
|
}
|
|
}
|