MCPcopy
hub / github.com/dgraph-io/dgraph / TestMain

Function TestMain

dgraph/cmd/live/load-uids/load_test.go:353–383  ·  view source on GitHub ↗
(m *testing.M)

Source from the content-addressed store, hash-verified

351}
352
353func TestMain(m *testing.M) {
354 alphaService = testutil.GetSockAddr()
355 alphaName = testutil.Instance
356
357 x.AssertTrue(strings.Count(alphaName, "_") == 2)
358 left := strings.Index(alphaName, "_")
359 right := strings.LastIndex(alphaName, "_")
360 alphaExportPath = alphaName + ":/data/" + alphaName[left+1:right] + "/export"
361 fmt.Printf("alphaExportPath: %s\n", alphaExportPath)
362
363 _, thisFile, _, _ := runtime.Caller(0)
364 testDataDir = filepath.Dir(thisFile)
365 fmt.Printf("Using test data dir: %s\n", testDataDir)
366
367 var err error
368 dg, err = testutil.DgraphClientWithGroot(testutil.GetSockAddr())
369 if err != nil {
370 log.Fatalf("Error while getting a dgraph client: %v", err)
371 }
372 x.Panic(dg.Alter(
373 context.Background(), &api.Operation{DropAll: true}))
374
375 // Try to create any files in a dedicated temp directory that gets cleaned up
376 // instead of all over /tmp or the working directory.
377 tmpDir, err := os.MkdirTemp("", "test.tmp-")
378 x.Panic(err)
379 x.Panic(os.Chdir(tmpDir))
380 defer os.RemoveAll(tmpDir)
381
382 m.Run()
383}

Callers

nothing calls this directly

Calls 11

GetSockAddrFunction · 0.92
AssertTrueFunction · 0.92
DgraphClientWithGrootFunction · 0.92
PanicFunction · 0.92
CountMethod · 0.80
IndexMethod · 0.80
FatalfMethod · 0.80
AlterMethod · 0.80
RemoveAllMethod · 0.80
LastIndexMethod · 0.45
RunMethod · 0.45

Tested by

no test coverage detected