aboutsummaryrefslogtreecommitdiffstats
path: root/skate/xio/util_test.go
blob: b1e06a550df5e300e824892e0dc58f3df48b3fc3 (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
25
26
27
28
29
30
31
32
33
34
35
package xio

import (
	"io/ioutil"
	"testing"
)

func TestOpenTwo(t *testing.T) {
	a, err := tempFile(t)
	if err != nil {
		t.Fatalf("failed to create tmp file: %v", err)
	}
	b, err := tempFile(t)
	if err != nil {
		t.Fatalf("failed to create tmp file: %v", err)
	}
	f1, f2, err := OpenTwo(a, b)
	if err != nil {
		t.Fatalf("failed to OpenTwo: %v", err)
	}
	defer f1.Close()
	defer f2.Close()
}

// tempFile creates an empty temporary file and returns its name on success.
func tempFile(t *testing.T) (filename string, err error) {
	f, err := ioutil.TempFile(t.TempDir(), "")
	if err != nil {
		return "", err
	}
	if err := f.Close(); err != nil {
		return "", err
	}
	return f.Name(), nil
}