(t *testing.T)
| 724 | } |
| 725 | |
| 726 | func TestWebSocketSubscribeAndReceiveChanges(t *testing.T) { |
| 727 | t.Parallel() |
| 728 | |
| 729 | ctx := testutil.Context(t, testutil.WaitLong) |
| 730 | repoDir := initTestRepo(t) |
| 731 | require.NoError(t, os.WriteFile(filepath.Join(repoDir, "ws.go"), []byte("package ws\n"), 0o600)) |
| 732 | |
| 733 | ps := agentgit.NewPathStore() |
| 734 | chatID := uuid.New() |
| 735 | |
| 736 | // Add paths before connecting so the handler picks them up on |
| 737 | // startup. |
| 738 | ps.AddPaths([]uuid.UUID{chatID}, []string{filepath.Join(repoDir, "ws.go")}) |
| 739 | |
| 740 | stream := dialGitWatchWithPathStore(t, ps, chatID) |
| 741 | ch := stream.Chan() |
| 742 | |
| 743 | msg := recvMsg(ctx, t, ch) |
| 744 | require.Equal(t, codersdk.WorkspaceAgentGitServerMessageTypeChanges, msg.Type) |
| 745 | require.NotNil(t, msg.ScannedAt) |
| 746 | require.NotEmpty(t, msg.Repositories) |
| 747 | require.Equal(t, repoDir, msg.Repositories[0].RepoRoot) |
| 748 | } |
| 749 | |
| 750 | func TestWebSocketMultipleRepos(t *testing.T) { |
| 751 | t.Parallel() |
nothing calls this directly
no test coverage detected