MCPcopy
hub / github.com/pingcap/tidb / testWriteFile

Function testWriteFile

br/pkg/task/operator/test_storage.go:311–335  ·  view source on GitHub ↗
(tc *TestContext, name string, data []byte)

Source from the content-addressed store, hash-verified

309}
310
311func testWriteFile(tc *TestContext, name string, data []byte) {
312 testName := fmt.Sprintf("WriteFile(%s)", name)
313 printStep("Test: %s", testName)
314 start := time.Now()
315
316 err := tc.Store.WriteFile(tc.Ctx, name, data)
317 duration := time.Since(start)
318
319 result := TestResult{
320 Name: testName,
321 Duration: duration,
322 Details: fmt.Sprintf("Wrote %d bytes", len(data)),
323 }
324
325 if err != nil {
326 printError(" ❌ Failed: %v", err)
327 result.Passed = false
328 result.Error = errors.Annotate(err, "WriteFile failed")
329 } else {
330 printSuccess(" ✓ Passed")
331 result.Passed = true
332 }
333
334 tc.AddResult(result)
335}
336
337func testFileExists(tc *TestContext, name string, expected bool) {
338 testName := fmt.Sprintf("FileExists(%s) - expecting %v", name, expected)

Callers 1

RunTestStorageFunction · 0.85

Calls 6

printStepFunction · 0.85
printErrorFunction · 0.85
printSuccessFunction · 0.85
NowMethod · 0.65
WriteFileMethod · 0.65
AddResultMethod · 0.45

Tested by

no test coverage detected