MCPcopy
hub / github.com/natefinch/lumberjack / TestAutoRotate

Function TestAutoRotate

lumberjack_test.go:127–163  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

125}
126
127func TestAutoRotate(t *testing.T) {
128 currentTime = fakeTime
129 megabyte = 1
130
131 dir := makeTempDir("TestAutoRotate", t)
132 defer os.RemoveAll(dir)
133
134 filename := logFile(dir)
135 l := &Logger{
136 Filename: filename,
137 MaxSize: 10,
138 }
139 defer l.Close()
140 b := []byte("boo!")
141 n, err := l.Write(b)
142 isNil(err, t)
143 equals(len(b), n, t)
144
145 existsWithContent(filename, b, t)
146 fileCount(dir, 1, t)
147
148 newFakeTime()
149
150 b2 := []byte("foooooo!")
151 n, err = l.Write(b2)
152 isNil(err, t)
153 equals(len(b2), n, t)
154
155 // the old logfile should be moved aside and the main logfile should have
156 // only the last write in it.
157 existsWithContent(filename, b2, t)
158
159 // the backup file will use the current fake time and have the old contents.
160 existsWithContent(backupFile(dir), b, t)
161
162 fileCount(dir, 2, t)
163}
164
165func TestFirstWriteRotate(t *testing.T) {
166 currentTime = fakeTime

Callers

nothing calls this directly

Calls 10

CloseMethod · 0.95
WriteMethod · 0.95
makeTempDirFunction · 0.85
logFileFunction · 0.85
isNilFunction · 0.85
equalsFunction · 0.85
existsWithContentFunction · 0.85
fileCountFunction · 0.85
newFakeTimeFunction · 0.85
backupFileFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…