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

Function TestRefresher_PRURLParseFailure

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

Source from the content-addressed store, hash-verified

394}
395
396func TestRefresher_PRURLParseFailure(t *testing.T) {
397 t.Parallel()
398
399 mp := &mockProvider{
400 parsePullRequestURL: func(_ string) (gitprovider.PRRef, bool) {
401 return gitprovider.PRRef{}, false
402 },
403 }
404
405 providers := func(_ context.Context, _ string) gitprovider.Provider { return mp }
406 tokens := func(_ context.Context, _ uuid.UUID, _ string) (*string, error) {
407 return ptr.Ref("test-token"), nil
408 }
409
410 r := gitsync.NewRefresher(providers, tokens, slogtest.Make(t, nil), quartz.NewReal())
411
412 row := database.ChatDiffStatus{
413 ChatID: uuid.New(),
414 Url: sql.NullString{String: "https://github.com/org/repo/not-a-pr", Valid: true},
415 GitRemoteOrigin: "https://github.com/org/repo",
416 GitBranch: "feature",
417 }
418
419 ownerID := uuid.New()
420 results, err := r.Refresh(context.Background(), []gitsync.RefreshRequest{
421 {Row: row, OwnerID: ownerID},
422 })
423 require.NoError(t, err)
424 require.Len(t, results, 1)
425 res := results[0]
426
427 assert.Nil(t, res.Params)
428 require.Error(t, res.Error)
429}
430
431func TestRefresher_BatchGroupsByOwnerAndOrigin(t *testing.T) {
432 t.Parallel()

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected