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

Function TestRefresher_EmptyToken

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

Source from the content-addressed store, hash-verified

324}
325
326func TestRefresher_EmptyToken(t *testing.T) {
327 t.Parallel()
328
329 mp := &mockProvider{}
330
331 providers := func(_ context.Context, _ string) gitprovider.Provider { return mp }
332 tokens := func(_ context.Context, _ uuid.UUID, _ string) (*string, error) {
333 return ptr.Ref(""), nil
334 }
335
336 r := gitsync.NewRefresher(providers, tokens, slogtest.Make(t, nil), quartz.NewReal())
337
338 row := database.ChatDiffStatus{
339 ChatID: uuid.New(),
340 Url: sql.NullString{String: "https://github.com/org/repo/pull/1", Valid: true},
341 GitRemoteOrigin: "https://github.com/org/repo",
342 GitBranch: "feature",
343 }
344
345 ownerID := uuid.New()
346 results, err := r.Refresh(context.Background(), []gitsync.RefreshRequest{
347 {Row: row, OwnerID: ownerID},
348 })
349 require.NoError(t, err)
350 require.Len(t, results, 1)
351 res := results[0]
352
353 assert.Nil(t, res.Params)
354 require.ErrorIs(t, res.Error, gitsync.ErrNoTokenAvailable)
355}
356
357func TestRefresher_ProviderFetchFails(t *testing.T) {
358 t.Parallel()

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected