createProjectWithTasks creates a project directory with .taskmd.yaml and task files.
(t *testing.T, taskDir string, tasks map[string]string)
| 34 | |
| 35 | // createProjectWithTasks creates a project directory with .taskmd.yaml and task files. |
| 36 | func createProjectWithTasks(t *testing.T, taskDir string, tasks map[string]string) string { |
| 37 | t.Helper() |
| 38 | projectDir := t.TempDir() |
| 39 | |
| 40 | tasksPath := filepath.Join(projectDir, taskDir) |
| 41 | if err := os.MkdirAll(tasksPath, 0755); err != nil { |
| 42 | t.Fatalf("failed to create tasks dir: %v", err) |
| 43 | } |
| 44 | |
| 45 | // Write .taskmd.yaml pointing to the task directory |
| 46 | configContent := "task-dir: " + taskDir + "\n" |
| 47 | if err := os.WriteFile(filepath.Join(projectDir, ".taskmd.yaml"), []byte(configContent), 0644); err != nil { |
| 48 | t.Fatalf("failed to write .taskmd.yaml: %v", err) |
| 49 | } |
| 50 | |
| 51 | for filename, content := range tasks { |
| 52 | if err := os.WriteFile(filepath.Join(tasksPath, filename), []byte(content), 0644); err != nil { |
| 53 | t.Fatalf("failed to create task file %s: %v", filename, err) |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | return projectDir |
| 58 | } |
| 59 | |
| 60 | func captureProjectsOutput(t *testing.T) (string, string, error) { |
| 61 | t.Helper() |
no outgoing calls
no test coverage detected