(t *testing.T)
| 1062 | } |
| 1063 | |
| 1064 | func 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 | |
| 1104 | func TestRefreshChat_RefreshError(t *testing.T) { |
| 1105 | t.Parallel() |
nothing calls this directly
no test coverage detected