MCPcopy Create free account
hub / github.com/sql-machine-learning/sqlflow / createTestingDB

Function createTestingDB

go/database/testing.go:56–68  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

54// order to do it, users might want to define TestMain and call
55// createTestingDB and defer db.Close in it.
56func 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
71func GetTestingMySQLConfig() *mysql.Config {

Callers 1

GetTestingDBSingletonFunction · 0.85

Calls 4

GetEnvFunction · 0.92
createTestingMySQLDBFunction · 0.85
createTestingHiveDBFunction · 0.85

Tested by

no test coverage detected