(t *testing.T)
| 272 | } |
| 273 | |
| 274 | func TestContext_JSON(t *testing.T) { |
| 275 | tmpDir := createContextTestFiles(t) |
| 276 | resetContextFlags() |
| 277 | taskDir = tmpDir |
| 278 | setupTestConfig(t, tmpDir) |
| 279 | |
| 280 | ctxTaskID = "003" |
| 281 | ctxFormat = "json" |
| 282 | output, err := captureContextOutput(t) |
| 283 | if err != nil { |
| 284 | t.Fatalf("unexpected error: %v", err) |
| 285 | } |
| 286 | |
| 287 | var result taskcontext.Result |
| 288 | if err := json.Unmarshal([]byte(output), &result); err != nil { |
| 289 | t.Fatalf("failed to parse JSON: %v\nOutput: %s", err, output) |
| 290 | } |
| 291 | |
| 292 | if result.TaskID != "003" { |
| 293 | t.Errorf("expected task_id 003, got %s", result.TaskID) |
| 294 | } |
| 295 | if len(result.Files) < 2 { |
| 296 | t.Errorf("expected at least 2 files, got %d", len(result.Files)) |
| 297 | } |
| 298 | |
| 299 | // Check source tagging |
| 300 | foundScope := false |
| 301 | foundExplicit := false |
| 302 | for _, f := range result.Files { |
| 303 | if strings.HasPrefix(f.Source, "scope:") { |
| 304 | foundScope = true |
| 305 | } |
| 306 | if f.Source == "explicit" { |
| 307 | foundExplicit = true |
| 308 | } |
| 309 | } |
| 310 | if !foundScope { |
| 311 | t.Error("expected at least one scope-sourced file") |
| 312 | } |
| 313 | if !foundExplicit { |
| 314 | t.Error("expected at least one explicit-sourced file") |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | func TestContext_YAML(t *testing.T) { |
| 319 | tmpDir := createContextTestFiles(t) |
nothing calls this directly
no test coverage detected