MCPcopy Index your code
hub / github.com/celer-pkg/celer / TestNFSServerSetupRemoveChattrCronJob

Function TestNFSServerSetupRemoveChattrCronJob

pkgcache/cache_setup_test.go:102–123  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

100}
101
102func TestNFSServerSetupRemoveChattrCronJob(t *testing.T) {
103 cronDir := t.TempDir()
104 cronPath := filepath.Join(cronDir, "celer-chattr")
105 if err := os.WriteFile(cronPath, []byte("* * * * * root /usr/bin/find /srv/cache -type d -exec /usr/bin/chattr +a {} + 2>/dev/null\n"), 0644); err != nil {
106 t.Fatal(err)
107 }
108
109 oldNFSCronDir := nfsCronDir
110 nfsCronDir = cronDir
111 t.Cleanup(func() { nfsCronDir = oldNFSCronDir })
112
113 setup := NewNFSServerSetup("/srv/cache")
114 if err := setup.removeChattrCronJob(nfsUser); err != nil {
115 t.Fatal(err)
116 }
117 if _, err := os.Stat(cronPath); !os.IsNotExist(err) {
118 t.Fatalf("os.Stat() error = %v, want missing cron file", err)
119 }
120 if err := setup.removeChattrCronJob(nfsUser); err != nil {
121 t.Fatal(err)
122 }
123}
124
125func TestNFSClientSetupRemoveFSTabEntry(t *testing.T) {
126 fstabPath := filepath.Join(t.TempDir(), "fstab")

Callers

nothing calls this directly

Calls 3

removeChattrCronJobMethod · 0.95
NewNFSServerSetupFunction · 0.85
WriteFileMethod · 0.80

Tested by

no test coverage detected