createTestingDB opens a database with parameters specified in the environment variables with prefix name "SQLFLOW_TEST_DB". By default, the database driver is "mysql". It also creates some tables in the opened database, and popularize data. For any error, createTestingDB panics. NOTE: It is the
()
| 54 | // order to do it, users might want to define TestMain and call |
| 55 | // createTestingDB and defer db.Close in it. |
| 56 | func createTestingDB() *DB { |
| 57 | switch dbms := test.GetEnv("SQLFLOW_TEST_DB", "mysql"); dbms { |
| 58 | case "mysql": |
| 59 | return createTestingMySQLDB() |
| 60 | case "hive": |
| 61 | return createTestingHiveDB() |
| 62 | case "maxcompute": |
| 63 | return createTestingMaxComputeDB() |
| 64 | default: |
| 65 | log.Panicf("Unrecognized environment variable SQLFLOW_TEST_DB %s", dbms) |
| 66 | } |
| 67 | return nil |
| 68 | } |
| 69 | |
| 70 | // GetTestingMySQLConfig construct a MySQL config |
| 71 | func GetTestingMySQLConfig() *mysql.Config { |
no test coverage detected