(m *testing.M)
| 351 | } |
| 352 | |
| 353 | func 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 | } |
nothing calls this directly
no test coverage detected