MCPcopy Create free account
hub / github.com/codehamr/codehamr / TestBootstrapTightensLooseDirPerms

Function TestBootstrapTightensLooseDirPerms

internal/config/config_test.go:351–370  ·  view source on GitHub ↗

TestBootstrapTightensLooseDirPerms: a .codehamr/ created loose (older release, or by hand at 0o755) must be tightened on the next Bootstrap, the directory counterpart of Save's fresh-temp-inode fix for config.yaml.

(t *testing.T)

Source from the content-addressed store, hash-verified

349// release, or by hand at 0o755) must be tightened on the next Bootstrap, the
350// directory counterpart of Save's fresh-temp-inode fix for config.yaml.
351func TestBootstrapTightensLooseDirPerms(t *testing.T) {
352 root := t.TempDir()
353 dir := filepath.Join(root, DirName)
354 if err := os.MkdirAll(dir, 0o755); err != nil {
355 t.Fatal(err)
356 }
357 if err := os.Chmod(dir, 0o755); err != nil { // bypass umask
358 t.Fatal(err)
359 }
360 if _, _, err := Bootstrap(root); err != nil {
361 t.Fatal(err)
362 }
363 st, err := os.Stat(dir)
364 if err != nil {
365 t.Fatal(err)
366 }
367 if got := st.Mode().Perm(); got != 0o700 {
368 t.Fatalf("pre-existing loose .codehamr/ = %v after Bootstrap, want 0o700", got)
369 }
370}
371
372// TestSaveIsAtomicAndLeavesNoTemp: writeYAML writes a sibling temp then renames
373// it over config.yaml so a torn write can't brick the next launch. Pin that the

Callers

nothing calls this directly

Calls 1

BootstrapFunction · 0.85

Tested by

no test coverage detected