| 10 | ) |
| 11 | |
| 12 | func TestCeler_Init_NewConfig(t *testing.T) { |
| 13 | tmpDir := t.TempDir() |
| 14 | dirs.Init(tmpDir) |
| 15 | celerPath := filepath.Join(tmpDir, "celer.toml") |
| 16 | |
| 17 | if fileio.PathExists(celerPath) { |
| 18 | t.Fatalf("celer.toml should not exist initially") |
| 19 | } |
| 20 | |
| 21 | // Test init. |
| 22 | celer := NewCeler() |
| 23 | if err := celer.Init(); err != nil { |
| 24 | t.Errorf("Init() error = %v", err) |
| 25 | } |
| 26 | |
| 27 | // Test cases. |
| 28 | if !fileio.PathExists(celerPath) { |
| 29 | t.Error("celer.toml should be created") |
| 30 | } |
| 31 | if buildType := celer.BuildType(); buildType != "release" { |
| 32 | t.Errorf("BuildType() = %v, want release", buildType) |
| 33 | } |
| 34 | if jobs := celer.Jobs(); jobs <= 0 { |
| 35 | t.Errorf("Jobs() = %v, want positive number", jobs) |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | func TestCeler_Init_ExistingConfig(t *testing.T) { |
| 40 | // Prepare test environment. |