MCPcopy Create free account
hub / github.com/celer-pkg/celer / TestCeler_Init_InvalidCacheDir

Function TestCeler_Init_InvalidCacheDir

configs/celer_test.go:99–121  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

97}
98
99func TestCeler_Init_InvalidCacheDir(t *testing.T) {
100 // Prepare test environment.
101 tmpDir := t.TempDir()
102 dirs.Init(tmpDir)
103 celerPath := filepath.Join(tmpDir, "celer.toml")
104
105 // Create config with invalid cache dir.
106 configWithInvalidCache := `[pkgcache]
107dir = ""
108`
109 if err := os.MkdirAll(tmpDir, os.ModePerm); err != nil {
110 t.Fatalf("MkdirAll() error = %v", err)
111 }
112 if err := os.WriteFile(celerPath, []byte(configWithInvalidCache), os.ModePerm); err != nil {
113 t.Fatalf("WriteFile() error = %v", err)
114 }
115
116 // Test cases.
117 celer := NewCeler()
118 if err := celer.Init(); err == nil {
119 t.Error("Init() should return error for invalid cache dir")
120 }
121}

Callers

nothing calls this directly

Calls 6

InitMethod · 0.95
InitFunction · 0.92
NewCelerFunction · 0.85
MkdirAllMethod · 0.80
WriteFileMethod · 0.80
ErrorMethod · 0.80

Tested by

no test coverage detected