TestBuildLogsDataRepositoryAndOrganizationFields verifies that repository and organization fields are populated on both RunData and EpisodeData from aw_info.json.
(t *testing.T)
| 817 | // TestBuildLogsDataRepositoryAndOrganizationFields verifies that repository and organization |
| 818 | // fields are populated on both RunData and EpisodeData from aw_info.json. |
| 819 | func TestBuildLogsDataRepositoryAndOrganizationFields(t *testing.T) { |
| 820 | tmpDir := testutil.TempDir(t, "test-repo-org-*") |
| 821 | runDir := filepath.Join(tmpDir, "run-9001") |
| 822 | |
| 823 | writeTestAwInfo(t, runDir, map[string]any{ |
| 824 | "engine_id": "copilot", |
| 825 | "repository": "myorg/myrepo", |
| 826 | "ref": "refs/heads/main", |
| 827 | "sha": "abc123", |
| 828 | "actor": "monalisa", |
| 829 | }) |
| 830 | |
| 831 | processedRuns := []ProcessedRun{ |
| 832 | { |
| 833 | Run: WorkflowRun{ |
| 834 | DatabaseID: 9001, |
| 835 | WorkflowName: "test-workflow", |
| 836 | WorkflowPath: ".github/workflows/test-workflow.yml", |
| 837 | Status: "completed", |
| 838 | Conclusion: "success", |
| 839 | CreatedAt: time.Date(2024, 3, 1, 10, 0, 0, 0, time.UTC), |
| 840 | StartedAt: time.Date(2024, 3, 1, 10, 0, 0, 0, time.UTC), |
| 841 | UpdatedAt: time.Date(2024, 3, 1, 10, 5, 0, 0, time.UTC), |
| 842 | LogsPath: runDir, |
| 843 | }, |
| 844 | }, |
| 845 | } |
| 846 | |
| 847 | logsData := buildLogsData(processedRuns, tmpDir, nil) |
| 848 | |
| 849 | // Verify RunData fields |
| 850 | if len(logsData.Runs) != 1 { |
| 851 | t.Fatalf("Expected 1 run, got %d", len(logsData.Runs)) |
| 852 | } |
| 853 | run := logsData.Runs[0] |
| 854 | if run.Repository != "myorg/myrepo" { |
| 855 | t.Errorf("Expected run.Repository 'myorg/myrepo', got %q", run.Repository) |
| 856 | } |
| 857 | if run.Organization != "myorg" { |
| 858 | t.Errorf("Expected run.Organization 'myorg', got %q", run.Organization) |
| 859 | } |
| 860 | |
| 861 | // Verify EpisodeData fields |
| 862 | if len(logsData.Episodes) != 1 { |
| 863 | t.Fatalf("Expected 1 episode, got %d", len(logsData.Episodes)) |
| 864 | } |
| 865 | episode := logsData.Episodes[0] |
| 866 | if episode.Repository != "myorg/myrepo" { |
| 867 | t.Errorf("Expected episode.Repository 'myorg/myrepo', got %q", episode.Repository) |
| 868 | } |
| 869 | if episode.Organization != "myorg" { |
| 870 | t.Errorf("Expected episode.Organization 'myorg', got %q", episode.Organization) |
| 871 | } |
| 872 | } |
| 873 | |
| 874 | // TestBuildLogsDataOrganizationEmptyWhenNoRepository verifies that organization is empty |
| 875 | // when no repository is set (e.g., older aw_info.json without repository field). |
nothing calls this directly
no test coverage detected