MCPcopy
hub / github.com/andeya/pholcus / TestFileAdapter

Function TestFileAdapter

logs/logs/log_test.go:232–249  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

230}
231
232func TestFileAdapter(t *testing.T) {
233 dir := t.TempDir()
234 fpath := filepath.Join(dir, "test.log")
235 bl := NewLogger(100)
236 err := bl.SetLogger("file", map[string]interface{}{"filename": fpath})
237 if err != nil {
238 t.Fatalf("SetLogger file: %v", err)
239 }
240 bl.Async(false)
241 bl.Debug("file debug")
242 bl.Error("file error")
243 bl.Flush()
244 bl.DelLogger("file")
245 data, _ := os.ReadFile(fpath)
246 if len(data) == 0 {
247 t.Error("file adapter wrote nothing")
248 }
249}
250
251func TestFileAdapterAppendToExisting(t *testing.T) {
252 dir := t.TempDir()

Callers

nothing calls this directly

Calls 7

NewLoggerFunction · 0.85
AsyncMethod · 0.80
SetLoggerMethod · 0.65
DebugMethod · 0.65
ErrorMethod · 0.65
FlushMethod · 0.65
DelLoggerMethod · 0.65

Tested by

no test coverage detected