MCPcopy
hub / github.com/caddyserver/caddy / TestDirMode_Inherit

Function TestDirMode_Inherit

modules/logging/filewriter_test.go:430–459  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

428}
429
430func TestDirMode_Inherit(t *testing.T) {
431 m := syscall.Umask(0)
432 defer syscall.Umask(m)
433
434 parent := t.TempDir()
435 if err := os.Chmod(parent, 0o755); err != nil {
436 t.Fatal(err)
437 }
438
439 targetDir := filepath.Join(parent, "a", "b")
440 fw := &FileWriter{
441 Filename: filepath.Join(targetDir, "test.log"),
442 DirMode: "inherit",
443 Mode: 0o640,
444 Roll: func() *bool { f := false; return &f }(),
445 }
446 w, err := fw.OpenWriter()
447 if err != nil {
448 t.Fatal(err)
449 }
450 _ = w.Close()
451
452 st, err := os.Stat(targetDir)
453 if err != nil {
454 t.Fatal(err)
455 }
456 if got := st.Mode().Perm(); got != 0o755 {
457 t.Fatalf("dir perm = %o, want 0755", got)
458 }
459}
460
461func TestDirMode_FromFile(t *testing.T) {
462 m := syscall.Umask(0)

Callers

nothing calls this directly

Calls 3

OpenWriterMethod · 0.95
StatMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected