Skip to content

Commit

Permalink
update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
sverdlov93 committed Mar 3, 2024
1 parent bedc04d commit 4077a01
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions io/fileutils_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package io

import (
"errors"
"github.com/stretchr/testify/assert"
"os"
"path"
"strings"
"testing"
)

func TestClose(t *testing.T) {
var err error
t.TempDir()
f, err := os.Create(path.Join(t.TempDir(), "test"))
assert.NoError(t, err)

Close(f, &err)
assert.NoError(t, err)

// Try closing the same file again and expect error
Close(f, &err)
assert.Error(t, err)

// Check that both errors are aggregated
err = errors.New("original error")
Close(f, &err)
assert.Len(t, strings.Split(err.Error(), "\n"), 2)
}

0 comments on commit 4077a01

Please sign in to comment.