alby-hub/db/test/db_test.go
Roland 66a1be6d16
Fix: sqlite connection parameters, add migrations to delete orphaned records and change postgres transaction amount to bigint (#1462)
* fix: sqlite pragma statement not applying to all sqlite connections

* fix: add migration to delete orphaned records

* fix: migrate postgres transaction amount column to bigint

* chore: simplify migration, update comment

* fix: sqlite uri when running tests

* fix: check that breaks tests

* fix: db locking within transaction

* fix: sqlite3 driver wrapper to execute PRAGMAs on each new connection (#1464)

* fix: sqlite3 driver wrapper to execute PRAGMAs on each new connection

* chore: add test to check temp_store value

---------

Co-authored-by: Roland Bewick <roland.bewick@gmail.com>

---------

Co-authored-by: Roman D <roman@dmitrienko.com>
2025-07-06 17:45:46 +07:00

33 lines
677 B
Go

package test
import (
"strconv"
"testing"
"github.com/sirupsen/logrus"
"github.com/getAlby/hub/logger"
"github.com/getAlby/hub/tests/db"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestTempStorePragmaIsApplied(t *testing.T) {
logger.Init(strconv.Itoa(int(logrus.DebugLevel)))
gormDb, err := db.NewDB(t)
require.NoError(t, err)
defer db.CloseDB(gormDb)
if gormDb.Dialector.Name() != "sqlite" {
t.Skip("Skipping non-sqlite dialector")
}
var result string
err = gormDb.Raw("PRAGMA temp_store").Scan(&result).Error
require.NoError(t, err)
// PRAGMA temp_store = MEMORY
// MEMORY = 2
assert.Equal(t, "2", result)
}