MCPcopy Index your code
hub / github.com/coder/coder / TestRefreshChat_NoPR

Function TestRefreshChat_NoPR

coderd/x/gitsync/worker_test.go:1064–1102  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1062}
1063
1064func TestRefreshChat_NoPR(t *testing.T) {
1065 t.Parallel()
1066 ctx := testutil.Context(t, testutil.WaitShort)
1067
1068 chatID := uuid.New()
1069 ownerID := uuid.New()
1070
1071 row := database.ChatDiffStatus{
1072 ChatID: chatID,
1073 GitBranch: "feature",
1074 GitRemoteOrigin: "https://github.com/owner/repo",
1075 }
1076
1077 ctrl := gomock.NewController(t)
1078 store := dbmock.NewMockStore(ctrl)
1079 // UpsertChatDiffStatus should NOT be called.
1080
1081 var publishCalled atomic.Bool
1082 pub := func(_ context.Context, _ uuid.UUID) error {
1083 publishCalled.Store(true)
1084 return nil
1085 }
1086
1087 mClock := quartz.NewMock(t)
1088 logger := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true})
1089
1090 // ResolveBranchPullRequest returns nil → no PR exists yet.
1091 refresher := newTestRefresher(t, mClock, withResolveBranchPR(
1092 func(context.Context, string, gitprovider.BranchRef) (*gitprovider.PRRef, error) {
1093 return nil, nil
1094 },
1095 ))
1096 worker := gitsync.NewWorker(store, refresher, pub, mClock, logger)
1097
1098 result, err := worker.RefreshChat(ctx, row, ownerID)
1099 require.NoError(t, err)
1100 assert.Nil(t, result, "result should be nil when no PR exists")
1101 assert.False(t, publishCalled.Load(), "publish should not be called when no PR exists")
1102}
1103
1104func TestRefreshChat_RefreshError(t *testing.T) {
1105 t.Parallel()

Callers

nothing calls this directly

Calls 9

RefreshChatMethod · 0.95
ContextFunction · 0.92
NewMockStoreFunction · 0.92
NewWorkerFunction · 0.92
newTestRefresherFunction · 0.85
withResolveBranchPRFunction · 0.85
NewMethod · 0.65
StoreMethod · 0.45
LoadMethod · 0.45

Tested by

no test coverage detected