mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[experiment] add alternative wasm sqlite3 implementation available via build-tag (#2863)
This allows for building GoToSocial with [SQLite transpiled to WASM](https://github.com/ncruces/go-sqlite3) and accessed through [Wazero](https://wazero.io/).
This commit is contained in:
@@ -19,10 +19,7 @@ package testrig
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/db/bundb"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||
@@ -84,22 +81,6 @@ var testModels = []interface{}{
|
||||
// If the environment variable GTS_DB_PORT is set, it will take that
|
||||
// value as the port instead.
|
||||
func NewTestDB(state *state.State) db.DB {
|
||||
if alternateAddress := os.Getenv("GTS_DB_ADDRESS"); alternateAddress != "" {
|
||||
config.SetDbAddress(alternateAddress)
|
||||
}
|
||||
|
||||
if alternateDBType := os.Getenv("GTS_DB_TYPE"); alternateDBType != "" {
|
||||
config.SetDbType(alternateDBType)
|
||||
}
|
||||
|
||||
if alternateDBPort := os.Getenv("GTS_DB_PORT"); alternateDBPort != "" {
|
||||
port, err := strconv.ParseUint(alternateDBPort, 10, 16)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
config.SetDbPort(int(port))
|
||||
}
|
||||
|
||||
state.Caches.Init()
|
||||
|
||||
testDB, err := bundb.NewBunDBService(context.Background(), state)
|
||||
@@ -374,9 +355,10 @@ func StandardDBTeardown(db db.DB) {
|
||||
if db == nil {
|
||||
return
|
||||
}
|
||||
defer db.Close()
|
||||
for _, m := range testModels {
|
||||
if err := db.DropTable(ctx, m); err != nil {
|
||||
log.Panic(nil, err)
|
||||
log.Error(ctx, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user