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

Function TestRefresher_NoProviderForOrigin

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

Source from the content-addressed store, hash-verified

253}
254
255func TestRefresher_NoProviderForOrigin(t *testing.T) {
256 t.Parallel()
257
258 providers := func(_ context.Context, _ string) gitprovider.Provider { return nil }
259 tokens := func(_ context.Context, _ uuid.UUID, _ string) (*string, error) {
260 return ptr.Ref("test-token"), nil
261 }
262
263 r := gitsync.NewRefresher(providers, tokens, slogtest.Make(t, nil), quartz.NewReal())
264
265 row := database.ChatDiffStatus{
266 ChatID: uuid.New(),
267 Url: sql.NullString{String: "https://example.com/pr/1", Valid: true},
268 GitRemoteOrigin: "https://example.com/org/repo",
269 GitBranch: "feature",
270 }
271
272 ownerID := uuid.New()
273 results, err := r.Refresh(context.Background(), []gitsync.RefreshRequest{
274 {Row: row, OwnerID: ownerID},
275 })
276 require.NoError(t, err)
277 require.Len(t, results, 1)
278 res := results[0]
279
280 assert.Nil(t, res.Params)
281 require.Error(t, res.Error)
282 assert.Contains(t, res.Error.Error(), "no provider")
283}
284
285func TestRefresher_TokenResolutionFails(t *testing.T) {
286 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