mirror of
https://github.com/netbirdio/netbird.git
synced 2026-09-29 18:19:07 +02:00
* extract shared db conn + data repository * extract repository interface * protect against nested transactions * fix mysql and db conn creation * fix context management * remove query warpper * remove withContext and withLock wrapper * remove context from function call * remove in memory mode * fix nested transaction handling * use db directly * remove leftover test * remove pool close on error during conn creation
32 lines
654 B
Go
32 lines
654 B
Go
package dbtest
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/netbirdio/netbird/management/internals/shared/db"
|
|
)
|
|
|
|
func TestNewConn_IgnoresSqliteFileOverride(t *testing.T) {
|
|
override := filepath.Join(t.TempDir(), "configured.db")
|
|
t.Setenv("NB_STORE_ENGINE_SQLITE_FILE", override)
|
|
|
|
conn := NewConn(t)
|
|
|
|
assert.Equal(t, db.SqliteStoreEngine, conn.Engine())
|
|
_, err := os.Stat(override)
|
|
require.ErrorIs(t, err, os.ErrNotExist)
|
|
}
|
|
|
|
func TestNewConn_Parallel(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
conn := NewConn(t)
|
|
|
|
assert.Equal(t, db.SqliteStoreEngine, conn.Engine())
|
|
}
|