MCPcopy
hub / github.com/wal-g/wal-g / TestRestoringPagesToEmptyFile

Function TestRestoringPagesToEmptyFile

internal/databases/postgres/pagefile_test.go:385–399  ·  view source on GitHub ↗

If the local file is empty, it should be fully restored

(t *testing.T)

Source from the content-addressed store, hash-verified

383
384// If the local file is empty, it should be fully restored
385func TestRestoringPagesToEmptyFile(t *testing.T) {
386 pagedFile, _ := os.Open(pagedFileName)
387 fileReader := io.Reader(pagedFile)
388 defer utility.LoggedClose(pagedFile, "")
389 mockContent := make([]byte, DatabasePageSize*pagedFileBlockCount)
390 mockFile := NewMockReadWriterAt(mockContent)
391
392 err := RestoreMissingPages(fileReader, mockFile)
393
394 assert.NoError(t, err, "Expected no errors after restoring missing pages")
395 mockFileReader := bytes.NewReader(mockFile.content)
396 pagedFile.Seek(0, 0)
397 compareResult := deepCompareReaders(pagedFile, mockFileReader)
398 assert.Truef(t, compareResult, "Increment could not restore file")
399}
400
401// Verify that all increment blocks exist in the resulting file
402// and that each block has been written to the right place

Callers

nothing calls this directly

Calls 8

LoggedCloseFunction · 0.92
NewMockReadWriterAtFunction · 0.85
RestoreMissingPagesFunction · 0.85
deepCompareReadersFunction · 0.85
OpenMethod · 0.80
NewReaderMethod · 0.80
ReaderMethod · 0.65
SeekMethod · 0.45

Tested by

no test coverage detected