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

Function TestMaintainOwner

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

Source from the content-addressed store, hash-verified

47}
48
49func TestMaintainOwner(t *testing.T) {
50 fakeFS := newFakeFS()
51 osChown = fakeFS.Chown
52 osStat = fakeFS.Stat
53 defer func() {
54 osChown = os.Chown
55 osStat = os.Stat
56 }()
57 currentTime = fakeTime
58 dir := makeTempDir("TestMaintainOwner", t)
59 defer os.RemoveAll(dir)
60
61 filename := logFile(dir)
62
63 f, err := os.OpenFile(filename, os.O_CREATE|os.O_RDWR, 0644)
64 isNil(err, t)
65 f.Close()
66
67 l := &Logger{
68 Filename: filename,
69 MaxBackups: 1,
70 MaxSize: 100, // megabytes
71 }
72 defer l.Close()
73 b := []byte("boo!")
74 n, err := l.Write(b)
75 isNil(err, t)
76 equals(len(b), n, t)
77
78 newFakeTime()
79
80 err = l.Rotate()
81 isNil(err, t)
82
83 equals(555, fakeFS.files[filename].uid, t)
84 equals(666, fakeFS.files[filename].gid, t)
85}
86
87func TestCompressMaintainMode(t *testing.T) {
88 currentTime = fakeTime

Callers

nothing calls this directly

Calls 9

CloseMethod · 0.95
WriteMethod · 0.95
RotateMethod · 0.95
newFakeFSFunction · 0.85
makeTempDirFunction · 0.85
logFileFunction · 0.85
isNilFunction · 0.85
equalsFunction · 0.85
newFakeTimeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…