diff options
author | Martin Czygan <martin.czygan@gmail.com> | 2021-06-21 23:48:26 +0200 |
---|---|---|
committer | Martin Czygan <martin.czygan@gmail.com> | 2021-06-21 23:48:26 +0200 |
commit | 1e6f3ed4c9710ab00c1bf002f5a14f52eb3bf5c5 (patch) | |
tree | 7ab014a5c9b2db97e24a60ee27d5f6f2fa8ac8b4 /skate/xio | |
parent | dea840992ea80288760dacb0c9c80bc8b085978f (diff) | |
download | refcat-1e6f3ed4c9710ab00c1bf002f5a14f52eb3bf5c5.tar.gz refcat-1e6f3ed4c9710ab00c1bf002f5a14f52eb3bf5c5.zip |
add test case
Diffstat (limited to 'skate/xio')
-rw-r--r-- | skate/xio/util_test.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/skate/xio/util_test.go b/skate/xio/util_test.go new file mode 100644 index 0000000..b1e06a5 --- /dev/null +++ b/skate/xio/util_test.go @@ -0,0 +1,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 +} |