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

Function TestBuildLogsDataPreservesExplicitWorkflowPath

pkg/cli/logs_json_test.go:1014–1054  ·  view source on GitHub ↗

TestBuildLogsDataPreservesExplicitWorkflowPath verifies that an explicit WorkflowPath set by the GitHub API is never overwritten by the inference fallback.

(t *testing.T)

Source from the content-addressed store, hash-verified

1012// TestBuildLogsDataPreservesExplicitWorkflowPath verifies that an explicit WorkflowPath
1013// set by the GitHub API is never overwritten by the inference fallback.
1014func TestBuildLogsDataPreservesExplicitWorkflowPath(t *testing.T) {
1015 tmpDir := testutil.TempDir(t, "test-preserve-workflow-path-*")
1016
1017 explicitPath := ".github/workflows/custom-path.lock.yml"
1018 processedRun := ProcessedRun{
1019 Run: WorkflowRun{
1020 DatabaseID: 99902,
1021 WorkflowName: "Auto-Triage Issues",
1022 WorkflowPath: explicitPath,
1023 Status: "completed",
1024 Conclusion: "success",
1025 LogsPath: tmpDir,
1026 },
1027 }
1028
1029 // Write an aw_info.json with a different workflow_name to ensure it does not
1030 // overwrite the explicit path that came from the GitHub API.
1031 awInfoPath := filepath.Join(tmpDir, "aw_info.json")
1032 awInfoData := map[string]any{
1033 "engine_id": "copilot",
1034 "workflow_name": "Different Name",
1035 }
1036 awInfoBytes, err := json.Marshal(awInfoData)
1037 if err != nil {
1038 t.Fatalf("Failed to marshal aw_info.json content: %v", err)
1039 }
1040 if err := os.WriteFile(awInfoPath, awInfoBytes, 0644); err != nil {
1041 t.Fatalf("Failed to write aw_info.json: %v", err)
1042 }
1043
1044 logsData := buildLogsData([]ProcessedRun{processedRun}, tmpDir, nil)
1045
1046 if len(logsData.Runs) != 1 {
1047 t.Fatalf("Expected 1 run, got %d", len(logsData.Runs))
1048 }
1049
1050 got := logsData.Runs[0].WorkflowPath
1051 if got != explicitPath {
1052 t.Errorf("WorkflowPath = %q, want %q (explicit path must not be overwritten)", got, explicitPath)
1053 }
1054}

Callers

nothing calls this directly

Calls 3

TempDirFunction · 0.92
buildLogsDataFunction · 0.85
ErrorfMethod · 0.45

Tested by

no test coverage detected