Skip to content

Commit

Permalink
tests: improve errors management
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Jun 30, 2024
1 parent c9b0b98 commit 1113ec8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
9 changes: 6 additions & 3 deletions flock_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ import (
"github.com/stretchr/testify/require"
)

func Test(t *testing.T) {
func TestFlock_fh_onError(t *testing.T) {
tmpFile, err := os.CreateTemp(t.TempDir(), "go-flock-")
require.NoError(t, err)

_ = tmpFile.Close()
_ = os.Remove(tmpFile.Name())
err = tmpFile.Close()
require.NoError(t, err)

err = os.Remove(tmpFile.Name())
require.NoError(t, err)

lock := New(tmpFile.Name())

Expand Down
7 changes: 5 additions & 2 deletions flock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ func (s *TestSuite) SetupTest() {
s.Require().NotNil(tmpFile)

s.path = tmpFile.Name()
_ = tmpFile.Close()

defer os.Remove(s.path)
err = tmpFile.Close()
s.Require().NoError(err)

err = os.Remove(s.path)
s.Require().NoError(err)

s.flock = flock.New(s.path)
}
Expand Down

0 comments on commit 1113ec8

Please sign in to comment.