feat: implement Iteration 0 foundation (backend + Flutter client)
Backend (Go): - Project structure with chi router, pgxpool, goose migrations - JWT auth (access/refresh tokens) with Firebase token verification - NoopTokenVerifier for local dev without Firebase credentials - PostgreSQL user repository with atomic profile updates (transactions) - Mifflin-St Jeor calorie calculation based on profile data - REST API: POST /auth/login, /auth/refresh, /auth/logout, GET/PUT /profile, GET /health - Middleware: auth, CORS (localhost wildcard), logging, recovery, request_id - Unit tests (51 passing) and integration tests (testcontainers) - Docker Compose setup with postgres healthcheck and graceful shutdown Flutter client: - Riverpod state management with GoRouter navigation - Firebase Auth (email/password + Google sign-in with web popup support) - Platform-aware API URLs (web/Android/iOS) - Dio HTTP client with JWT auth interceptor and concurrent refresh handling - Secure token storage - Screens: Login, Register, Home (tabs: Menu, Recipes, Products, Profile) - Unit tests (17 passing) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
46
backend/internal/user/mocks/repository.go
Normal file
46
backend/internal/user/mocks/repository.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package mocks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/food-ai/backend/internal/user"
|
||||
)
|
||||
|
||||
type MockUserRepository struct {
|
||||
UpsertByFirebaseUIDFn func(ctx context.Context, uid, email, name, avatarURL string) (*user.User, error)
|
||||
GetByIDFn func(ctx context.Context, id string) (*user.User, error)
|
||||
UpdateFn func(ctx context.Context, id string, req user.UpdateProfileRequest) (*user.User, error)
|
||||
UpdateInTxFn func(ctx context.Context, id string, profileReq user.UpdateProfileRequest, caloriesReq *user.UpdateProfileRequest) (*user.User, error)
|
||||
SetRefreshTokenFn func(ctx context.Context, id, token string, expiresAt time.Time) error
|
||||
FindByRefreshTokenFn func(ctx context.Context, token string) (*user.User, error)
|
||||
ClearRefreshTokenFn func(ctx context.Context, id string) error
|
||||
}
|
||||
|
||||
func (m *MockUserRepository) UpsertByFirebaseUID(ctx context.Context, uid, email, name, avatarURL string) (*user.User, error) {
|
||||
return m.UpsertByFirebaseUIDFn(ctx, uid, email, name, avatarURL)
|
||||
}
|
||||
|
||||
func (m *MockUserRepository) GetByID(ctx context.Context, id string) (*user.User, error) {
|
||||
return m.GetByIDFn(ctx, id)
|
||||
}
|
||||
|
||||
func (m *MockUserRepository) Update(ctx context.Context, id string, req user.UpdateProfileRequest) (*user.User, error) {
|
||||
return m.UpdateFn(ctx, id, req)
|
||||
}
|
||||
|
||||
func (m *MockUserRepository) UpdateInTx(ctx context.Context, id string, profileReq user.UpdateProfileRequest, caloriesReq *user.UpdateProfileRequest) (*user.User, error) {
|
||||
return m.UpdateInTxFn(ctx, id, profileReq, caloriesReq)
|
||||
}
|
||||
|
||||
func (m *MockUserRepository) SetRefreshToken(ctx context.Context, id, token string, expiresAt time.Time) error {
|
||||
return m.SetRefreshTokenFn(ctx, id, token, expiresAt)
|
||||
}
|
||||
|
||||
func (m *MockUserRepository) FindByRefreshToken(ctx context.Context, token string) (*user.User, error) {
|
||||
return m.FindByRefreshTokenFn(ctx, token)
|
||||
}
|
||||
|
||||
func (m *MockUserRepository) ClearRefreshToken(ctx context.Context, id string) error {
|
||||
return m.ClearRefreshTokenFn(ctx, id)
|
||||
}
|
||||
Reference in New Issue
Block a user