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

Function TestDirMode_ExplicitOctal

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

Source from the content-addressed store, hash-verified

508}
509
510func TestDirMode_ExplicitOctal(t *testing.T) {
511 m := syscall.Umask(0)
512 defer syscall.Umask(m)
513
514 base := t.TempDir()
515 dest := filepath.Join(base, "logs3")
516 fw := &FileWriter{
517 Filename: filepath.Join(dest, "app.log"),
518 DirMode: "0750",
519 Mode: 0o640,
520 Roll: func() *bool { f := false; return &f }(),
521 }
522 w, err := fw.OpenWriter()
523 if err != nil {
524 t.Fatal(err)
525 }
526 _ = w.Close()
527
528 st, err := os.Stat(dest)
529 if err != nil {
530 t.Fatal(err)
531 }
532 if got := st.Mode().Perm(); got != 0o750 {
533 t.Fatalf("dir perm = %o, want 0750", got)
534 }
535}
536
537func TestDirMode_Default0700(t *testing.T) {
538 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