MCPcopy Index your code
hub / github.com/google/go-github / assertEqualFiles

Function assertEqualFiles

tools/metadata/main_test.go:394–412  ·  view source on GitHub ↗
(t *testing.T, want, got string)

Source from the content-addressed store, hash-verified

392}
393
394func assertEqualFiles(t *testing.T, want, got string) bool {
395 t.Helper()
396 wantBytes, err := os.ReadFile(want)
397 if !assertNilError(t, err) {
398 return false
399 }
400 wantBytes = bytes.ReplaceAll(wantBytes, []byte("\r\n"), []byte("\n"))
401 gotBytes, err := os.ReadFile(got)
402 if !assertNilError(t, err) {
403 return false
404 }
405 gotBytes = bytes.ReplaceAll(gotBytes, []byte("\r\n"), []byte("\n"))
406 if !bytes.Equal(wantBytes, gotBytes) {
407 diff := cmp.Diff(string(wantBytes), string(gotBytes))
408 t.Errorf("files %q and %q differ: %v", want, got, diff)
409 return false
410 }
411 return true
412}
413
414func assertNilError(t *testing.T, err error) bool {
415 t.Helper()

Callers 1

checkGoldenDirFunction · 0.85

Calls 2

EqualMethod · 0.80
assertNilErrorFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…