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

Function TestRefreshChat_RefreshError

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

Source from the content-addressed store, hash-verified

1102}
1103
1104func TestRefreshChat_RefreshError(t *testing.T) {
1105 t.Parallel()
1106 ctx := testutil.Context(t, testutil.WaitShort)
1107
1108 chatID := uuid.New()
1109 ownerID := uuid.New()
1110
1111 row := database.ChatDiffStatus{
1112 ChatID: chatID,
1113 Url: sql.NullString{String: "https://github.com/org/repo/pull/1", Valid: true},
1114 GitBranch: "feature",
1115 GitRemoteOrigin: "https://github.com/owner/repo",
1116 }
1117
1118 ctrl := gomock.NewController(t)
1119 store := dbmock.NewMockStore(ctrl)
1120 // UpsertChatDiffStatus should NOT be called.
1121
1122 // Provider resolver returns nil → "no provider" error.
1123 providers := func(context.Context, string) gitprovider.Provider { return nil }
1124 tokens := func(context.Context, uuid.UUID, string) (*string, error) {
1125 return ptr.Ref("tok"), nil
1126 }
1127
1128 mClock := quartz.NewMock(t)
1129 logger := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true})
1130 refresher := gitsync.NewRefresher(providers, tokens, logger, mClock)
1131 worker := gitsync.NewWorker(store, refresher, nil, mClock, logger)
1132
1133 result, err := worker.RefreshChat(ctx, row, ownerID)
1134 require.Error(t, err)
1135 assert.Contains(t, err.Error(), "no provider")
1136 assert.Nil(t, result)
1137}
1138
1139func TestRefreshChat_UpsertError(t *testing.T) {
1140 t.Parallel()

Callers

nothing calls this directly

Calls 9

RefreshChatMethod · 0.95
ContextFunction · 0.92
NewMockStoreFunction · 0.92
RefFunction · 0.92
NewRefresherFunction · 0.92
NewWorkerFunction · 0.92
NewMethod · 0.65
ErrorMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected