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

Function TestCeler_Init_ExistingConfig

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

Source from the content-addressed store, hash-verified

37}
38
39func TestCeler_Init_ExistingConfig(t *testing.T) {
40 // Prepare test environment.
41 tmpDir := t.TempDir()
42 dirs.Init(tmpDir)
43
44 packageCacheDir := filepath.Join(tmpDir, "pkgcache_dir")
45 if err := os.MkdirAll(packageCacheDir, os.ModePerm); err != nil {
46 t.Fatalf("MkdirAll() error = %v", err)
47 }
48
49 // Create a test config.
50 existingConfig := `[main]
51 build_type = "debug"
52 jobs = 4
53 platform = ""
54 project = ""`
55
56 celerPath := filepath.Join(tmpDir, "celer.toml")
57 if err := os.MkdirAll(tmpDir, os.ModePerm); err != nil {
58 t.Fatalf("MkdirAll() error = %v", err)
59 }
60 if err := os.WriteFile(celerPath, []byte(existingConfig), os.ModePerm); err != nil {
61 t.Fatalf("WriteFile() error = %v", err)
62 }
63
64 celer := NewCeler()
65 if err := celer.Init(); err != nil {
66 t.Fatalf("Init() error = %v", err)
67 }
68
69 if buildType := celer.BuildType(); buildType != "debug" {
70 t.Errorf("BuildType() = %v, want debug", buildType)
71 }
72 if jobs := celer.Jobs(); jobs != 4 {
73 t.Errorf("Jobs() = %v, want 4", jobs)
74 }
75}
76
77func TestCeler_Init_InvalidTOML(t *testing.T) {
78 // Prepare test environment.

Callers

nothing calls this directly

Calls 7

InitMethod · 0.95
BuildTypeMethod · 0.95
JobsMethod · 0.95
InitFunction · 0.92
NewCelerFunction · 0.85
MkdirAllMethod · 0.80
WriteFileMethod · 0.80

Tested by

no test coverage detected