mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-23 17:20:24 +08:00
chore: add more tests (#3315)
This commit is contained in:
parent
3564e36a35
commit
452c9dbcaf
@ -74,6 +74,11 @@ func TestFirstLineShort(t *testing.T) {
|
|||||||
assert.Equal(t, "first line", val)
|
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) {
|
func TestLastLine(t *testing.T) {
|
||||||
filename, err := fs.TempFilenameWithText(text)
|
filename, err := fs.TempFilenameWithText(text)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
@ -113,3 +118,8 @@ func TestLastLineWithLastNewlineShort(t *testing.T) {
|
|||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
assert.Equal(t, "last line", val)
|
assert.Equal(t, "last line", val)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestLastLineError(t *testing.T) {
|
||||||
|
_, err := LastLine("/tmp/does-not-exist")
|
||||||
|
assert.Error(t, err)
|
||||||
|
}
|
||||||
|
@ -97,6 +97,15 @@ func TestConsoleWriter(t *testing.T) {
|
|||||||
w.(*concreteWriter).statLog = easyToCloseWriter{}
|
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) {
|
func TestNopWriter(t *testing.T) {
|
||||||
assert.NotPanics(t, func() {
|
assert.NotPanics(t, func() {
|
||||||
var w nopWriter
|
var w nopWriter
|
||||||
|
Loading…
Reference in New Issue
Block a user