| 35 | } |
| 36 | |
| 37 | func TestInitMysqlError(t *testing.T) { |
| 38 | err := config.Init(configs.Path("serverNameExample.yml")) |
| 39 | if err != nil { |
| 40 | panic(err) |
| 41 | } |
| 42 | |
| 43 | // change config error test |
| 44 | config.Get().Database.Mysql.Dsn = "root:123456@(127.0.0.1:3306)/test" |
| 45 | |
| 46 | utils.SafeRunWithTimeout(time.Second*2, func(cancel context.CancelFunc) { |
| 47 | _ = CloseDB() |
| 48 | InitMysql() |
| 49 | assert.NotNil(t, gdb) |
| 50 | cancel() |
| 51 | }) |
| 52 | } |
| 53 | |
| 54 | func TestInitPostgresqlError(t *testing.T) { |
| 55 | _ = config.Init(configs.Path("serverNameExample.yml")) |