mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-10-07 14:59:44 +00:00
test✅: restore the tenant's previous database after the opera log test
sdk.Runtime is process-wide, so setting the tenant back to nil on cleanup could overwrite a mapping another test had installed. Save the previous value and put it back, as common/middleware/db_test.go does.
This commit is contained in:
@@ -23,8 +23,9 @@ func TestSaveOperaLogTruncatesOnCharacterBoundary(t *testing.T) {
|
||||
if err := db.AutoMigrate(&SysOperaLog{}); err != nil {
|
||||
t.Fatalf("migrate: %v", err)
|
||||
}
|
||||
previous := sdk.Runtime.GetDbByTenant(tenant)
|
||||
sdk.Runtime.SetDbByTenant(tenant, db)
|
||||
t.Cleanup(func() { sdk.Runtime.SetDbByTenant(tenant, nil) })
|
||||
t.Cleanup(func() { sdk.Runtime.SetDbByTenant(tenant, previous) })
|
||||
|
||||
// 150 characters, 3 bytes each: byte 100 falls inside the 34th character.
|
||||
long := strings.Repeat("中", 150)
|
||||
|
||||
Reference in New Issue
Block a user