From 81926d61db3dac223a75ea49eab893b25a089587 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Tue, 16 Nov 2021 16:53:21 +0800 Subject: Decouple unit test, remove intermediate `unittestbridge` package (#17662) Co-authored-by: Lunny Xiao --- models/db/engine.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'models/db/engine.go') diff --git a/models/db/engine.go b/models/db/engine.go index d1b279e016..e392008020 100755 --- a/models/db/engine.go +++ b/models/db/engine.go @@ -153,6 +153,15 @@ func InitEngine(ctx context.Context) (err error) { return nil } +// SetEngine is used by unit test code +func SetEngine(eng *xorm.Engine) { + x = eng + DefaultContext = &Context{ + Context: context.Background(), + e: x, + } +} + // InitEngineWithMigration initializes a new xorm.Engine // This function must never call .Sync2() if the provided migration function fails. // When called from the "doctor" command, the migration function is a version check -- cgit v1.2.3