feat: backend core - auth, user, role, permission, device, webhook, monitoring, cache, repository, service, middleware, API handlers
2026-04-02 11:19:50 +08:00
|
|
|
//go:build integration
|
|
|
|
|
|
|
|
|
|
package repository
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"errors"
|
|
|
|
|
"testing"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"github.com/redis/go-redis/v9"
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
"github.com/stretchr/testify/suite"
|
test: add comprehensive test coverage and improve code quality
- Add new test files for auth, service, and handler modules
- Improve test organization and coverage
- Refactor code for better maintainability
- Add captcha, settings, stats, and theme handler tests
- Add auth module tests (CAS, OAuth, password, SSO, state)
- Add service layer tests for auth, export, permissions, roles
- All Go tests pass (exit code 0)
- All frontend tests pass (325 tests in 59 files)
2026-04-17 20:43:50 +08:00
|
|
|
"github.com/user-management-system/internal/service"
|
feat: backend core - auth, user, role, permission, device, webhook, monitoring, cache, repository, service, middleware, API handlers
2026-04-02 11:19:50 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type GeminiTokenCacheSuite struct {
|
|
|
|
|
IntegrationRedisSuite
|
|
|
|
|
cache service.GeminiTokenCache
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *GeminiTokenCacheSuite) SetupTest() {
|
|
|
|
|
s.IntegrationRedisSuite.SetupTest()
|
|
|
|
|
s.cache = NewGeminiTokenCache(s.rdb)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *GeminiTokenCacheSuite) TestDeleteAccessToken() {
|
|
|
|
|
cacheKey := "project-123"
|
|
|
|
|
token := "token-value"
|
|
|
|
|
require.NoError(s.T(), s.cache.SetAccessToken(s.ctx, cacheKey, token, time.Minute))
|
|
|
|
|
|
|
|
|
|
got, err := s.cache.GetAccessToken(s.ctx, cacheKey)
|
|
|
|
|
require.NoError(s.T(), err)
|
|
|
|
|
require.Equal(s.T(), token, got)
|
|
|
|
|
|
|
|
|
|
require.NoError(s.T(), s.cache.DeleteAccessToken(s.ctx, cacheKey))
|
|
|
|
|
|
|
|
|
|
_, err = s.cache.GetAccessToken(s.ctx, cacheKey)
|
|
|
|
|
require.True(s.T(), errors.Is(err, redis.Nil), "expected redis.Nil after delete")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *GeminiTokenCacheSuite) TestDeleteAccessToken_MissingKey() {
|
|
|
|
|
require.NoError(s.T(), s.cache.DeleteAccessToken(s.ctx, "missing-key"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestGeminiTokenCacheSuite(t *testing.T) {
|
|
|
|
|
suite.Run(t, new(GeminiTokenCacheSuite))
|
|
|
|
|
}
|