refactor: move all tests to backend/tests/ as black-box packages
All test files relocated from internal/X/ to tests/X/ and converted to package X_test, using only the public API of each package. - tests/auth/: jwt, service, handler integration tests - tests/middleware/: auth, request_id, recovery tests - tests/user/: calories, service, repository integration tests - tests/locale/: locale tests (already package locale_test, just moved) - tests/ingredient/: repository integration tests - tests/recipe/: repository integration tests mockUserRepo in tests/user/service_test.go redefined locally with fully-qualified user.* types. Unexported auth.refreshRequest replaced with a local testRefreshRequest struct in the integration test. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
36
backend/tests/recipe/repository_integration_test.go
Normal file
36
backend/tests/recipe/repository_integration_test.go
Normal file
@@ -0,0 +1,36 @@
|
||||
//go:build integration
|
||||
|
||||
package recipe_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/food-ai/backend/internal/recipe"
|
||||
"github.com/food-ai/backend/internal/testutil"
|
||||
)
|
||||
|
||||
func TestRecipeRepository_GetByID_NotFound(t *testing.T) {
|
||||
pool := testutil.SetupTestDB(t)
|
||||
repo := recipe.NewRepository(pool)
|
||||
ctx := context.Background()
|
||||
|
||||
got, getError := repo.GetByID(ctx, "00000000-0000-0000-0000-000000000000")
|
||||
if getError != nil {
|
||||
t.Fatalf("unexpected error: %v", getError)
|
||||
}
|
||||
if got != nil {
|
||||
t.Error("expected nil for non-existent ID")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRecipeRepository_Count(t *testing.T) {
|
||||
pool := testutil.SetupTestDB(t)
|
||||
repo := recipe.NewRepository(pool)
|
||||
ctx := context.Background()
|
||||
|
||||
_, countError := repo.Count(ctx)
|
||||
if countError != nil {
|
||||
t.Fatalf("count: %v", countError)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user