Skip to content

Commit 4077a01

Browse files
committed
update deps
1 parent bedc04d commit 4077a01

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

io/fileutils_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package io
2+
3+
import (
4+
"errors"
5+
"github.com/stretchr/testify/assert"
6+
"os"
7+
"path"
8+
"strings"
9+
"testing"
10+
)
11+
12+
func TestClose(t *testing.T) {
13+
var err error
14+
t.TempDir()
15+
f, err := os.Create(path.Join(t.TempDir(), "test"))
16+
assert.NoError(t, err)
17+
18+
Close(f, &err)
19+
assert.NoError(t, err)
20+
21+
// Try closing the same file again and expect error
22+
Close(f, &err)
23+
assert.Error(t, err)
24+
25+
// Check that both errors are aggregated
26+
err = errors.New("original error")
27+
Close(f, &err)
28+
assert.Len(t, strings.Split(err.Error(), "\n"), 2)
29+
}

0 commit comments

Comments
 (0)