aboutsummaryrefslogtreecommitdiff
path: root/librsync/common_test.go
blob: 65828be8e9d3fc9fccecedcf51b9411eb552e05b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package librsync // import "code.laria.me/golibrsync/librsync"

import (
	"fmt"
	"io"
	"os"
)

// Some functions to support testing

func dump(r io.Reader) (string, error) {
	path := fmt.Sprintf("%s%cgolibrsync_test", os.TempDir(), os.PathSeparator)
	file, err := os.Create(path)
	if err != nil {
		return "", err
	}
	defer file.Close()

	if _, err = io.Copy(file, r); err != nil {
		return "", err
	}

	return path, nil
}