MCPcopy Create free account
hub / github.com/github/gh-aw / TestBuildLogsDataInfersWorkflowPathFromAwInfo

Function TestBuildLogsDataInfersWorkflowPathFromAwInfo

pkg/cli/logs_json_test.go:968–1010  ·  view source on GitHub ↗

TestBuildLogsDataInfersWorkflowPathFromAwInfo verifies that buildLogsData falls back to inferring workflow_path from aw_info.json when the GitHub API returned an empty path.

(t *testing.T)

Source from the content-addressed store, hash-verified

966// TestBuildLogsDataInfersWorkflowPathFromAwInfo verifies that buildLogsData falls back
967// to inferring workflow_path from aw_info.json when the GitHub API returned an empty path.
968func TestBuildLogsDataInfersWorkflowPathFromAwInfo(t *testing.T) {
969 tmpDir := testutil.TempDir(t, "test-infer-workflow-path-*")
970
971 // Create a run with an empty WorkflowPath (simulating what the GitHub API returns
972 // for scheduled/agentic workflow runs).
973 processedRun := ProcessedRun{
974 Run: WorkflowRun{
975 DatabaseID: 99901,
976 WorkflowName: "Auto-Triage Issues",
977 WorkflowPath: "", // empty — the bug scenario
978 Status: "completed",
979 Conclusion: "success",
980 LogsPath: tmpDir,
981 },
982 }
983
984 // Write an aw_info.json that contains the workflow display name.
985 awInfoPath := filepath.Join(tmpDir, "aw_info.json")
986 awInfoData := map[string]any{
987 "engine_id": "copilot",
988 "engine_name": "GitHub Copilot CLI",
989 "workflow_name": "Auto-Triage Issues",
990 }
991 awInfoBytes, err := json.Marshal(awInfoData)
992 if err != nil {
993 t.Fatalf("Failed to marshal aw_info: %v", err)
994 }
995 if err := os.WriteFile(awInfoPath, awInfoBytes, 0644); err != nil {
996 t.Fatalf("Failed to write aw_info.json: %v", err)
997 }
998
999 logsData := buildLogsData([]ProcessedRun{processedRun}, tmpDir, nil)
1000
1001 if len(logsData.Runs) != 1 {
1002 t.Fatalf("Expected 1 run, got %d", len(logsData.Runs))
1003 }
1004
1005 got := logsData.Runs[0].WorkflowPath
1006 want := ".github/workflows/auto-triage-issues.lock.yml"
1007 if got != want {
1008 t.Errorf("WorkflowPath = %q, want %q", got, want)
1009 }
1010}
1011
1012// TestBuildLogsDataPreservesExplicitWorkflowPath verifies that an explicit WorkflowPath
1013// set by the GitHub API is never overwritten by the inference fallback.

Callers

nothing calls this directly

Calls 3

TempDirFunction · 0.92
buildLogsDataFunction · 0.85
ErrorfMethod · 0.45

Tested by

no test coverage detected