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

Function TestMaintainMode

linux_test.go:12–47  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestMaintainMode(t *testing.T) {
13 currentTime = fakeTime
14 dir := makeTempDir("TestMaintainMode", t)
15 defer os.RemoveAll(dir)
16
17 filename := logFile(dir)
18
19 mode := os.FileMode(0600)
20 f, err := os.OpenFile(filename, os.O_CREATE|os.O_RDWR, mode)
21 isNil(err, t)
22 f.Close()
23
24 l := &Logger{
25 Filename: filename,
26 MaxBackups: 1,
27 MaxSize: 100, // megabytes
28 }
29 defer l.Close()
30 b := []byte("boo!")
31 n, err := l.Write(b)
32 isNil(err, t)
33 equals(len(b), n, t)
34
35 newFakeTime()
36
37 err = l.Rotate()
38 isNil(err, t)
39
40 filename2 := backupFile(dir)
41 info, err := os.Stat(filename)
42 isNil(err, t)
43 info2, err := os.Stat(filename2)
44 isNil(err, t)
45 equals(mode, info.Mode(), t)
46 equals(mode, info2.Mode(), t)
47}
48
49func TestMaintainOwner(t *testing.T) {
50 fakeFS := newFakeFS()

Callers

nothing calls this directly

Calls 10

CloseMethod · 0.95
WriteMethod · 0.95
RotateMethod · 0.95
makeTempDirFunction · 0.85
logFileFunction · 0.85
isNilFunction · 0.85
equalsFunction · 0.85
newFakeTimeFunction · 0.85
backupFileFunction · 0.85
StatMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…