MCPcopy
hub / github.com/tinode/chat / init

Function init

server/db/postgres/tests/postgres_test.go:1382–1412  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1380}
1381
1382func init() {
1383 ctx = context.Background()
1384 logs.Init(os.Stderr, "stdFlags")
1385 adp = backend.GetTestAdapter()
1386 conffile := flag.String("config", "./test.conf", "config of the database connection")
1387
1388 if file, err := os.Open(*conffile); err != nil {
1389 log.Fatal("Failed to read config file:", err)
1390 } else if err = json.NewDecoder(jcr.New(file)).Decode(&config); err != nil {
1391 log.Fatal("Failed to parse config file:", err)
1392 }
1393
1394 if adp == nil {
1395 log.Fatal("Database adapter is missing")
1396 }
1397 if adp.IsOpen() {
1398 log.Print("Connection is already opened")
1399 }
1400
1401 err := adp.Open(config.Adapters[adp.GetName()])
1402 if err != nil {
1403 log.Fatal(err)
1404 }
1405
1406 db = adp.GetTestDB().(*pgxpool.Pool)
1407 testData = test_data.InitTestData()
1408 if testData == nil {
1409 log.Fatal("Failed to initialize test data")
1410 }
1411 store.SetTestUidGenerator(*testData.UGen)
1412}

Callers

nothing calls this directly

Calls 8

InitFunction · 0.92
InitTestDataFunction · 0.92
SetTestUidGeneratorFunction · 0.92
OpenMethod · 0.65
IsOpenMethod · 0.65
GetNameMethod · 0.65
GetTestDBMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…