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

Function TestBuildLogsDataWithContinuation

pkg/cli/logs_json_test.go:632–720  ·  view source on GitHub ↗

TestBuildLogsDataWithContinuation tests continuation field in logs data

(t *testing.T)

Source from the content-addressed store, hash-verified

630
631// TestBuildLogsDataWithContinuation tests continuation field in logs data
632func TestBuildLogsDataWithContinuation(t *testing.T) {
633 tmpDir := testutil.TempDir(t, "test-*")
634
635 // Create sample processed runs
636 processedRuns := []ProcessedRun{
637 {
638 Run: WorkflowRun{
639 DatabaseID: 12345,
640 Number: 1,
641 WorkflowName: "Test Workflow",
642 Status: "completed",
643 Conclusion: "success",
644 CreatedAt: time.Date(2024, 1, 1, 12, 0, 0, 0, time.UTC),
645 URL: "https://github.com/test/repo/actions/runs/12345",
646 LogsPath: filepath.Join(tmpDir, "run-12345"),
647 },
648 },
649 {
650 Run: WorkflowRun{
651 DatabaseID: 12344,
652 Number: 2,
653 WorkflowName: "Test Workflow",
654 Status: "completed",
655 Conclusion: "success",
656 CreatedAt: time.Date(2024, 1, 2, 12, 0, 0, 0, time.UTC),
657 URL: "https://github.com/test/repo/actions/runs/12344",
658 LogsPath: filepath.Join(tmpDir, "run-12344"),
659 },
660 },
661 }
662
663 // Create continuation data (simulating timeout scenario)
664 continuation := &ContinuationData{
665 Message: "Timeout reached. Use these parameters to continue fetching more logs.",
666 WorkflowName: "Test Workflow",
667 Count: 100,
668 StartDate: "2024-01-01",
669 EndDate: "2024-12-31",
670 Engine: "copilot",
671 Branch: "main",
672 AfterRunID: 0,
673 BeforeRunID: 12344, // Continue from the oldest run
674 Timeout: 50,
675 }
676
677 // Build logs data with continuation
678 logsData := buildLogsData(processedRuns, tmpDir, continuation)
679
680 // Verify continuation field is present
681 if logsData.Continuation == nil {
682 t.Fatal("Expected continuation field to be present, got nil")
683 }
684
685 // Verify continuation data
686 if logsData.Continuation.Message != "Timeout reached. Use these parameters to continue fetching more logs." {
687 t.Errorf("Expected continuation message, got '%s'", logsData.Continuation.Message)
688 }
689 if logsData.Continuation.WorkflowName != "Test Workflow" {

Callers

nothing calls this directly

Calls 3

TempDirFunction · 0.92
buildLogsDataFunction · 0.85
ErrorfMethod · 0.45

Tested by

no test coverage detected