|
@@ -5,6 +5,7 @@ import (
|
|
|
"testing"
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/mhsanaei/3x-ui/v3/internal/database"
|
|
"github.com/mhsanaei/3x-ui/v3/internal/database"
|
|
|
|
|
+ "github.com/mhsanaei/3x-ui/v3/internal/database/dbtest"
|
|
|
"github.com/mhsanaei/3x-ui/v3/internal/database/model"
|
|
"github.com/mhsanaei/3x-ui/v3/internal/database/model"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -46,10 +47,7 @@ func TestClientWithInboundFlow_GatesByInboundCapability(t *testing.T) {
|
|
|
func TestFlowIsolation_VisionDoesNotLeakToWsInbound(t *testing.T) {
|
|
func TestFlowIsolation_VisionDoesNotLeakToWsInbound(t *testing.T) {
|
|
|
dbDir := t.TempDir()
|
|
dbDir := t.TempDir()
|
|
|
t.Setenv("XUI_DB_FOLDER", dbDir)
|
|
t.Setenv("XUI_DB_FOLDER", dbDir)
|
|
|
- if err := database.InitDB(filepath.Join(dbDir, "x-ui.db")); err != nil {
|
|
|
|
|
- t.Fatalf("InitDB: %v", err)
|
|
|
|
|
- }
|
|
|
|
|
- t.Cleanup(func() { _ = database.CloseDB() })
|
|
|
|
|
|
|
+ dbtest.InitDB(t, filepath.Join(dbDir, "x-ui.db"))
|
|
|
|
|
|
|
|
db := database.GetDB()
|
|
db := database.GetDB()
|
|
|
|
|
|
|
@@ -95,10 +93,7 @@ func TestFlowIsolation_VisionDoesNotLeakToWsInbound(t *testing.T) {
|
|
|
func TestEffectiveFlow_NonFlowInboundSyncedLastDoesNotHideVision(t *testing.T) {
|
|
func TestEffectiveFlow_NonFlowInboundSyncedLastDoesNotHideVision(t *testing.T) {
|
|
|
dbDir := t.TempDir()
|
|
dbDir := t.TempDir()
|
|
|
t.Setenv("XUI_DB_FOLDER", dbDir)
|
|
t.Setenv("XUI_DB_FOLDER", dbDir)
|
|
|
- if err := database.InitDB(filepath.Join(dbDir, "x-ui.db")); err != nil {
|
|
|
|
|
- t.Fatalf("InitDB: %v", err)
|
|
|
|
|
- }
|
|
|
|
|
- t.Cleanup(func() { _ = database.CloseDB() })
|
|
|
|
|
|
|
+ dbtest.InitDB(t, filepath.Join(dbDir, "x-ui.db"))
|
|
|
|
|
|
|
|
db := database.GetDB()
|
|
db := database.GetDB()
|
|
|
reality := &model.Inbound{Tag: "vless-reality", Enable: true, Port: 40001, Protocol: model.VLESS, StreamSettings: `{"network":"tcp","security":"reality"}`}
|
|
reality := &model.Inbound{Tag: "vless-reality", Enable: true, Port: 40001, Protocol: model.VLESS, StreamSettings: `{"network":"tcp","security":"reality"}`}
|
|
@@ -145,10 +140,7 @@ func TestEffectiveFlow_NonFlowInboundSyncedLastDoesNotHideVision(t *testing.T) {
|
|
|
func TestEffectiveFlow_ClearedFlowStaysCleared(t *testing.T) {
|
|
func TestEffectiveFlow_ClearedFlowStaysCleared(t *testing.T) {
|
|
|
dbDir := t.TempDir()
|
|
dbDir := t.TempDir()
|
|
|
t.Setenv("XUI_DB_FOLDER", dbDir)
|
|
t.Setenv("XUI_DB_FOLDER", dbDir)
|
|
|
- if err := database.InitDB(filepath.Join(dbDir, "x-ui.db")); err != nil {
|
|
|
|
|
- t.Fatalf("InitDB: %v", err)
|
|
|
|
|
- }
|
|
|
|
|
- t.Cleanup(func() { _ = database.CloseDB() })
|
|
|
|
|
|
|
+ dbtest.InitDB(t, filepath.Join(dbDir, "x-ui.db"))
|
|
|
|
|
|
|
|
db := database.GetDB()
|
|
db := database.GetDB()
|
|
|
reality := &model.Inbound{Tag: "vless-reality", Enable: true, Port: 41001, Protocol: model.VLESS, StreamSettings: `{"network":"tcp","security":"reality"}`}
|
|
reality := &model.Inbound{Tag: "vless-reality", Enable: true, Port: 41001, Protocol: model.VLESS, StreamSettings: `{"network":"tcp","security":"reality"}`}
|
|
@@ -191,10 +183,7 @@ func TestEffectiveFlow_ClearedFlowStaysCleared(t *testing.T) {
|
|
|
func TestAttach_PreservesVisionFlowWhenCanonicalColumnZeroed(t *testing.T) {
|
|
func TestAttach_PreservesVisionFlowWhenCanonicalColumnZeroed(t *testing.T) {
|
|
|
dbDir := t.TempDir()
|
|
dbDir := t.TempDir()
|
|
|
t.Setenv("XUI_DB_FOLDER", dbDir)
|
|
t.Setenv("XUI_DB_FOLDER", dbDir)
|
|
|
- if err := database.InitDB(filepath.Join(dbDir, "x-ui.db")); err != nil {
|
|
|
|
|
- t.Fatalf("InitDB: %v", err)
|
|
|
|
|
- }
|
|
|
|
|
- t.Cleanup(func() { _ = database.CloseDB() })
|
|
|
|
|
|
|
+ dbtest.InitDB(t, filepath.Join(dbDir, "x-ui.db"))
|
|
|
|
|
|
|
|
db := database.GetDB()
|
|
db := database.GetDB()
|
|
|
|
|
|
|
@@ -267,10 +256,7 @@ func TestAttach_PreservesVisionFlowWhenCanonicalColumnZeroed(t *testing.T) {
|
|
|
func TestBulkAttach_PreservesVisionFlowWhenCanonicalColumnZeroed(t *testing.T) {
|
|
func TestBulkAttach_PreservesVisionFlowWhenCanonicalColumnZeroed(t *testing.T) {
|
|
|
dbDir := t.TempDir()
|
|
dbDir := t.TempDir()
|
|
|
t.Setenv("XUI_DB_FOLDER", dbDir)
|
|
t.Setenv("XUI_DB_FOLDER", dbDir)
|
|
|
- if err := database.InitDB(filepath.Join(dbDir, "x-ui.db")); err != nil {
|
|
|
|
|
- t.Fatalf("InitDB: %v", err)
|
|
|
|
|
- }
|
|
|
|
|
- t.Cleanup(func() { _ = database.CloseDB() })
|
|
|
|
|
|
|
+ dbtest.InitDB(t, filepath.Join(dbDir, "x-ui.db"))
|
|
|
|
|
|
|
|
db := database.GetDB()
|
|
db := database.GetDB()
|
|
|
|
|
|