(t *testing.T)
| 531 | } |
| 532 | |
| 533 | func TestExtractEngineFromAwInfoNestedDirectory(t *testing.T) { |
| 534 | tmpDir := testutil.TempDir(t, "test-*") |
| 535 | |
| 536 | // Test Case 1: aw_info.json as a regular file |
| 537 | awInfoFile := filepath.Join(tmpDir, "aw_info.json") |
| 538 | awInfoContent := `{ |
| 539 | "engine_id": "claude", |
| 540 | "engine_name": "Claude", |
| 541 | "model": "claude-3-sonnet", |
| 542 | "version": "20240620", |
| 543 | "workflow_name": "Test Claude", |
| 544 | "experimental": false, |
| 545 | "supports_tools_allowlist": true, |
| 546 | "run_id": 123456789, |
| 547 | "run_number": 42, |
| 548 | "run_attempt": "1", |
| 549 | "repository": "github/gh-aw", |
| 550 | "ref": "refs/heads/main", |
| 551 | "sha": "abc123", |
| 552 | "actor": "testuser", |
| 553 | "event_name": "workflow_dispatch", |
| 554 | "created_at": "2025-08-13T13:36:39.704Z" |
| 555 | }` |
| 556 | |
| 557 | err := os.WriteFile(awInfoFile, []byte(awInfoContent), 0644) |
| 558 | if err != nil { |
| 559 | t.Fatalf("Failed to create aw_info.json file: %v", err) |
| 560 | } |
| 561 | |
| 562 | // Test regular file extraction |
| 563 | engine := extractEngineFromAwInfo(awInfoFile, true) |
| 564 | if engine == nil { |
| 565 | t.Errorf("Expected to extract engine from regular aw_info.json file, got nil") |
| 566 | } else if engine.GetID() != "claude" { |
| 567 | t.Errorf("Expected engine ID 'claude', got '%s'", engine.GetID()) |
| 568 | } |
| 569 | |
| 570 | // Clean up for next test |
| 571 | os.Remove(awInfoFile) |
| 572 | |
| 573 | // Test Case 2: aw_info.json as a directory containing the actual file |
| 574 | awInfoDir := filepath.Join(tmpDir, "aw_info.json") |
| 575 | err = os.Mkdir(awInfoDir, 0755) |
| 576 | if err != nil { |
| 577 | t.Fatalf("Failed to create aw_info.json directory: %v", err) |
| 578 | } |
| 579 | |
| 580 | // Create the nested aw_info.json file inside the directory |
| 581 | nestedAwInfoFile := filepath.Join(awInfoDir, "aw_info.json") |
| 582 | awInfoContentCodex := `{ |
| 583 | "engine_id": "codex", |
| 584 | "engine_name": "Codex", |
| 585 | "model": "o4-mini", |
| 586 | "version": "", |
| 587 | "workflow_name": "Test Codex", |
| 588 | "experimental": true, |
| 589 | "supports_tools_allowlist": true, |
| 590 | "run_id": 987654321, |
nothing calls this directly
no test coverage detected