diff --git a/core/filex/file_test.go b/core/filex/file_test.go index ed773d91..d79e06a8 100644 --- a/core/filex/file_test.go +++ b/core/filex/file_test.go @@ -74,6 +74,11 @@ func TestFirstLineShort(t *testing.T) { assert.Equal(t, "first line", val) } +func TestFirstLineError(t *testing.T) { + _, err := FirstLine("/tmp/does-not-exist") + assert.Error(t, err) +} + func TestLastLine(t *testing.T) { filename, err := fs.TempFilenameWithText(text) assert.Nil(t, err) @@ -113,3 +118,8 @@ func TestLastLineWithLastNewlineShort(t *testing.T) { assert.Nil(t, err) assert.Equal(t, "last line", val) } + +func TestLastLineError(t *testing.T) { + _, err := LastLine("/tmp/does-not-exist") + assert.Error(t, err) +} diff --git a/core/logx/writer_test.go b/core/logx/writer_test.go index ec5e8912..c88d0c7b 100644 --- a/core/logx/writer_test.go +++ b/core/logx/writer_test.go @@ -97,6 +97,15 @@ func TestConsoleWriter(t *testing.T) { w.(*concreteWriter).statLog = easyToCloseWriter{} } +func TestNewFileWriter(t *testing.T) { + t.Run("access", func(t *testing.T) { + _, err := newFileWriter(LogConf{ + Path: "/not-exists", + }) + assert.Error(t, err) + }) +} + func TestNopWriter(t *testing.T) { assert.NotPanics(t, func() { var w nopWriter