(t *testing.T)
| 678 | } |
| 679 | |
| 680 | func TestExpMcpReporter(t *testing.T) { |
| 681 | t.Parallel() |
| 682 | |
| 683 | // Reading to / writing from the PTY is flaky on non-linux systems. |
| 684 | if runtime.GOOS != "linux" { |
| 685 | t.Skip("skipping on non-linux") |
| 686 | } |
| 687 | |
| 688 | t.Run("Error", func(t *testing.T) { |
| 689 | t.Parallel() |
| 690 | |
| 691 | ctx, cancel := context.WithCancel(testutil.Context(t, testutil.WaitShort)) |
| 692 | socketPath := testutil.AgentSocketPath(t) |
| 693 | inv, _ := clitest.New(t, |
| 694 | "exp", "mcp", "server", |
| 695 | "--socket-path", socketPath, |
| 696 | "--app-status-slug", "vscode", |
| 697 | "--ai-agentapi-url", "not a valid url", |
| 698 | ) |
| 699 | inv = inv.WithContext(ctx) |
| 700 | |
| 701 | pty := ptytest.New(t) |
| 702 | inv.Stdin = pty.Input() |
| 703 | inv.Stdout = pty.Output() |
| 704 | stderr := ptytest.New(t) |
| 705 | inv.Stderr = stderr.Output() |
| 706 | |
| 707 | cmdDone := make(chan struct{}) |
| 708 | go func() { |
| 709 | defer close(cmdDone) |
| 710 | err := inv.Run() |
| 711 | assert.Error(t, err) |
| 712 | }() |
| 713 | |
| 714 | stderr.ExpectMatch("Failed to connect to agent socket") |
| 715 | cancel() |
| 716 | <-cmdDone |
| 717 | }) |
| 718 | |
| 719 | makeStatusEvent := func(status agentapi.AgentStatus) *codersdk.ServerSentEvent { |
| 720 | return &codersdk.ServerSentEvent{ |
| 721 | Type: ServerSentEventTypeStatusChange, |
| 722 | Data: agentapi.EventStatusChange{ |
| 723 | Status: status, |
| 724 | }, |
| 725 | } |
| 726 | } |
| 727 | |
| 728 | makeMessageEvent := func(id int64, role agentapi.ConversationRole) *codersdk.ServerSentEvent { |
| 729 | return &codersdk.ServerSentEvent{ |
| 730 | Type: ServerSentEventTypeMessageUpdate, |
| 731 | Data: agentapi.EventMessageUpdate{ |
| 732 | Id: id, |
| 733 | Role: role, |
| 734 | }, |
| 735 | } |
| 736 | } |
| 737 |
nothing calls this directly
no test coverage detected