Add end-to-end replication/restore testing
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
package testingutil
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// MustReadFile reads all data from filename. Fail on error.
|
||||
func MustReadFile(tb testing.TB, filename string) []byte {
|
||||
// ReadFile reads all data from filename. Fail on error.
|
||||
func ReadFile(tb testing.TB, filename string) []byte {
|
||||
tb.Helper()
|
||||
b, err := os.ReadFile(filename)
|
||||
if err != nil {
|
||||
@@ -15,6 +16,26 @@ func MustReadFile(tb testing.TB, filename string) []byte {
|
||||
return b
|
||||
}
|
||||
|
||||
// CopyFile copies all data from src to dst. Fail on error.
|
||||
func CopyFile(tb testing.TB, src, dst string) {
|
||||
tb.Helper()
|
||||
r, err := os.Open(src)
|
||||
if err != nil {
|
||||
tb.Fatal(err)
|
||||
}
|
||||
defer r.Close()
|
||||
|
||||
w, err := os.Create(dst)
|
||||
if err != nil {
|
||||
tb.Fatal(err)
|
||||
}
|
||||
defer w.Close()
|
||||
|
||||
if _, err := io.Copy(w, r); err != nil {
|
||||
tb.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Getpwd returns the working directory. Fail on error.
|
||||
func Getwd(tb testing.TB) string {
|
||||
tb.Helper()
|
||||
|
||||
Reference in New Issue
Block a user