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

Function TestDirMode_Default0700

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

Source from the content-addressed store, hash-verified

535}
536
537func TestDirMode_Default0700(t *testing.T) {
538 m := syscall.Umask(0)
539 defer syscall.Umask(m)
540
541 base := t.TempDir()
542 dest := filepath.Join(base, "logs4")
543 fw := &FileWriter{
544 Filename: filepath.Join(dest, "app.log"),
545 Mode: 0o640,
546 Roll: func() *bool { f := false; return &f }(),
547 }
548 w, err := fw.OpenWriter()
549 if err != nil {
550 t.Fatal(err)
551 }
552 _ = w.Close()
553
554 st, err := os.Stat(dest)
555 if err != nil {
556 t.Fatal(err)
557 }
558 if got := st.Mode().Perm(); got != 0o700 {
559 t.Fatalf("dir perm = %o, want 0700", got)
560 }
561}
562
563func TestDirMode_UmaskInteraction(t *testing.T) {
564 _ = syscall.Umask(0o022) // typical umask; restore after

Callers

nothing calls this directly

Calls 3

OpenWriterMethod · 0.95
StatMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected