MCPcopy Create free account
hub / github.com/gogs/gogs / loginSourcesSave

Function loginSourcesSave

internal/database/login_sources_test.go:455–496  ·  view source on GitHub ↗
(t *testing.T, ctx context.Context, s *LoginSourcesStore)

Source from the content-addressed store, hash-verified

453}
454
455func loginSourcesSave(t *testing.T, ctx context.Context, s *LoginSourcesStore) {
456 t.Run("save to database", func(t *testing.T) {
457 // Create a login source with name "GitHub"
458 source, err := s.Create(ctx,
459 CreateLoginSourceOptions{
460 Type: auth.GitHub,
461 Name: "GitHub",
462 Activated: true,
463 Default: false,
464 Config: &github.Config{
465 APIEndpoint: "https://api.github.com",
466 },
467 },
468 )
469 require.NoError(t, err)
470
471 source.IsActived = false
472 source.Provider = github.NewProvider(&github.Config{
473 APIEndpoint: "https://api2.github.com",
474 })
475 err = s.Save(ctx, source)
476 require.NoError(t, err)
477
478 source, err = s.GetByID(ctx, source.ID)
479 require.NoError(t, err)
480 assert.False(t, source.IsActived)
481 assert.Equal(t, "https://api2.github.com", source.GitHub().APIEndpoint)
482 })
483
484 t.Run("save to file", func(t *testing.T) {
485 mockFile := NewMockLoginSourceFileStore()
486 source := &LoginSource{
487 Provider: github.NewProvider(&github.Config{
488 APIEndpoint: "https://api.github.com",
489 }),
490 File: mockFile,
491 }
492 err := s.Save(ctx, source)
493 require.NoError(t, err)
494 mockrequire.Called(t, mockFile.SaveFunc)
495 })
496}

Callers

nothing calls this directly

Calls 6

GitHubMethod · 0.95
NewProviderFunction · 0.92
SaveMethod · 0.65
GetByIDMethod · 0.65
CreateMethod · 0.45

Tested by

no test coverage detected