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

Function TestRefresher_ProviderFetchFails

coderd/x/gitsync/gitsync_test.go:357–394  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

355}
356
357func TestRefresher_ProviderFetchFails(t *testing.T) {
358 t.Parallel()
359
360 mp := &mockProvider{
361 parsePullRequestURL: func(_ string) (gitprovider.PRRef, bool) {
362 return gitprovider.PRRef{Owner: "org", Repo: "repo", Number: 42}, true
363 },
364 fetchPullRequestStatus: func(_ context.Context, _ string, _ gitprovider.PRRef) (*gitprovider.PRStatus, error) {
365 return nil, errors.New("api error")
366 },
367 }
368
369 providers := func(_ context.Context, _ string) gitprovider.Provider { return mp }
370 tokens := func(_ context.Context, _ uuid.UUID, _ string) (*string, error) {
371 return ptr.Ref("test-token"), nil
372 }
373
374 r := gitsync.NewRefresher(providers, tokens, slogtest.Make(t, nil), quartz.NewReal())
375
376 row := database.ChatDiffStatus{
377 ChatID: uuid.New(),
378 Url: sql.NullString{String: "https://github.com/org/repo/pull/42", Valid: true},
379 GitRemoteOrigin: "https://github.com/org/repo",
380 GitBranch: "feature",
381 }
382
383 ownerID := uuid.New()
384 results, err := r.Refresh(context.Background(), []gitsync.RefreshRequest{
385 {Row: row, OwnerID: ownerID},
386 })
387 require.NoError(t, err)
388 require.Len(t, results, 1)
389 res := results[0]
390
391 assert.Nil(t, res.Params)
392 require.Error(t, res.Error)
393 assert.Contains(t, res.Error.Error(), "api error")
394}
395
396func TestRefresher_PRURLParseFailure(t *testing.T) {
397 t.Parallel()

Callers

nothing calls this directly

Calls 7

RefreshMethod · 0.95
RefFunction · 0.92
NewRefresherFunction · 0.92
NewMethod · 0.65
LenMethod · 0.45
ErrorMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected