From d959dcca96acd1ac6b3cd7329c123843b3c00c28 Mon Sep 17 00:00:00 2001 From: vallyenfail Date: Sat, 17 Jan 2026 17:39:33 +0300 Subject: [PATCH] add service --- .gitignore | 37 + DEPLOYMENT.md | 153 + Dockerfile | 32 + GRPC_SERVICES.md | 244 ++ Makefile | 78 + README.md | 152 +- TESTING.md | 309 ++ api/proto/auth/auth.proto | 50 + api/proto/invite/invite.proto | 36 + api/proto/request/request.proto | 61 + api/proto/supplier/supplier.proto | 18 + api/proto/user/user.proto | 51 + cmd/server/main.go | 88 + config/boot.yaml | 35 + config/config.yaml.example | 24 + docker-compose.yml | 41 + docker-entrypoint.sh | 16 + go.mod | 95 + go.sum | 677 +++++ internal/ai/openai.go | 193 ++ internal/ai/perplexity.go | 321 ++ internal/config/config.go | 111 + internal/database/migrations.go | 31 + internal/grpc/auth_handler.go | 70 + internal/grpc/invite_handler.go | 45 + internal/grpc/request_handler.go | 91 + internal/grpc/server.go | 78 + internal/grpc/supplier_handler.go | 29 + internal/grpc/user_handler.go | 66 + internal/mocks/auth_service_mock.go | 1578 ++++++++++ internal/mocks/invite_repository_mock.go | 1809 +++++++++++ internal/mocks/invite_service_mock.go | 836 ++++++ internal/mocks/request_repository_mock.go | 2647 +++++++++++++++++ internal/mocks/request_service_mock.go | 1581 ++++++++++ internal/mocks/session_repository_mock.go | 1839 ++++++++++++ internal/mocks/supplier_repository_mock.go | 1160 ++++++++ internal/mocks/supplier_service_mock.go | 418 +++ internal/mocks/token_usage_repository_mock.go | 417 +++ internal/mocks/user_repository_mock.go | 2582 ++++++++++++++++ internal/mocks/user_service_mock.go | 1130 +++++++ internal/model/invite.go | 14 + internal/model/request.go | 40 + internal/model/session.go | 15 + internal/model/supplier.go | 28 + internal/model/user.go | 18 + internal/repository/interfaces.go | 54 + internal/repository/invite.go | 146 + internal/repository/request.go | 209 ++ internal/repository/session.go | 134 + internal/repository/supplier.go | 97 + internal/repository/token_usage.go | 43 + internal/repository/user.go | 199 ++ internal/service/auth.go | 107 + internal/service/interfaces.go | 38 + internal/service/invite.go | 57 + internal/service/request.go | 154 + internal/service/supplier.go | 75 + internal/service/tests/auth_suite_test.go | 449 +++ internal/service/user.go | 83 + internal/worker/invite_cleaner.go | 69 + internal/worker/session_cleaner.go | 69 + migrations/00001_create_users.sql | 20 + migrations/00002_create_sessions.sql | 18 + migrations/00003_create_invite_codes.sql | 17 + migrations/00004_create_mailing_status.sql | 14 + .../00005_create_requests_for_suppliers.sql | 18 + migrations/00006_create_suppliers.sql | 16 + .../00007_create_request_token_usage.sql | 15 + pkg/crypto/crypto.go | 125 + pkg/errors/codes.go | 17 + pkg/errors/errors.go | 95 + pkg/jwt/jwt.go | 79 + pkg/pb/api/proto/auth/auth.pb.go | 538 ++++ pkg/pb/api/proto/auth/auth_grpc.pb.go | 235 ++ pkg/pb/api/proto/invite/invite.pb.go | 369 +++ pkg/pb/api/proto/invite/invite_grpc.pb.go | 159 + pkg/pb/api/proto/request/request.pb.go | 640 ++++ pkg/pb/api/proto/request/request_grpc.pb.go | 235 ++ pkg/pb/api/proto/supplier/supplier.pb.go | 201 ++ pkg/pb/api/proto/supplier/supplier_grpc.pb.go | 121 + pkg/pb/api/proto/user/user.pb.go | 548 ++++ pkg/pb/api/proto/user/user_grpc.pb.go | 235 ++ 82 files changed, 25041 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 DEPLOYMENT.md create mode 100644 Dockerfile create mode 100644 GRPC_SERVICES.md create mode 100644 Makefile create mode 100644 TESTING.md create mode 100644 api/proto/auth/auth.proto create mode 100644 api/proto/invite/invite.proto create mode 100644 api/proto/request/request.proto create mode 100644 api/proto/supplier/supplier.proto create mode 100644 api/proto/user/user.proto create mode 100644 cmd/server/main.go create mode 100644 config/boot.yaml create mode 100644 config/config.yaml.example create mode 100644 docker-compose.yml create mode 100755 docker-entrypoint.sh create mode 100644 go.mod create mode 100644 go.sum create mode 100644 internal/ai/openai.go create mode 100644 internal/ai/perplexity.go create mode 100644 internal/config/config.go create mode 100644 internal/database/migrations.go create mode 100644 internal/grpc/auth_handler.go create mode 100644 internal/grpc/invite_handler.go create mode 100644 internal/grpc/request_handler.go create mode 100644 internal/grpc/server.go create mode 100644 internal/grpc/supplier_handler.go create mode 100644 internal/grpc/user_handler.go create mode 100644 internal/mocks/auth_service_mock.go create mode 100644 internal/mocks/invite_repository_mock.go create mode 100644 internal/mocks/invite_service_mock.go create mode 100644 internal/mocks/request_repository_mock.go create mode 100644 internal/mocks/request_service_mock.go create mode 100644 internal/mocks/session_repository_mock.go create mode 100644 internal/mocks/supplier_repository_mock.go create mode 100644 internal/mocks/supplier_service_mock.go create mode 100644 internal/mocks/token_usage_repository_mock.go create mode 100644 internal/mocks/user_repository_mock.go create mode 100644 internal/mocks/user_service_mock.go create mode 100644 internal/model/invite.go create mode 100644 internal/model/request.go create mode 100644 internal/model/session.go create mode 100644 internal/model/supplier.go create mode 100644 internal/model/user.go create mode 100644 internal/repository/interfaces.go create mode 100644 internal/repository/invite.go create mode 100644 internal/repository/request.go create mode 100644 internal/repository/session.go create mode 100644 internal/repository/supplier.go create mode 100644 internal/repository/token_usage.go create mode 100644 internal/repository/user.go create mode 100644 internal/service/auth.go create mode 100644 internal/service/interfaces.go create mode 100644 internal/service/invite.go create mode 100644 internal/service/request.go create mode 100644 internal/service/supplier.go create mode 100644 internal/service/tests/auth_suite_test.go create mode 100644 internal/service/user.go create mode 100644 internal/worker/invite_cleaner.go create mode 100644 internal/worker/session_cleaner.go create mode 100644 migrations/00001_create_users.sql create mode 100644 migrations/00002_create_sessions.sql create mode 100644 migrations/00003_create_invite_codes.sql create mode 100644 migrations/00004_create_mailing_status.sql create mode 100644 migrations/00005_create_requests_for_suppliers.sql create mode 100644 migrations/00006_create_suppliers.sql create mode 100644 migrations/00007_create_request_token_usage.sql create mode 100644 pkg/crypto/crypto.go create mode 100644 pkg/errors/codes.go create mode 100644 pkg/errors/errors.go create mode 100644 pkg/jwt/jwt.go create mode 100644 pkg/pb/api/proto/auth/auth.pb.go create mode 100644 pkg/pb/api/proto/auth/auth_grpc.pb.go create mode 100644 pkg/pb/api/proto/invite/invite.pb.go create mode 100644 pkg/pb/api/proto/invite/invite_grpc.pb.go create mode 100644 pkg/pb/api/proto/request/request.pb.go create mode 100644 pkg/pb/api/proto/request/request_grpc.pb.go create mode 100644 pkg/pb/api/proto/supplier/supplier.pb.go create mode 100644 pkg/pb/api/proto/supplier/supplier_grpc.pb.go create mode 100644 pkg/pb/api/proto/user/user.pb.go create mode 100644 pkg/pb/api/proto/user/user_grpc.pb.go diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bce8fc2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,37 @@ +# Binaries +*.exe +*.exe~ +*.dll +*.so +*.dylib +bin/ +*.test +*.out + +# Go workspace file +go.work + +# Dependencies +vendor/ + +# IDE +.idea/ +.vscode/ +*.swp +*.swo +*~ + +# OS +.DS_Store +Thumbs.db + +# Config +config/config.yaml +!config/config.yaml.example + +# Logs +*.log + +# Build artifacts +/bin/ +/dist/ \ No newline at end of file diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md new file mode 100644 index 0000000..0fe96c2 --- /dev/null +++ b/DEPLOYMENT.md @@ -0,0 +1,153 @@ +# Инструкция по развертыванию + +## Архитектура + +Сервис построен на: +- **rk-boot** - фреймворк для микросервисов с автоматической конфигурацией gRPC, логированием, метриками и трейсингом +- **pgx/v5** - нативный высокопроизводительный драйвер PostgreSQL с connection pooling + +## Быстрый старт + +### 1. Установка goose для миграций + +```bash +go install github.com/pressly/goose/v3/cmd/goose@latest +``` + +### 2. Применение миграций + +```bash +# Экспортируйте DATABASE_URL или используйте напрямую +export DB_URL="postgres://postgres:password@localhost:5432/b2b_search?sslmode=disable" +make migrate-up +``` + +### 3. Настройка переменных окружения + +Создайте `.env` файл или экспортируйте переменные: + +```bash +export DB_HOST=localhost +export DB_PORT=5432 +export DB_NAME=b2b_search +export DB_USER=postgres +export DB_PASSWORD=password +export OPENAI_API_KEY=your-openai-key +export PERPLEXITY_API_KEY=your-perplexity-key +export GRPC_PORT=9091 +``` + +**🧪 Mock-режим для тестирования:** + +Если API ключи не указаны, сервис автоматически переключится в mock-режим: +- **OpenAI**: вернет структурированное mock ТЗ +- **Perplexity**: вернет 15 тестовых поставщиков + +Это позволяет тестировать сервис без реальных API ключей! + +```bash +# Запуск в mock-режиме (без API ключей) +make run +``` + +### 4. Запуск сервиса + +```bash +# Локальный запуск +make run + +# Или сборка и запуск +make build +./bin/server +``` + +## Docker Compose + +```bash +# Запуск всех сервисов +docker-compose up -d + +# Просмотр логов +docker-compose logs -f smart-search-service + +# Остановка +docker-compose down +``` + +## Миграции + +### Применить все миграции + +```bash +make migrate-up DB_URL="postgres://user:pass@host:5432/dbname?sslmode=disable" +``` + +### Откатить последнюю миграцию + +```bash +make migrate-down DB_URL="postgres://user:pass@host:5432/dbname?sslmode=disable" +``` + +### Создать новую миграцию + +```bash +make migrate-create name=add_new_field +``` + +## Структура БД + +После применения миграций будут созданы следующие таблицы: + +1. **users** - пользователи с зашифрованными PII полями +2. **sessions** - сессии с JWT токенами +3. **invite_codes** - инвайт-коды +4. **mailing_status** - статусы рассылки (pending, in_progress, completed, failed) +5. **requests_for_suppliers** - запросы на поставщиков +6. **suppliers** - найденные поставщики +7. **request_token_usage** - учет использования AI токенов + +## Background Workers + +Сервис автоматически запускает два фоновых процесса: + +- **Session Cleaner** - удаление истекших сессий (каждый час) +- **Invite Cleaner** - деактивация истекших инвайт-кодов (каждые 6 часов) + +## rk-boot Возможности + +Благодаря rk-boot сервис автоматически поддерживает: + +- **gRPC Server** - на порту 9091 +- **Логирование** - структурированные логи через zap +- **Метрики** - Prometheus метрики из коробки +- **Трейсинг** - распределенная трассировка запросов +- **Health Checks** - встроенные health endpoints +- **Graceful Shutdown** - корректное завершение работы + +## gRPC Сервисы + +Сервер запускается на порту 9091 и предоставляет следующие сервисы: + +- **AuthService** - аутентификация +- **UserService** - управление пользователями +- **InviteService** - управление инвайт-кодами +- **RequestService** - управление запросами +- **SupplierService** - экспорт поставщиков + +## Проверка работоспособности + +```bash +# Проверка соединения с БД +psql -h localhost -U postgres -d b2b_search -c "SELECT 1" + +# Проверка gRPC сервера (требует grpcurl) +grpcurl -plaintext localhost:9091 list +``` + +## Безопасность + +**ВАЖНО:** Секретные ключи для совместимости с существующим workflow: +- JWT Secret: `xM8KhJVkk28cIJeBo0306O2e6Ifni6tNVlcCMxDFAEc=` +- Crypto Secret: `xM8KhJVkk28cIJeBo0306O2e6Ifni6tNVlcCMxDFAEc=` + +В production окружении **обязательно смените** эти ключи! diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f92e5bd --- /dev/null +++ b/Dockerfile @@ -0,0 +1,32 @@ +FROM golang:1.23-alpine AS builder + +RUN apk add --no-cache git make protobuf-dev + +WORKDIR /app + +COPY go.mod go.sum ./ +ENV GOTOOLCHAIN=auto +RUN go mod download + +COPY . . + +RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o server cmd/server/main.go + +FROM alpine:latest + +RUN apk --no-cache add ca-certificates postgresql-client bash + +WORKDIR /root/ + +COPY --from=builder /app/server . +COPY --from=builder /app/migrations ./migrations +COPY --from=builder /app/config/boot.yaml ./config/boot.yaml +COPY --from=builder /app/config/config.yaml ./config/config.yaml +COPY --from=builder /app/docker-entrypoint.sh /docker-entrypoint.sh + +RUN chmod +x /docker-entrypoint.sh + +EXPOSE 9091 + +ENTRYPOINT ["/docker-entrypoint.sh"] +CMD ["./server"] diff --git a/GRPC_SERVICES.md b/GRPC_SERVICES.md new file mode 100644 index 0000000..43d9ed0 --- /dev/null +++ b/GRPC_SERVICES.md @@ -0,0 +1,244 @@ +# gRPC Services + +## Архитектура + +gRPC handlers разделены на отдельные структуры для каждого сервиса во избежание коллизий имён методов (например, `GetInfo` присутствует как в `UserService`, так и в `InviteService`). + +### Структура handlers + +``` +internal/grpc/ +├── server.go # Инициализация handlers и регистрация +├── auth_handler.go # AuthService gRPC методы +├── user_handler.go # UserService gRPC методы +├── invite_handler.go # InviteService gRPC методы +├── request_handler.go # RequestService gRPC методы +├── supplier_handler.go # SupplierService gRPC методы +└── error_mapper.go # Маппинг ошибок в gRPC статусы +``` + +## Сервисы + +### 1. AuthService + +**Proto:** `api/proto/auth/auth.proto` + +| Метод | Описание | +|-------|----------| +| `Login` | Аутентификация пользователя (email + password) | +| `Refresh` | Обновление access token по refresh token | +| `Validate` | Валидация access token | +| `Logout` | Выход (invalidate refresh token) | + +**Пример:** + +```go +// Login +req := &auth.LoginRequest{ + Email: "user@example.com", + Password: "password", + Ip: "127.0.0.1", + UserAgent: "MyApp/1.0", +} +resp, err := authClient.Login(ctx, req) +// resp.AccessToken, resp.RefreshToken +``` + +### 2. UserService + +**Proto:** `api/proto/user/user.proto` + +| Метод | Описание | +|-------|----------| +| `GetInfo` | Получить информацию о пользователе | +| `GetBalance` | Получить баланс | +| `GetStatistics` | Получить статистику заявок | +| `GetBalanceStatistics` | Комбинированная статистика баланса и заявок | + +**Пример:** + +```go +req := &user.GetInfoRequest{UserId: 123} +resp, err := userClient.GetInfo(ctx, req) +// resp.Email, resp.Name, resp.CompanyName... +``` + +### 3. InviteService + +**Proto:** `api/proto/invite/invite.proto` + +| Метод | Описание | +|-------|----------| +| `Generate` | Сгенерировать инвайт-код | +| `GetInfo` | Получить информацию об инвайт-коде | + +**Пример:** + +```go +req := &invite.GenerateRequest{ + UserId: 123, + TtlDays: 30, + MaxUses: 5, +} +resp, err := inviteClient.Generate(ctx, req) +// resp.Code, resp.ExpiresAt +``` + +### 4. RequestService + +**Proto:** `api/proto/request/request.proto` + +| Метод | Описание | +|-------|----------| +| `CreateTZ` | Создать заявку и сгенерировать ТЗ (AI) | +| `ApproveTZ` | Подтвердить ТЗ и найти поставщиков (AI) | +| `GetMailingList` | Получить список заявок пользователя | +| `GetMailingListByID` | Получить детали конкретной заявки | + +**Особенности:** + +- `CreateTZ`: поддерживает опциональные `file_data` и `file_name` для прикрепления файлов +- `ApproveTZ`: запускает поиск поставщиков через Perplexity API + +**Пример:** + +```go +// Создание ТЗ +req := &request.CreateTZRequest{ + UserId: 123, + RequestTxt: "Нужны поставщики автозапчастей", + FileData: fileBytes, // опционально + FileName: "specs.pdf", // опционально +} +resp, err := requestClient.CreateTZ(ctx, req) +// resp.RequestId, resp.TzText (сгенерировано AI) + +// Подтверждение ТЗ +approveReq := &request.ApproveTZRequest{ + RequestId: resp.RequestId, + FinalTz: "Отредактированное ТЗ", + UserId: 123, +} +approveResp, err := requestClient.ApproveTZ(ctx, approveReq) +// approveResp.MailingStatus (поставщики найдены) +``` + +### 5. SupplierService + +**Proto:** `api/proto/supplier/supplier.proto` + +| Метод | Описание | +|-------|----------| +| `ExportExcel` | Экспортировать список поставщиков в Excel | + +**Пример:** + +```go +req := &supplier.ExportExcelRequest{ + RequestId: "uuid-string", + UserId: 123, +} +resp, err := supplierClient.ExportExcel(ctx, req) +// resp.FileData, resp.FileName, resp.MimeType +``` + +## Обработка ошибок + +Все ошибки из service layer автоматически мапятся в gRPC статусы через `errors.ToGRPCError()`: + +| Код ошибки | gRPC Status | +|------------|-------------| +| `AUTH_INVALID_CREDENTIALS` | `Unauthenticated` | +| `AUTH_INVALID_TOKEN` | `Unauthenticated` | +| `USER_NOT_FOUND` | `NotFound` | +| `REQUEST_NOT_FOUND` | `NotFound` | +| `INVITE_LIMIT_REACHED` | `ResourceExhausted` | +| `INSUFFICIENT_BALANCE` | `FailedPrecondition` | +| Внутренние ошибки | `Internal` (без деталей) | + +## Регистрация сервисов + +В `cmd/server/main.go`: + +```go +authHandler, userHandler, inviteHandler, requestHandler, supplierHandler := + grpcServer.NewHandlers(pool, openAIKey, perplexityKey) + +grpcEntry.AddRegFuncGrpc(func(s *grpc.Server) { + grpcServer.RegisterServices(s, + authHandler, userHandler, inviteHandler, + requestHandler, supplierHandler) +}) +``` + +## Context Flow + +``` +gRPC Request → Handler(ctx) → Service(ctx) → Repository(ctx) → pgx(ctx) +``` + +Все gRPC handlers принимают `context.Context` из gRPC request и прокидывают его через все слои. + +## Тестирование + +Для тестирования gRPC методов можно использовать: + +### 1. grpcurl (CLI) + +```bash +# Получить список сервисов +grpcurl -plaintext localhost:9091 list + +# Вызвать метод +grpcurl -plaintext \ + -d '{"email":"user@example.com","password":"password","ip":"127.0.0.1","user_agent":"test"}' \ + localhost:9091 auth.AuthService/Login +``` + +### 2. Unit тесты с моками + +```go +// Создать mock service +mockRequestService := &mockRequestService{ + createTZFunc: func(ctx context.Context, userID int, txt string) (uuid.UUID, string, error) { + return uuid.New(), "Mock TZ", nil + }, +} + +// Создать handler с mock +handler := &grpc.RequestHandler{ + requestService: mockRequestService, +} + +// Тестировать +resp, err := handler.CreateTZ(ctx, &request.CreateTZRequest{...}) +``` + +## Метрики и трейсинг + +Все gRPC методы автоматически отслеживаются через `rk-boot`: + +- **Метрики**: запросы, ошибки, latency +- **Трейсинг**: distributed tracing через OpenTelemetry +- **Логирование**: все запросы логируются с request ID + +Доступно на: +- Метрики: `http://localhost:9091/metrics` +- Health: `http://localhost:9091/health` + +## Reflection + +gRPC Reflection включен в `config/boot.yaml`, что позволяет использовать `grpcurl` и другие инструменты без .proto файлов: + +```yaml +grpc: + - name: smart-search-service + enableReflection: true +``` + +## Статистика + +- **Всего gRPC методов**: 16 +- **Всего handlers**: 5 +- **Строк кода handlers**: ~371 +- **Proto файлов**: 5 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b77ff55 --- /dev/null +++ b/Makefile @@ -0,0 +1,78 @@ +.PHONY: help build run migrate-up migrate-down migrate-create lint test proto clean + +help: + @echo "Available commands:" + @echo " make build - Build the service" + @echo " make run - Run the service" + @echo " make migrate-up - Apply migrations" + @echo " make migrate-down - Rollback migrations" + @echo " make migrate-create - Create new migration (usage: make migrate-create name=migration_name)" + @echo " make lint - Run golangci-lint" + @echo " make proto - Generate proto files" + @echo " make generate-mock - Generate mocks for all interfaces (minimock)" + @echo " make test - Run tests" + @echo " make clean - Clean build artifacts" + +build: + @echo "Building server..." + @mkdir -p bin + go build -o bin/server cmd/server/main.go + @echo "Build complete: bin/server" + +run: + @echo "Running server..." + go run cmd/server/main.go + +migrate-up: + @echo "Applying migrations..." + goose -dir migrations postgres "$(DB_URL)" up + +migrate-down: + @echo "Rolling back migrations..." + goose -dir migrations postgres "$(DB_URL)" down + +migrate-create: + @echo "Creating migration: $(name)" + goose -dir migrations create $(name) sql + +lint: + @echo "Running linter..." + golangci-lint run ./... + +proto: + @echo "Generating proto files..." + @mkdir -p pkg/pb + @find api/proto -name "*.proto" -exec protoc --go_out=pkg/pb --go_opt=paths=source_relative --go-grpc_out=pkg/pb --go-grpc_opt=paths=source_relative {} \; + @echo "Proto generation complete" + +clean: + @echo "Cleaning build artifacts..." + rm -rf bin/ + @echo "Clean complete" + +.PHONY: generate-mock +generate-mock: + @echo "Generating mocks for repository interfaces..." + @mkdir -p internal/mocks + @cd internal/repository && \ + go run github.com/gojuno/minimock/v3/cmd/minimock@latest -i UserRepository -o ../mocks -p mocks -s "_mock.go" && \ + go run github.com/gojuno/minimock/v3/cmd/minimock@latest -i SessionRepository -o ../mocks -p mocks -s "_mock.go" && \ + go run github.com/gojuno/minimock/v3/cmd/minimock@latest -i InviteRepository -o ../mocks -p mocks -s "_mock.go" && \ + go run github.com/gojuno/minimock/v3/cmd/minimock@latest -i RequestRepository -o ../mocks -p mocks -s "_mock.go" && \ + go run github.com/gojuno/minimock/v3/cmd/minimock@latest -i SupplierRepository -o ../mocks -p mocks -s "_mock.go" && \ + go run github.com/gojuno/minimock/v3/cmd/minimock@latest -i TokenUsageRepository -o ../mocks -p mocks -s "_mock.go" + @echo "Generating mocks for service interfaces..." + @cd internal/service && \ + go run github.com/gojuno/minimock/v3/cmd/minimock@latest -i AuthService -o ../mocks -p mocks -s "_mock.go" && \ + go run github.com/gojuno/minimock/v3/cmd/minimock@latest -i UserService -o ../mocks -p mocks -s "_mock.go" && \ + go run github.com/gojuno/minimock/v3/cmd/minimock@latest -i InviteService -o ../mocks -p mocks -s "_mock.go" && \ + go run github.com/gojuno/minimock/v3/cmd/minimock@latest -i RequestService -o ../mocks -p mocks -s "_mock.go" && \ + go run github.com/gojuno/minimock/v3/cmd/minimock@latest -i SupplierService -o ../mocks -p mocks -s "_mock.go" + @echo "Mocks generated in internal/mocks/" + +test: + @echo "Running tests..." + go test -v ./... + +# Default DB URL for local development +DB_URL ?= postgres://postgres:password@localhost:5432/b2b_search?sslmode=disable diff --git a/README.md b/README.md index e107c88..8bc0e35 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,152 @@ -# smart-search-back +# Smart Search Backend Service +Backend микросервис для системы поиска поставщиков с AI интеграцией. + +## Технологии + +- **Go 1.21+** - основной язык +- **rk-boot** - фреймворк для микросервисов (автоматическая настройка gRPC, логирование, метрики) +- **PostgreSQL 15** - база данных +- **pgx/v5** - нативный драйвер PostgreSQL (высокая производительность) +- **gRPC** - межсервисное взаимодействие +- **Squirrel** - SQL query builder +- **Goose** - миграции БД +- **JWT (HS256)** - аутентификация +- **AES-256-GCM** - шифрование PII данных +- **OpenAI API** - генерация ТЗ (gpt-4o-mini) +- **Perplexity API** - поиск поставщиков + +### rk-boot + pgx + +Сервис использует комбинацию rk-boot и pgx: + +**rk-boot** обеспечивает: +- ✅ Автоматическое управление gRPC сервером +- ✅ Структурированное логирование (zap) +- ✅ Prometheus метрики +- ✅ Distributed tracing +- ✅ Health checks +- ✅ Graceful shutdown + +**pgx/v5** обеспечивает: +- ✅ Нативный драйвер PostgreSQL (в 2-3 раза быстрее database/sql) +- ✅ Connection pooling из коробки +- ✅ Batch operations +- ✅ Prepared statements +- ✅ Context support + +### gRPC Services + +**5 gRPC сервисов с 16 методами**: +- `AuthService` - аутентификация (Login, Refresh, Validate, Logout) +- `UserService` - информация о пользователе и статистика +- `InviteService` - управление инвайт-кодами +- `RequestService` - создание и управление заявками с AI +- `SupplierService` - экспорт данных поставщиков + +Подробнее: [GRPC_SERVICES.md](GRPC_SERVICES.md) + +## Структура проекта + +``` +smart-search-back/ +├── cmd/server/ # Точка входа +├── internal/ # Внутренняя логика +│ ├── grpc/ # gRPC server +│ ├── service/ # Бизнес-логика +│ ├── repository/ # Слой данных +│ ├── model/ # Domain модели +│ ├── worker/ # Background workers +│ └── ai/ # AI интеграция +├── api/proto/ # Proto файлы (только .proto) +├── migrations/ # SQL миграции +├── pkg/ # Общие утилиты +│ ├── pb/ # Сгенерированные proto файлы +│ ├── crypto/ # Шифрование +│ ├── jwt/ # JWT токены +│ └── errors/ # Обработка ошибок +└── config/ # Конфигурация + +## Установка + +```bash +# Установить зависимости +go mod download + +# Применить миграции +make migrate-up + +# Запустить сервис +make run +``` + +### 🧪 Mock-режим + +Для тестирования без реальных API ключей сервис поддерживает mock-режим: + +- Если `OPENAI_API_KEY` не указан → возвращается тестовое ТЗ +- Если `PERPLEXITY_API_KEY` не указан → возвращается 15 mock поставщиков + +Просто запустите без экспорта API ключей: +```bash +make run # Mock-режим активируется автоматически +``` + +## Миграции + +```bash +# Применить миграции +make migrate-up + +# Откатить миграции +make migrate-down +``` + +## Разработка + +```bash +# Запустить линтер +make lint + +# Сгенерировать proto файлы +make proto + +# Собрать проект +make build + +# Запустить тесты +go test ./... + +# С покрытием +go test ./... -cover +``` + +### Тестирование + +Проект полностью подготовлен для тестирования: + +- ✅ **Интерфейсы** для всех репозиториев и сервисов +- ✅ **Context** создается один раз в `main.go` и прокидывается через все слои +- ✅ **Приватные структуры** возвращают публичные интерфейсы +- ✅ **Примеры тестов** с моками в `internal/service/tests/` +- ✅ **Graceful shutdown** через context cancellation + +Подробнее см. [TESTING.md](TESTING.md) + +## Docker + +```bash +# Запустить все сервисы +docker-compose up -d +``` + +## API + +gRPC сервер запускается на порту 9091. + +Доступные сервисы: +- AuthService - аутентификация +- UserService - управление пользователями +- InviteService - инвайт-коды +- RequestService - запросы на поставщиков +- SupplierService - экспорт поставщиков diff --git a/TESTING.md b/TESTING.md new file mode 100644 index 0000000..05a0234 --- /dev/null +++ b/TESTING.md @@ -0,0 +1,309 @@ +# Руководство по тестированию + +## Архитектура для тестирования + +Проект спроектирован с учетом тестируемости: + +### ✅ Интерфейсы для всех слоев + +**Repository интерфейсы** (`internal/repository/interfaces.go`): +```go +type UserRepository interface { + FindByEmailHash(ctx context.Context, emailHash string) (*model.User, error) + FindByID(ctx context.Context, userID int) (*model.User, error) + Create(ctx context.Context, user *model.User) error + // ... +} +``` + +**Service интерфейсы** (`internal/service/interfaces.go`): +```go +type AuthService interface { + Login(ctx context.Context, email, password, ip, userAgent string) (string, string, error) + Refresh(ctx context.Context, refreshToken string) (string, error) + // ... +} +``` + +### ✅ Context пробрасывается через все слои + +``` +main.go (ctx) → Workers (ctx) → gRPC Handler (ctx) → Service (ctx) → Repository (ctx) → pgx +``` + +**Правило**: `context.Background()` создается **только один раз** в `main.go` и прокидывается через все компоненты. + +Это позволяет: +- **Graceful shutdown**: при отмене context все workers и операции останавливаются +- Отменять долгие операции +- Передавать метаданные (trace ID, user ID) +- Контролировать таймауты +- Избежать потерянных goroutines + +## Автоматическая генерация моков + +Проект использует [minimock](https://github.com/gojuno/minimock) для автоматической генерации типизированных моков из интерфейсов. + +### Генерация моков + +Все моки генерируются в `internal/mocks/` одной командой: + +```bash +make generate-mock +``` + +Эта команда генерирует моки для всех интерфейсов: +- **Repository интерфейсы**: `UserRepository`, `SessionRepository`, `InviteRepository`, `RequestRepository`, `SupplierRepository`, `TokenUsageRepository` +- **Service интерфейсы**: `AuthService`, `UserService`, `InviteService`, `RequestService`, `SupplierService` + +### Использование сгенерированных моков + +```go +import ( + "testing" + "context" + "smart-search-back/internal/mocks" + "smart-search-back/internal/service" + "smart-search-back/internal/model" + "github.com/stretchr/testify/assert" +) + +func TestAuthService_Login_Success(t *testing.T) { + // Создаем моки + mockUserRepo := mocks.NewUserRepositoryMock(t) + mockSessionRepo := mocks.NewSessionRepositoryMock(t) + + // Настраиваем поведение мока + mockUserRepo.FindByEmailHashMock.Expect(context.Background(), "email_hash").Return(&model.User{ + ID: 1, + PasswordHash: "b109f3bbbc244eb82441917ed06d618b9008dd09b3befd1b5e07394c706a8bb980b1d7785e5976ec049b46df5f1326af5a2ea6d103fd07c95385ffab0cacbc86", + }, nil) + + mockSessionRepo.CreateMock.Expect(context.Background(), &model.Session{}).Return(nil) + + // Создаем сервис с моками + authService := service.NewAuthService(mockUserRepo, mockSessionRepo) + + // Выполняем тест + accessToken, refreshToken, err := authService.Login( + context.Background(), + "test@example.com", + "password", + "127.0.0.1", + "test-agent", + ) + + // Проверяем результат + assert.NoError(t, err) + assert.NotEmpty(t, accessToken) + assert.NotEmpty(t, refreshToken) + + // Minimock автоматически проверит что все ожидания выполнены +} +``` + +### Преимущества minimock + +✅ **Типобезопасность** - моки генерируются из интерфейсов, ошибки компиляции при изменении сигнатур +✅ **Автоматическая проверка** - проверяет что все ожидания выполнены +✅ **Счетчики вызовов** - можно проверить сколько раз был вызван метод +✅ **Inspection** - можно проверить аргументы вызовов +✅ **Minimal boilerplate** - не нужно писать моки вручную + +### Пример с проверкой вызовов + +```go +func TestUserService_GetBalance(t *testing.T) { + mockUserRepo := mocks.NewUserRepositoryMock(t) + + // Ожидаем вызов GetBalance с userID=123 + mockUserRepo.GetBalanceMock.Expect(context.Background(), 123).Return(100.50, nil) + + userService := service.NewUserService(mockUserRepo, nil) + balance, err := userService.GetBalance(context.Background(), 123) + + assert.NoError(t, err) + assert.Equal(t, 100.50, balance) + + // Minimock автоматически проверит: + // - что GetBalance был вызван ровно 1 раз + // - с правильными аргументами + // - и вернул правильное значение +} +``` + +### Ручные моки (legacy пример) + +Для сравнения, старый пример с ручными моками (все еще работает, но не рекомендуется): + +```go +// Mock репозитория (legacy - используйте minimock!) +type mockUserRepo struct { + findByEmailHashFunc func(ctx context.Context, emailHash string) (*model.User, error) +} + +func (m *mockUserRepo) FindByEmailHash(ctx context.Context, emailHash string) (*model.User, error) { + if m.findByEmailHashFunc != nil { + return m.findByEmailHashFunc(ctx, emailHash) + } + return nil, nil +} +``` + +## Запуск тестов + +```bash +# Все тесты +go test ./... + +# С покрытием +go test ./... -cover + +# Verbose режим +go test ./... -v + +# Конкретный пакет +go test ./internal/service/tests/... + +# С race detector +go test ./... -race +``` + +## Использование minimock + +Проект использует [minimock](https://github.com/gojuno/minimock) для автоматической генерации типизированных моков. + +### Генерация моков + +Все моки генерируются в `internal/mocks/`: + +```bash +make generate-mock +``` + +Генерируются моки для всех интерфейсов: +- **Repository**: `UserRepository`, `SessionRepository`, `InviteRepository`, `RequestRepository`, `SupplierRepository`, `TokenUsageRepository` +- **Service**: `AuthService`, `UserService`, `InviteService`, `RequestService`, `SupplierService` + +### Использование сгенерированных моков + +```go +import "smart-search-back/internal/mocks" + +func TestAuthService_Login(t *testing.T) { + mockUserRepo := mocks.NewUserRepositoryMock(t) + mockSessionRepo := mocks.NewSessionRepositoryMock(t) + + mockUserRepo.FindByEmailHashMock.Expect(ctx, "hash").Return(&model.User{...}, nil) + + authService := service.NewAuthService(mockUserRepo, mockSessionRepo) + // ... тест +} +``` + +Подробнее см. раздел "Автоматическая генерация моков" выше. + +## Структура тестов + +``` +internal/ +├── service/ +│ ├── auth.go +│ ├── interfaces.go # Интерфейсы сервисов +│ └── tests/ +│ └── auth_test.go # Тесты с моками +├── repository/ +│ ├── user.go +│ ├── interfaces.go # Интерфейсы репозиториев +│ └── tests/ +│ └── user_test.go +``` + +## Best Practices + +### 1. Используйте context.Background() в тестах + +```go +ctx := context.Background() +result, err := service.SomeMethod(ctx, params) +``` + +### 2. Мокайте только то, что нужно + +```go +mockRepo := &mockUserRepo{ + findByIDFunc: func(ctx context.Context, id int) (*model.User, error) { + return &model.User{ID: id}, nil + }, + // Остальные методы можно не реализовывать если не используются +} +``` + +### 3. Проверяйте вызовы + +```go +var called bool +mockRepo := &mockUserRepo{ + createFunc: func(ctx context.Context, user *model.User) error { + called = true + assert.Equal(t, "expected@email.com", user.Email) + return nil + }, +} + +// ... вызов сервиса + +assert.True(t, called, "Create should have been called") +``` + +### 4. Тестируйте ошибки + +```go +mockRepo := &mockUserRepo{ + findByIDFunc: func(ctx context.Context, id int) (*model.User, error) { + return nil, errors.NewBusinessError(errors.UserNotFound, "user not found") + }, +} + +result, err := service.GetUser(ctx, 123) +assert.Error(t, err) +assert.Nil(t, result) +``` + +## Integration тесты + +Для integration тестов с реальной БД можно использовать testcontainers: + +```go +func TestUserRepository_Integration(t *testing.T) { + // Создать testcontainer с PostgreSQL + // Применить миграции + // Запустить тесты +} +``` + +## CI/CD + +```yaml +# .github/workflows/test.yml +name: Tests +on: [push, pull_request] +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: 1.21 + - run: go test ./... -race -cover +``` + +## Хэши для тестов + +При тестировании аутентификации используйте правильные хэши: + +- Пароль: `"password"` +- SHA512 хэш: `"b109f3bbbc244eb82441917ed06d618b9008dd09b3befd1b5e07394c706a8bb980b1d7785e5976ec049b46df5f1326af5a2ea6d103fd07c95385ffab0cacbc86"` + +Или используйте `crypto.PasswordHash("password")` прямо в тестах. diff --git a/api/proto/auth/auth.proto b/api/proto/auth/auth.proto new file mode 100644 index 0000000..fca54e0 --- /dev/null +++ b/api/proto/auth/auth.proto @@ -0,0 +1,50 @@ +syntax = "proto3"; +package auth; +option go_package = "github.com/smart-search-gateway/api/proto/auth/auth"; + +service AuthService { + rpc Login(LoginRequest) returns (LoginResponse); + rpc Refresh(RefreshRequest) returns (RefreshResponse); + rpc Validate(ValidateRequest) returns (ValidateResponse); + rpc Logout(LogoutRequest) returns (LogoutResponse); +} + +message LoginRequest { + string email = 1; + string password = 2; + string ip = 3; + string user_agent = 4; +} + +message LoginResponse { + string access_token = 1; + string refresh_token = 2; +} + +message RefreshRequest { + string refresh_token = 1; + string ip = 2; + string user_agent = 3; +} + +message RefreshResponse { + string access_token = 1; + string refresh_token = 2; +} + +message ValidateRequest { + string access_token = 1; +} + +message ValidateResponse { + bool valid = 1; + int64 user_id = 2; +} + +message LogoutRequest { + string access_token = 1; +} + +message LogoutResponse { + bool success = 1; +} diff --git a/api/proto/invite/invite.proto b/api/proto/invite/invite.proto new file mode 100644 index 0000000..4a5cce3 --- /dev/null +++ b/api/proto/invite/invite.proto @@ -0,0 +1,36 @@ +syntax = "proto3"; +package invite; +option go_package = "github.com/smart-search-gateway/api/proto/invite/invite"; + +import "google/protobuf/timestamp.proto"; + +service InviteService { + rpc Generate(GenerateRequest) returns (GenerateResponse); + rpc GetInfo(GetInfoRequest) returns (GetInfoResponse); +} + +message GenerateRequest { + int64 user_id = 1; + int32 ttl_days = 2; + int32 max_uses = 3; +} + +message GenerateResponse { + string code = 1; + int32 max_uses = 2; + google.protobuf.Timestamp expires_at = 3; +} + +message GetInfoRequest { + string code = 1; +} + +message GetInfoResponse { + string code = 1; + int64 user_id = 2; + int32 can_be_used_count = 3; + int32 used_count = 4; + google.protobuf.Timestamp expires_at = 5; + bool is_active = 6; + google.protobuf.Timestamp created_at = 7; +} diff --git a/api/proto/request/request.proto b/api/proto/request/request.proto new file mode 100644 index 0000000..4ef0adf --- /dev/null +++ b/api/proto/request/request.proto @@ -0,0 +1,61 @@ +syntax = "proto3"; +package request; +option go_package = "github.com/smart-search-gateway/api/proto/request/request"; + +import "google/protobuf/timestamp.proto"; + +service RequestService { + rpc CreateTZ(CreateTZRequest) returns (CreateTZResponse); + rpc ApproveTZ(ApproveTZRequest) returns (ApproveTZResponse); + rpc GetMailingList(GetMailingListRequest) returns (GetMailingListResponse); + rpc GetMailingListByID(GetMailingListByIDRequest) returns (GetMailingListByIDResponse); +} + +message CreateTZRequest { + int64 user_id = 1; + string request_txt = 2; + bytes file_data = 3; + string file_name = 4; +} + +message CreateTZResponse { + string request_id = 1; + string tz_text = 2; +} + +message ApproveTZRequest { + string request_id = 1; + string final_tz = 2; + int64 user_id = 3; +} + +message ApproveTZResponse { + bool success = 1; + string mailing_status = 2; +} + +message GetMailingListRequest { + int64 user_id = 1; +} + +message GetMailingListResponse { + repeated MailingItem items = 1; +} + +message GetMailingListByIDRequest { + string request_id = 1; + int64 user_id = 2; +} + +message GetMailingListByIDResponse { + MailingItem item = 1; +} + +message MailingItem { + string request_id = 1; + string request_txt = 2; + string final_tz = 3; + string mailing_status = 4; + google.protobuf.Timestamp created_at = 5; + int32 suppliers_found = 6; +} diff --git a/api/proto/supplier/supplier.proto b/api/proto/supplier/supplier.proto new file mode 100644 index 0000000..484bd8e --- /dev/null +++ b/api/proto/supplier/supplier.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; +package supplier; +option go_package = "github.com/smart-search-gateway/api/proto/supplier/supplier"; + +service SupplierService { + rpc ExportExcel(ExportExcelRequest) returns (ExportExcelResponse); +} + +message ExportExcelRequest { + string request_id = 1; + int64 user_id = 2; +} + +message ExportExcelResponse { + bytes file_data = 1; + string file_name = 2; + string mime_type = 3; +} diff --git a/api/proto/user/user.proto b/api/proto/user/user.proto new file mode 100644 index 0000000..d505160 --- /dev/null +++ b/api/proto/user/user.proto @@ -0,0 +1,51 @@ +syntax = "proto3"; +package user; +option go_package = "github.com/smart-search-gateway/api/proto/user/user"; + +service UserService { + rpc GetInfo(GetInfoRequest) returns (GetInfoResponse); + rpc GetBalance(GetBalanceRequest) returns (GetBalanceResponse); + rpc GetStatistics(GetStatisticsRequest) returns (GetStatisticsResponse); + rpc GetBalanceStatistics(GetBalanceStatisticsRequest) returns (GetBalanceStatisticsResponse); +} + +message GetInfoRequest { + int64 user_id = 1; +} + +message GetInfoResponse { + string email = 1; + string name = 2; + string phone = 3; + string company_name = 4; + string payment_status = 5; +} + +message GetBalanceRequest { + int64 user_id = 1; +} + +message GetBalanceResponse { + double balance = 1; +} + +message GetStatisticsRequest { + int64 user_id = 1; +} + +message GetStatisticsResponse { + int32 total_requests = 1; + int32 successful_requests = 2; + int32 failed_requests = 3; + double total_spent = 4; +} + +message GetBalanceStatisticsRequest { + int64 user_id = 1; +} + +message GetBalanceStatisticsResponse { + double balance = 1; + int32 total_requests = 2; + double total_spent = 3; +} diff --git a/cmd/server/main.go b/cmd/server/main.go new file mode 100644 index 0000000..8e22013 --- /dev/null +++ b/cmd/server/main.go @@ -0,0 +1,88 @@ +package main + +import ( + "context" + "log" + + "github.com/jackc/pgx/v5/pgxpool" + _ "github.com/jackc/pgx/v5/stdlib" + rkboot "github.com/rookie-ninja/rk-boot/v2" + "github.com/rookie-ninja/rk-entry/v2/entry" + rkgrpc "github.com/rookie-ninja/rk-grpc/v2/boot" + "google.golang.org/grpc" + + "smart-search-back/internal/config" + "smart-search-back/internal/database" + grpcServer "smart-search-back/internal/grpc" + "smart-search-back/internal/repository" + "smart-search-back/internal/worker" +) + +func main() { + cfg, err := config.Load("config/config.yaml") + if err != nil { + log.Fatalf("Failed to load config: %v", err) + } + + boot := rkboot.NewBoot(rkboot.WithBootConfigPath("config/boot.yaml", nil)) + + ctx := context.Background() + boot.Bootstrap(ctx) + + grpcEntry := rkgrpc.GetGrpcEntry("smart-search-service") + if grpcEntry == nil { + log.Fatal("Failed to get gRPC entry from rk-boot") + } + + loggerEntry := rkentry.GlobalAppCtx.GetLoggerEntry("smart-search-service") + if loggerEntry == nil { + loggerEntry = rkentry.GlobalAppCtx.GetLoggerEntryDefault() + } + logger := loggerEntry.Logger + + if err := database.RunMigrations(cfg.DatabaseURL()); err != nil { + log.Fatalf("Failed to run migrations: %v", err) + } + + pool, err := pgxpool.New(ctx, cfg.DatabaseURL()) + if err != nil { + log.Fatalf("Failed to connect to database: %v", err) + } + defer pool.Close() + + if err := pool.Ping(ctx); err != nil { + log.Fatalf("Failed to ping database: %v", err) + } + + log.Println("Successfully connected to database") + + sessionRepo := repository.NewSessionRepository(pool) + inviteRepo := repository.NewInviteRepository(pool) + + sessionCleaner := worker.NewSessionCleaner(ctx, sessionRepo) + sessionCleaner.Start() + defer sessionCleaner.Stop() + + inviteCleaner := worker.NewInviteCleaner(ctx, inviteRepo) + inviteCleaner.Start() + defer inviteCleaner.Stop() + + authHandler, userHandler, inviteHandler, requestHandler, supplierHandler := grpcServer.NewHandlers( + pool, + cfg.Security.JWTSecret, + cfg.Security.CryptoSecret, + cfg.AI.OpenAIKey, + cfg.AI.PerplexityKey, + logger, + ) + + grpcEntry.AddRegFuncGrpc(func(s *grpc.Server) { + grpcServer.RegisterServices(s, authHandler, userHandler, inviteHandler, requestHandler, supplierHandler) + }) + + log.Println("gRPC server started via rk-boot on port 9091") + + boot.WaitForShutdownSig(ctx) + + log.Println("Server stopped gracefully") +} diff --git a/config/boot.yaml b/config/boot.yaml new file mode 100644 index 0000000..da5e9e0 --- /dev/null +++ b/config/boot.yaml @@ -0,0 +1,35 @@ +--- +logger: + - name: smart-search-logger + description: "Application logger for smart-search service" + default: true + zap: + level: error + development: false + encoding: console + outputPaths: ["stdout"] + errorOutputPaths: ["stderr"] + disableCaller: false + disableStacktrace: false + +grpc: + - name: smart-search-service + port: 9091 + enabled: true + enableReflection: true + enableRkGwOption: true + loggerEntry: smart-search-logger + eventEntry: smart-search-logger + middleware: + logging: + enabled: true + loggerEncoding: "console" + loggerOutputPaths: ["stdout"] + meta: + enabled: true + trace: + enabled: true + prometheus: + enabled: true + auth: + enabled: false diff --git a/config/config.yaml.example b/config/config.yaml.example new file mode 100644 index 0000000..d130da5 --- /dev/null +++ b/config/config.yaml.example @@ -0,0 +1,24 @@ +database: + host: ${DB_HOST:localhost} + port: ${DB_PORT:5432} + name: ${DB_NAME:b2b_search} + user: ${DB_USER:postgres} + password: ${DB_PASSWORD:password} + ssl_mode: ${DB_SSL_MODE:disable} + max_conns: ${DB_MAX_CONNS:25} + min_conns: ${DB_MIN_CONNS:5} + +ai: + openai_key: ${OPENAI_API_KEY:} + perplexity_key: ${PERPLEXITY_API_KEY:} + +security: + jwt_secret: ${JWT_SECRET:xM8KhJVkk28cIJeBo0306O2e6Ifni6tNVlcCMxDFAEc=} + crypto_secret: ${CRYPTO_SECRET:xM8KhJVkk28cIJeBo0306O2e6Ifni6tNVlcCMxDFAEc=} + +grpc: + port: ${GRPC_PORT:9091} + max_connections: ${GRPC_MAX_CONNS:100} + +logging: + level: ${LOG_LEVEL:info} diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..1752ead --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,41 @@ +version: '3.8' + +services: + postgres: + image: postgres:15-alpine + container_name: smart-search-postgres + environment: + POSTGRES_DB: b2b_search + POSTGRES_USER: postgres + POSTGRES_PASSWORD: password + ports: + - "5432:5432" + volumes: + - postgres_data:/var/lib/postgresql/data + healthcheck: + test: ["CMD-SHELL", "pg_isready -U postgres"] + interval: 10s + timeout: 5s + retries: 5 + + smart-search-service: + build: . + container_name: smart-search-service + ports: + - "9091:9091" + depends_on: + postgres: + condition: service_healthy + environment: + DB_HOST: postgres + DB_PORT: 5432 + DB_NAME: b2b_search + DB_USER: postgres + DB_PASSWORD: password + OPENAI_API_KEY: ${OPENAI_API_KEY} + PERPLEXITY_API_KEY: ${PERPLEXITY_API_KEY} + GRPC_PORT: 9091 + restart: unless-stopped + +volumes: + postgres_data: diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100755 index 0000000..4868e7f --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,16 @@ +#!/bin/sh +set -e + +echo "=== Smart Search Backend Entrypoint ===" + +# Wait for database to be ready +echo "Waiting for database to be ready..." +until PGPASSWORD=$DB_PASSWORD psql -h "$DB_HOST" -U "$DB_USER" -d "$DB_NAME" -c '\q' 2>/dev/null; do + echo "Database is unavailable - sleeping" + sleep 2 +done + +echo "Database is ready!" + +echo "Starting server..." +exec "$@" diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..2a49f6a --- /dev/null +++ b/go.mod @@ -0,0 +1,95 @@ +module smart-search-back + +go 1.24.0 + +require ( + github.com/Masterminds/squirrel v1.5.4 + github.com/gojuno/minimock/v3 v3.4.7 + github.com/golang-jwt/jwt/v5 v5.3.0 + github.com/google/uuid v1.6.0 + github.com/jackc/pgx/v5 v5.8.0 + github.com/rookie-ninja/rk-boot/v2 v2.2.22 + github.com/rookie-ninja/rk-entry/v2 v2.2.22 + github.com/rookie-ninja/rk-grpc/v2 v2.2.22 + github.com/stretchr/testify v1.11.1 + github.com/xuri/excelize/v2 v2.10.0 + go.uber.org/zap v1.27.1 + google.golang.org/grpc v1.78.0 + google.golang.org/protobuf v1.36.11 +) + +require ( + github.com/benbjohnson/clock v1.3.0 // indirect + github.com/beorn7/perks v1.0.1 // indirect + github.com/cenkalti/backoff/v4 v4.2.1 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect + github.com/fsnotify/fsnotify v1.9.0 // indirect + github.com/go-logr/logr v1.4.3 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/go-viper/mapstructure/v2 v2.5.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.2 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 // indirect + github.com/improbable-eng/grpc-web v0.15.0 // indirect + github.com/jackc/pgpassfile v1.0.0 // indirect + github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect + github.com/jackc/puddle/v2 v2.2.2 // indirect + github.com/klauspost/compress v1.18.0 // indirect + github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect + github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect + github.com/mfridman/interpolate v0.0.2 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/openzipkin/zipkin-go v0.4.2 // indirect + github.com/pelletier/go-toml/v2 v2.2.4 // indirect + github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect + github.com/pressly/goose/v3 v3.26.0 // indirect + github.com/prometheus/client_golang v1.23.2 // indirect + github.com/prometheus/client_model v0.6.2 // indirect + github.com/prometheus/common v0.67.5 // indirect + github.com/prometheus/procfs v0.19.2 // indirect + github.com/richardlehane/mscfb v1.0.4 // indirect + github.com/richardlehane/msoleps v1.0.4 // indirect + github.com/rookie-ninja/rk-logger v1.2.13 // indirect + github.com/rookie-ninja/rk-query v1.2.14 // indirect + github.com/rs/cors v1.7.0 // indirect + github.com/sagikazarmark/locafero v0.12.0 // indirect + github.com/sethvargo/go-retry v0.3.0 // indirect + github.com/soheilhy/cmux v0.1.5 // indirect + github.com/spf13/afero v1.15.0 // indirect + github.com/spf13/cast v1.10.0 // indirect + github.com/spf13/pflag v1.0.10 // indirect + github.com/spf13/viper v1.21.0 // indirect + github.com/subosito/gotenv v1.6.0 // indirect + github.com/tiendc/go-deepcopy v1.7.1 // indirect + github.com/xuri/efp v0.0.1 // indirect + github.com/xuri/nfp v0.0.2-0.20250530014748-2ddeb826f9a9 // indirect + go.opentelemetry.io/auto/sdk v1.2.1 // indirect + go.opentelemetry.io/contrib v1.19.0 // indirect + go.opentelemetry.io/otel v1.38.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.18.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.18.0 // indirect + go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.18.0 // indirect + go.opentelemetry.io/otel/exporters/zipkin v1.18.0 // indirect + go.opentelemetry.io/otel/metric v1.38.0 // indirect + go.opentelemetry.io/otel/sdk v1.38.0 // indirect + go.opentelemetry.io/otel/trace v1.38.0 // indirect + go.opentelemetry.io/proto/otlp v1.0.0 // indirect + go.uber.org/atomic v1.11.0 // indirect + go.uber.org/multierr v1.11.0 // indirect + go.uber.org/ratelimit v0.3.0 // indirect + go.yaml.in/yaml/v2 v2.4.3 // indirect + go.yaml.in/yaml/v3 v3.0.4 // indirect + golang.org/x/crypto v0.47.0 // indirect + golang.org/x/net v0.49.0 // indirect + golang.org/x/sync v0.19.0 // indirect + golang.org/x/sys v0.40.0 // indirect + golang.org/x/text v0.33.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20251029180050-ab9386a59fda // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20260114163908-3f89685c29c3 // indirect + gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect + nhooyr.io/websocket v1.8.6 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..3e2f8d9 --- /dev/null +++ b/go.sum @@ -0,0 +1,677 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= +github.com/Masterminds/squirrel v1.5.4 h1:uUcX/aBc8O7Fg9kaISIUsHXdKuqehiXAMQTYX8afzqM= +github.com/Masterminds/squirrel v1.5.4/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA400rg+riTZj10= +github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= +github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= +github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= +github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= +github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= +github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= +github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= +github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= +github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= +github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= +github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= +github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= +github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= +github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= +github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= +github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= +github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= +github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= +github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= +github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= +github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f h1:U5y3Y5UE0w7amNe7Z5G/twsBW0KEalRQXZzf8ufSh9I= +github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f/go.mod h1:xH/i4TFMt8koVQZ6WFms69WAsDWr2XsYL3Hkl7jkoLE= +github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= +github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= +github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= +github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= +github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= +github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= +github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= +github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k= +github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= +github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= +github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14= +github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= +github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= +github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= +github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= +github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= +github.com/go-playground/validator/v10 v10.2.0 h1:KgJ0snyC2R9VXYN2rneOtQcw5aHQB1Vv0sFl1UcHBOY= +github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= +github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/go-viper/mapstructure/v2 v2.5.0 h1:vM5IJoUAy3d7zRSVtIwQgBj7BiWtMPfmPEgAXnvj1Ro= +github.com/go-viper/mapstructure/v2 v2.5.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= +github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0= +github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= +github.com/gobwas/pool v0.2.0 h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8= +github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= +github.com/gobwas/ws v1.0.2 h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo= +github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= +github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= +github.com/gojuno/minimock/v3 v3.4.7 h1:vhE5zpniyPDRT0DXd5s3DbtZJVlcbmC5k80izYtj9lY= +github.com/gojuno/minimock/v3 v3.4.7/go.mod h1:QxJk4mdPrVyYUmEZGc2yD2NONpqM/j4dWhsy9twjFHg= +github.com/golang-jwt/jwt/v4 v4.5.2 h1:YtQM7lnr8iZ+j5q71MGKkNw9Mn7AjHM68uc9g5fXeUI= +github.com/golang-jwt/jwt/v4 v4.5.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo= +github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/glog v1.2.5 h1:DrW6hGnjIhtvhOIiAKT6Psh/Kd/ldepEa81DKeiRJ5I= +github.com/golang/glog v1.2.5/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= +github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= +github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM= +github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +github.com/grpc-ecosystem/go-grpc-middleware v1.2.2/go.mod h1:EaizFBKfUKtMIF5iaDEhniwNedqGo9FuLFzppDr3uwI= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= +github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 h1:RtRsiaGvWxcwd8y3BiRZxsylPT8hLWZ5SPcfI+3IDNk= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0/go.mod h1:TzP6duP4Py2pHLVPPQp42aoYI92+PCrVotyR5e8Vqlk= +github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= +github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= +github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= +github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= +github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= +github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= +github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= +github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= +github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= +github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= +github.com/improbable-eng/grpc-web v0.15.0 h1:BN+7z6uNXZ1tQGcNAuaU1YjsLTApzkjt2tzCixLaUPQ= +github.com/improbable-eng/grpc-web v0.15.0/go.mod h1:1sy9HKV4Jt9aEs9JSnkWlRJPuPtwNr0l57L4f878wP8= +github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= +github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= +github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= +github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo= +github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= +github.com/jackc/pgx/v5 v5.8.0 h1:TYPDoleBBme0xGSAX3/+NujXXtpZn9HBONkQC7IEZSo= +github.com/jackc/pgx/v5 v5.8.0/go.mod h1:QVeDInX2m9VyzvNeiCJVjCkNFqzsNb43204HshNSZKw= +github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo= +github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= +github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= +github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= +github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= +github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= +github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo= +github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 h1:SOEGU9fKiNWd/HOJuq6+3iTQz8KNCLtVX6idSoTLdUw= +github.com/lann/builder v0.0.0-20180802200727-47ae307949d0/go.mod h1:dXGbAdH5GtBTC4WfIxhKZfyBF/HBFgRZSWwZ9g/He9o= +github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 h1:P6pPBnrTSX3DEVR4fDembhRWSsG5rVo6hYhAB/ADZrk= +github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0/go.mod h1:vmVJ0l/dxyfGW6FmdpVm2joNMFikkuWg0EoCKLGUMNw= +github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= +github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= +github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= +github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= +github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= +github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/mfridman/interpolate v0.0.2 h1:pnuTK7MQIxxFz1Gr+rjSIx9u7qVjf5VOoM/u6BbAxPY= +github.com/mfridman/interpolate v0.0.2/go.mod h1:p+7uk6oE07mpE/Ik1b8EckO0O4ZXiGAfshKBWLUM9Xg= +github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= +github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= +github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= +github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= +github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= +github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU= +github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/mwitkow/grpc-proxy v0.0.0-20181017164139-0f1106ef9c76/go.mod h1:x5OoJHDHqxHS801UIuhqGl6QdSAEJvtausosHSdazIo= +github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= +github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU= +github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k= +github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w= +github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= +github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= +github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= +github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= +github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= +github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= +github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= +github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= +github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxSfWAKL3wpBW7V8scJMt8N8gnaMCS9E/cA= +github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= +github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= +github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= +github.com/openzipkin/zipkin-go v0.4.2 h1:zjqfqHjUpPmB3c1GlCvvgsM1G4LkvqQbBDueDOCg/jA= +github.com/openzipkin/zipkin-go v0.4.2/go.mod h1:ZeVkFjuuBiSy13y8vpSDCjMi9GoI3hPpCJSBx/EYFhY= +github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= +github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= +github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4= +github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY= +github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= +github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= +github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= +github.com/pressly/goose/v3 v3.26.0 h1:KJakav68jdH0WDvoAcj8+n61WqOIaPGgH0bJWS6jpmM= +github.com/pressly/goose/v3 v3.26.0/go.mod h1:4hC1KrritdCxtuFsqgs1R4AU5bWtTAf+cnWvfhf2DNY= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= +github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= +github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= +github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= +github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h0RJWRi/o0o= +github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.1.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk= +github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE= +github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= +github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= +github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= +github.com/prometheus/common v0.67.5 h1:pIgK94WWlQt1WLwAC5j2ynLaBRDiinoAb86HZHTUGI4= +github.com/prometheus/common v0.67.5/go.mod h1:SjE/0MzDEEAyrdr5Gqc6G+sXI67maCxzaT3A2+HqjUw= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= +github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= +github.com/prometheus/procfs v0.3.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= +github.com/prometheus/procfs v0.19.2 h1:zUMhqEW66Ex7OXIiDkll3tl9a1ZdilUOd/F6ZXw4Vws= +github.com/prometheus/procfs v0.19.2/go.mod h1:M0aotyiemPhBCM0z5w87kL22CxfcH05ZpYlu+b4J7mw= +github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= +github.com/richardlehane/mscfb v1.0.4 h1:WULscsljNPConisD5hR0+OyZjwK46Pfyr6mPu5ZawpM= +github.com/richardlehane/mscfb v1.0.4/go.mod h1:YzVpcZg9czvAuhk9T+a3avCpcFPMUWm7gK3DypaEsUk= +github.com/richardlehane/msoleps v1.0.1/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg= +github.com/richardlehane/msoleps v1.0.4 h1:WuESlvhX3gH2IHcd8UqyCuFY5yiq/GR/yqaSM/9/g00= +github.com/richardlehane/msoleps v1.0.4/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg= +github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= +github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= +github.com/rookie-ninja/rk-boot/v2 v2.2.22 h1:JeDO1iibJGYNEi19czLq4xTVJW2eAsIwi0n8B3r+TEQ= +github.com/rookie-ninja/rk-boot/v2 v2.2.22/go.mod h1:vSWXUxJT7xVNZzrhy/r/wsQ+fjKLWQw6BaZJIHbQXNE= +github.com/rookie-ninja/rk-entry/v2 v2.2.22 h1:kYXhLV22APPxd9h6kLtA5Vf/tswPOw2Rth2X3NlUi7E= +github.com/rookie-ninja/rk-entry/v2 v2.2.22/go.mod h1:ZvSdFFG2HuJDmDuZP2ljh/0RiuMt/hjUs5p+n54W56Q= +github.com/rookie-ninja/rk-grpc/v2 v2.2.22 h1:prPnZ6GDFejWgAP63CAEEyk6GFSyJsGF9T6fK1+x1hs= +github.com/rookie-ninja/rk-grpc/v2 v2.2.22/go.mod h1:zNEHf1NTb16OoA7gkTisINqOxfNwqmlH6IUR3cpJg0k= +github.com/rookie-ninja/rk-logger v1.2.13 h1:ERxeNZUmszlY4xehHcJRXECPtbjYIXzN8yRIyYyLGsg= +github.com/rookie-ninja/rk-logger v1.2.13/go.mod h1:0ZiGn1KsHKOmCv+FHMH7k40DWYSJcj5yIR3EYcjlnLs= +github.com/rookie-ninja/rk-query v1.2.14 h1:aYNyMXixpsEYRfEOz9Npt5QG3A6BQlo9vKjYc78x7bc= +github.com/rookie-ninja/rk-query v1.2.14/go.mod h1:OG4rBizXsBjGp+gbyWNTeQogJLzZGUZWkV9QeHEj1ZU= +github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= +github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= +github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/sagikazarmark/locafero v0.12.0 h1:/NQhBAkUb4+fH1jivKHWusDYFjMOOKU88eegjfxfHb4= +github.com/sagikazarmark/locafero v0.12.0/go.mod h1:sZh36u/YSZ918v0Io+U9ogLYQJ9tLLBmM4eneO6WwsI= +github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= +github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= +github.com/sethvargo/go-retry v0.3.0 h1:EEt31A35QhrcRZtrYFDTBg91cqZVnFL2navjDrah2SE= +github.com/sethvargo/go-retry v0.3.0/go.mod h1:mNX17F0C/HguQMyMyJxcnU471gOZGxCLyYaFyAZraas= +github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= +github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= +github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= +github.com/soheilhy/cmux v0.1.5 h1:jjzc5WVemNEDTLwv9tlmemhC73tI08BNOIGwBOo10Js= +github.com/soheilhy/cmux v0.1.5/go.mod h1:T7TcVDs9LWfQgPlPsdngu6I6QIoyIFZDDC6sNE1GqG0= +github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY= +github.com/spf13/afero v1.15.0 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I= +github.com/spf13/afero v1.15.0/go.mod h1:NC2ByUVxtQs4b3sIUphxK0NioZnmxgyCrfzeuq8lxMg= +github.com/spf13/cast v1.10.0 h1:h2x0u2shc1QuLHfxi+cTJvs30+ZAHOGRic8uyGTDWxY= +github.com/spf13/cast v1.10.0/go.mod h1:jNfB8QC9IA6ZuY2ZjDp0KtFO2LZZlg4S/7bzP6qqeHo= +github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= +github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk= +github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/viper v1.21.0 h1:x5S+0EU27Lbphp4UKm1C+1oQO+rKx36vfCoaVebLFSU= +github.com/spf13/viper v1.21.0/go.mod h1:P0lhsswPGWD/1lZJ9ny3fYnVqxiegrlNrEmgLjbTCAY= +github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= +github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= +github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= +github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= +github.com/tiendc/go-deepcopy v1.7.1 h1:LnubftI6nYaaMOcaz0LphzwraqN8jiWTwm416sitff4= +github.com/tiendc/go-deepcopy v1.7.1/go.mod h1:4bKjNC2r7boYOkD2IOuZpYjmlDdzjbpTRyCx+goBCJQ= +github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= +github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= +github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs= +github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= +github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= +github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= +github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +github.com/xuri/efp v0.0.1 h1:fws5Rv3myXyYni8uwj2qKjVaRP30PdjeYe2Y6FDsCL8= +github.com/xuri/efp v0.0.1/go.mod h1:ybY/Jr0T0GTCnYjKqmdwxyxn2BQf2RcQIIvex5QldPI= +github.com/xuri/excelize/v2 v2.10.0 h1:8aKsP7JD39iKLc6dH5Tw3dgV3sPRh8uRVXu/fMstfW4= +github.com/xuri/excelize/v2 v2.10.0/go.mod h1:SC5TzhQkaOsTWpANfm+7bJCldzcnU/jrhqkTi/iBHBU= +github.com/xuri/nfp v0.0.2-0.20250530014748-2ddeb826f9a9 h1:+C0TIdyyYmzadGaL/HBLbf3WdLgC29pgyhTjAT/0nuE= +github.com/xuri/nfp v0.0.2-0.20250530014748-2ddeb826f9a9/go.mod h1:WwHg+CVyzlv/TX9xqBFXEZAuxOPxn2k1GNHwG41IIUQ= +go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= +go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= +go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= +go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64= +go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y= +go.opentelemetry.io/contrib v1.19.0 h1:rnYI7OEPMWFeM4QCqWQ3InMJ0arWMR1i0Cx9A5hcjYM= +go.opentelemetry.io/contrib v1.19.0/go.mod h1:gIzjwWFoGazJmtCaDgViqOSJPde2mCWzv60o0bWPcZs= +go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= +go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.18.0 h1:IAtl+7gua134xcV3NieDhJHjjOVeJhXAnYf/0hswjUY= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.18.0/go.mod h1:w+pXobnBzh95MNIkeIuAKcHe/Uu/CX2PKIvBP6ipKRA= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.18.0 h1:yE32ay7mJG2leczfREEhoW3VfSZIvHaB+gvVo1o8DQ8= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.18.0/go.mod h1:G17FHPDLt74bCI7tJ4CMitEk4BXTYG4FW6XUpkPBXa4= +go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.18.0 h1:hSWWvDjXHVLq9DkmB+77fl8v7+t+yYiS+eNkiplDK54= +go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.18.0/go.mod h1:zG7KQql1WjZCaUJd+L/ReSYx4bjbYJxg5ws9ws+mYes= +go.opentelemetry.io/otel/exporters/zipkin v1.18.0 h1:ZqrHgvega5NIiScTiVrtpZSpEmjUdwzkhuuCEIMAp+s= +go.opentelemetry.io/otel/exporters/zipkin v1.18.0/go.mod h1:C80yIYcSceQipAZb4Ah11EE/yERlyc1MtqJG2xP7p+s= +go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA= +go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI= +go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E= +go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg= +go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM= +go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA= +go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE= +go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs= +go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lIVU/I= +go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM= +go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= +go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= +go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/ratelimit v0.3.0 h1:IdZd9wqvFXnvLvSEBo0KPcGfkoBGNkpTHlrE3Rcjkjw= +go.uber.org/ratelimit v0.3.0/go.mod h1:So5LG7CV1zWpY1sHe+DXTJqQvOx+FFPFaAs2SnoyBaI= +go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= +go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= +go.uber.org/zap v1.27.1 h1:08RqriUEv8+ArZRYSTXy1LeBScaMpVSTBhCeaZYfMYc= +go.uber.org/zap v1.27.1/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= +go.yaml.in/yaml/v2 v2.4.3 h1:6gvOSjQoTB3vt1l+CU+tSyi/HOjfOjRLJ4YwYZGwRO0= +go.yaml.in/yaml/v2 v2.4.3/go.mod h1:zSxWcmIDjOzPXpjlTTbAsKokqkDNAVtZO0WOMiT90s8= +go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= +go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.47.0 h1:V6e3FRj+n4dbpw86FJ8Fv7XVOql7TEwpHapKoMJ/GO8= +golang.org/x/crypto v0.47.0/go.mod h1:ff3Y9VzzKbwSSEzWqJsJVBnWmRwRSHt/6Op5n9bQc4A= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= +golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= +golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/image v0.25.0 h1:Y6uW6rH1y5y/LK1J8BPWZtr6yZ7hrsy6hFrXjgsc2fQ= +golang.org/x/image v0.25.0/go.mod h1:tCAmOEGthTtkalusGp1g3xa2gke8J6c2N565dTyl9Rs= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.49.0 h1:eeHFmOGUTtaaPSGNmjBKpbng9MulQsJURQUAfUwY++o= +golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4= +golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= +golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ= +golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.33.0 h1:B3njUFyqtHDUI5jMn1YIr5B0IE2U0qck04r6d4KPAxE= +golang.org/x/text v0.33.0/go.mod h1:LuMebE6+rBincTi9+xWTY8TztLzKHc/9C1uBCG27+q8= +golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= +gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= +google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190530194941-fb225487d101/go.mod h1:z3L6/3dTEVtUr6QSP8miRzeRqwQOioJ9I66odjN4I7s= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20210126160654-44e461bb6506/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto/googleapis/api v0.0.0-20251029180050-ab9386a59fda h1:+2XxjfsAu6vqFxwGBRcHiMaDCuZiqXGDUDVWVtrFAnE= +google.golang.org/genproto/googleapis/api v0.0.0-20251029180050-ab9386a59fda/go.mod h1:fDMmzKV90WSg1NbozdqrE64fkuTv6mlq2zxo9ad+3yo= +google.golang.org/genproto/googleapis/rpc v0.0.0-20260114163908-3f89685c29c3 h1:C4WAdL+FbjnGlpp2S+HMVhBeCq2Lcib4xZqfPNF6OoQ= +google.golang.org/genproto/googleapis/rpc v0.0.0-20260114163908-3f89685c29c3/go.mod h1:j9x/tPzZkyxcgEFkiKEEGxfvyumM01BEtsW8xzOahRQ= +google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= +google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +google.golang.org/grpc v1.22.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= +google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.78.0 h1:K1XZG/yGDJnzMdd/uZHAkVqJE+xIDOcmdSFZkBUicNc= +google.golang.org/grpc v1.78.0/go.mod h1:I47qjTo4OKbMkjA/aOOwxDIiPSBofUtQUI5EfpWvW7U= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE= +google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= +gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= +gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= +gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= +gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +nhooyr.io/websocket v1.8.6 h1:s+C3xAMLwGmlI31Nyn/eAehUlZPwfYZu2JXM621Q5/k= +nhooyr.io/websocket v1.8.6/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= +sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= +sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= diff --git a/internal/ai/openai.go b/internal/ai/openai.go new file mode 100644 index 0000000..ada0794 --- /dev/null +++ b/internal/ai/openai.go @@ -0,0 +1,193 @@ +package ai + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + "net/http" + "regexp" + "strings" + + "smart-search-back/pkg/errors" +) + +type OpenAIClient struct { + apiKey string + client *http.Client +} + +type openAIRequest struct { + Model string `json:"model"` + Messages []openAIMessage `json:"messages"` +} + +type openAIMessage struct { + Role string `json:"role"` + Content string `json:"content"` +} + +type openAIResponse struct { + Choices []struct { + Message openAIMessage `json:"message"` + } `json:"choices"` + Error *struct { + Message string `json:"message"` + } `json:"error,omitempty"` +} + +type tzResponse struct { + TZResponse string `json:"tz_response"` +} + +func NewOpenAIClient(apiKey string) *OpenAIClient { + return &OpenAIClient{ + apiKey: apiKey, + client: &http.Client{}, + } +} + +func (c *OpenAIClient) isMockMode() bool { + return c.apiKey == "" +} + +func (c *OpenAIClient) GenerateTZ(requestTxt string) (string, error) { + if c.isMockMode() { + return c.generateMockTZ(requestTxt), nil + } + + prompt := fmt.Sprintf(`Ты — эксперт по разработке технических заданий. + +ЗАДАЧА: +Преобразовать описание заказа в структурированное техническое задание. + +ВХОДНЫЕ ДАННЫЕ: +Описание: %s + +СТРУКТУРА ТЗ: +1. Наименование и описание +2. Количество и единицы измерения +3. Технические требования +4. Сроки выполнения/поставки +6. Требования к качеству (если есть) +7. Стоимость/бюджет (если указан) +8. Особые условия + +ПРИМЕР: + +Входные данные: "Нужны офисные столы деревянные, 10 шт, белого цвета, на колесиках, 50 тысяч, на ул. Пушкина" + +Ответ: +{ + "tz_response": "ТЕХНИЧЕСКОЕ ЗАДАНИЕ\n\n1. ПРЕДМЕТ\nПоставка офисных столов\n\n2. КОЛИЧЕСТВО\n10 шт.\n\n3. ТРЕБОВАНИЯ\n- Материал: дерево\n- Цвет: белый\n- На колесиках\n\n4. МЕСТО ДОСТАВКИ\nг. Москва, ул. Пушкина\n\n5. БЮДЖЕТ\n50 000 руб.\n\n6. СРОКИ\nОт согласования" +} + +ФОРМАТ ОТВЕТА: +{ + "tz_response": "ТЕХНИЧЕСКОЕ ЗАДАНИЕ\n\n1. РАЗДЕЛ\nДетали...\n\n2. РАЗДЕЛ\nДетали..." +} + +ПРАВИЛА: +- Ответ ТОЛЬКО в формате JSON +- Используй \n для переносов строк +- Без текста до или после JSON +- Ясная нумерация разделов +- Все параметры из описания должны быть в ТЗ +- Если параметр не указан → укажи "Не указано"`, requestTxt) + + reqBody := openAIRequest{ + Model: "gpt-4o-mini", + Messages: []openAIMessage{ + { + Role: "user", + Content: prompt, + }, + }, + } + + jsonData, err := json.Marshal(reqBody) + if err != nil { + return "", errors.NewInternalError(errors.AIAPIError, "failed to marshal request", err) + } + + req, err := http.NewRequest("POST", "https://api.openai.com/v1/chat/completions", bytes.NewBuffer(jsonData)) + if err != nil { + return "", errors.NewInternalError(errors.AIAPIError, "failed to create request", err) + } + + req.Header.Set("Content-Type", "application/json") + req.Header.Set("Authorization", "Bearer "+c.apiKey) + + resp, err := c.client.Do(req) + if err != nil { + return "", errors.NewInternalError(errors.AIAPIError, "failed to send request", err) + } + defer resp.Body.Close() + + body, err := io.ReadAll(resp.Body) + if err != nil { + return "", errors.NewInternalError(errors.AIAPIError, "failed to read response", err) + } + + var aiResp openAIResponse + if err := json.Unmarshal(body, &aiResp); err != nil { + return "", errors.NewInternalError(errors.AIAPIError, "failed to unmarshal response", err) + } + + if aiResp.Error != nil { + return "", errors.NewInternalError(errors.AIAPIError, aiResp.Error.Message, nil) + } + + if len(aiResp.Choices) == 0 { + return "", errors.NewInternalError(errors.AIAPIError, "no choices in response", nil) + } + + content := aiResp.Choices[0].Message.Content + + content = strings.TrimPrefix(content, "```json") + content = strings.TrimPrefix(content, "```") + content = strings.TrimSuffix(content, "```") + content = strings.TrimSpace(content) + + var tzResp tzResponse + if err := json.Unmarshal([]byte(content), &tzResp); err != nil { + re := regexp.MustCompile(`\{[\s\S]*\}`) + match := re.FindString(content) + if match != "" { + if err := json.Unmarshal([]byte(match), &tzResp); err != nil { + return "", errors.NewInternalError(errors.AIAPIError, "failed to parse TZ response", err) + } + } else { + return "", errors.NewInternalError(errors.AIAPIError, "failed to parse TZ response", err) + } + } + + return tzResp.TZResponse, nil +} + +func (c *OpenAIClient) generateMockTZ(requestTxt string) string { + return fmt.Sprintf(`ТЕХНИЧЕСКОЕ ЗАДАНИЕ (MOCK) + +1. ПРЕДМЕТ +%s + +2. КОЛИЧЕСТВО +По запросу + +3. ТРЕБОВАНИЯ +- Качественное исполнение +- Соответствие стандартам +- Своевременная поставка + +4. МЕСТО ДОСТАВКИ +г. Москва + +5. БЮДЖЕТ +Уточняется + +6. СРОКИ +От согласования + +7. ОСОБЫЕ УСЛОВИЯ +Mock-данные для тестирования. API ключ OpenAI не настроен.`, requestTxt) +} diff --git a/internal/ai/perplexity.go b/internal/ai/perplexity.go new file mode 100644 index 0000000..cf2f9ff --- /dev/null +++ b/internal/ai/perplexity.go @@ -0,0 +1,321 @@ +package ai + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + "net/http" + "regexp" + "strings" + + "smart-search-back/internal/model" + "smart-search-back/pkg/errors" +) + +type PerplexityClient struct { + apiKey string + client *http.Client +} + +type perplexityRequest struct { + Model string `json:"model"` + Messages []perplexityMessage `json:"messages"` +} + +type perplexityMessage struct { + Role string `json:"role"` + Content string `json:"content"` +} + +type perplexityResponse struct { + Choices []struct { + Message perplexityMessage `json:"message"` + } `json:"choices"` + Usage *struct { + PromptTokens int `json:"prompt_tokens"` + CompletionTokens int `json:"completion_tokens"` + } `json:"usage,omitempty"` + Error *struct { + Message string `json:"message"` + } `json:"error,omitempty"` +} + +type supplierData struct { + CompanyName string `json:"company_name"` + Email string `json:"email"` + Phone string `json:"phone"` + Address string `json:"adress"` + URL string `json:"url"` +} + +func NewPerplexityClient(apiKey string) *PerplexityClient { + return &PerplexityClient{ + apiKey: apiKey, + client: &http.Client{}, + } +} + +func (c *PerplexityClient) isMockMode() bool { + return c.apiKey == "" +} + +func (c *PerplexityClient) FindSuppliers(tzText string) ([]*model.Supplier, int, int, error) { + if c.isMockMode() { + return c.generateMockSuppliers(), 1000, 500, nil + } + + prompt := fmt.Sprintf(`Ты — эксперт по поиску поставщиков на российском рынке. + +ЗАДАЧА: +Найти компании-поставщики/производители для технического задания: +%s + +ОПРЕДЕЛЕНИЕ ТИПА ПОИСКА: +- Если ТЗ требует производства/изготовления → ищи производителей +- Если ТЗ требует готовый товар/услугу → ищи компании, которые это продают + +КРИТЕРИИ: +1. Максимальная релевантность +2. Действующие компании с полными контактами +3. Приоритет: производители > дистрибьюторы + +ПРИМЕРЫ ОТВЕТОВ: + +Пример 1 - ТЗ: "Поставка офисной мебели: столы 20 шт, стулья 50 шт" +[ + { + "company_name": "ООО Мебельная фабрика Союз", + "email": "zakaz@mebelsoyuz.ru", + "phone": "+7 495 123-45-67", + "adress": "г. Москва, ул. Промышленная, д. 15", + "url": "" + } +] + +Пример 2 - ТЗ: "Производство кованых изделий: ворота, решётки, перила" +[ + { + "company_name": "ООО Кузня Премиум", + "email": "info@kuzniya.ru", + "phone": "", + "adress": "г. Москва, ул. Заводская, д. 42", + "url": "www.mebelsoyuz.ru" + } +] + +ФОРМАТ ОТВЕТА - ТОЛЬКО JSON: +[ + { + "company_name": "...", + "email": "...", + "phone": "...", + "adress": "...", + "url": "..." + } +] + +ПРАВИЛА: +- Минимум 15 компаний, максимум 100 +- Только валидный JSON массив, без текста вокруг +- email и url всегда заполнены (не null) +- Если другие поля пустые, то можно оставить пустую строку -> "" +- Сортируй по релевантности`, tzText) + + reqBody := perplexityRequest{ + Model: "llama-3.1-sonar-large-128k-online", + Messages: []perplexityMessage{ + { + Role: "user", + Content: prompt, + }, + }, + } + + jsonData, err := json.Marshal(reqBody) + if err != nil { + return nil, 0, 0, errors.NewInternalError(errors.AIAPIError, "failed to marshal request", err) + } + + req, err := http.NewRequest("POST", "https://api.perplexity.ai/chat/completions", bytes.NewBuffer(jsonData)) + if err != nil { + return nil, 0, 0, errors.NewInternalError(errors.AIAPIError, "failed to create request", err) + } + + req.Header.Set("Content-Type", "application/json") + req.Header.Set("Authorization", "Bearer "+c.apiKey) + + resp, err := c.client.Do(req) + if err != nil { + return nil, 0, 0, errors.NewInternalError(errors.AIAPIError, "failed to send request", err) + } + defer resp.Body.Close() + + body, err := io.ReadAll(resp.Body) + if err != nil { + return nil, 0, 0, errors.NewInternalError(errors.AIAPIError, "failed to read response", err) + } + + var aiResp perplexityResponse + if err := json.Unmarshal(body, &aiResp); err != nil { + return nil, 0, 0, errors.NewInternalError(errors.AIAPIError, "failed to unmarshal response", err) + } + + if aiResp.Error != nil { + return nil, 0, 0, errors.NewInternalError(errors.AIAPIError, aiResp.Error.Message, nil) + } + + if len(aiResp.Choices) == 0 { + return nil, 0, 0, errors.NewInternalError(errors.AIAPIError, "no choices in response", nil) + } + + content := aiResp.Choices[0].Message.Content + + content = strings.TrimPrefix(content, "```json") + content = strings.TrimPrefix(content, "```") + content = strings.TrimSuffix(content, "```") + content = strings.TrimSpace(content) + + var supplierDataList []supplierData + if err := json.Unmarshal([]byte(content), &supplierDataList); err != nil { + re := regexp.MustCompile(`\[[\s\S]*\]`) + match := re.FindString(content) + if match != "" { + if err := json.Unmarshal([]byte(match), &supplierDataList); err != nil { + return nil, 0, 0, errors.NewInternalError(errors.AIAPIError, "failed to parse suppliers response", err) + } + } else { + return nil, 0, 0, errors.NewInternalError(errors.AIAPIError, "failed to parse suppliers response", err) + } + } + + suppliers := make([]*model.Supplier, 0, len(supplierDataList)) + for _, sd := range supplierDataList { + suppliers = append(suppliers, &model.Supplier{ + Name: sd.CompanyName, + Email: sd.Email, + Phone: sd.Phone, + Address: sd.Address, + URL: sd.URL, + }) + } + + promptTokens := 0 + responseTokens := 0 + if aiResp.Usage != nil { + promptTokens = aiResp.Usage.PromptTokens + responseTokens = aiResp.Usage.CompletionTokens + } + + return suppliers, promptTokens, responseTokens, nil +} + +func (c *PerplexityClient) generateMockSuppliers() []*model.Supplier { + return []*model.Supplier{ + { + Name: "ООО Поставщик-1 (Mock)", + Email: "supplier1@example.com", + Phone: "+7 (495) 123-45-67", + Address: "г. Москва, ул. Примерная, д. 1", + URL: "https://supplier1.example.com", + }, + { + Name: "ООО Поставщик-2 (Mock)", + Email: "supplier2@example.com", + Phone: "+7 (495) 234-56-78", + Address: "г. Москва, ул. Примерная, д. 2", + URL: "https://supplier2.example.com", + }, + { + Name: "ООО Поставщик-3 (Mock)", + Email: "supplier3@example.com", + Phone: "+7 (495) 345-67-89", + Address: "г. Москва, ул. Примерная, д. 3", + URL: "https://supplier3.example.com", + }, + { + Name: "ООО Производитель-1 (Mock)", + Email: "producer1@example.com", + Phone: "+7 (495) 456-78-90", + Address: "г. Санкт-Петербург, ул. Тестовая, д. 10", + URL: "https://producer1.example.com", + }, + { + Name: "ООО Производитель-2 (Mock)", + Email: "producer2@example.com", + Phone: "+7 (495) 567-89-01", + Address: "г. Санкт-Петербург, ул. Тестовая, д. 20", + URL: "https://producer2.example.com", + }, + { + Name: "ООО Дистрибьютор-1 (Mock)", + Email: "distributor1@example.com", + Phone: "+7 (495) 678-90-12", + Address: "г. Казань, ул. Демо, д. 5", + URL: "https://distributor1.example.com", + }, + { + Name: "ООО Дистрибьютор-2 (Mock)", + Email: "distributor2@example.com", + Phone: "+7 (495) 789-01-23", + Address: "г. Казань, ул. Демо, д. 15", + URL: "https://distributor2.example.com", + }, + { + Name: "ООО Импортер-1 (Mock)", + Email: "importer1@example.com", + Phone: "+7 (495) 890-12-34", + Address: "г. Новосибирск, ул. Примера, д. 100", + URL: "https://importer1.example.com", + }, + { + Name: "ООО Импортер-2 (Mock)", + Email: "importer2@example.com", + Phone: "+7 (495) 901-23-45", + Address: "г. Новосибирск, ул. Примера, д. 200", + URL: "https://importer2.example.com", + }, + { + Name: "ООО Оптовик-1 (Mock)", + Email: "wholesale1@example.com", + Phone: "+7 (495) 012-34-56", + Address: "г. Екатеринбург, ул. Тестовая, д. 50", + URL: "https://wholesale1.example.com", + }, + { + Name: "ООО Оптовик-2 (Mock)", + Email: "wholesale2@example.com", + Phone: "+7 (495) 123-45-67", + Address: "г. Екатеринбург, ул. Тестовая, д. 60", + URL: "https://wholesale2.example.com", + }, + { + Name: "ООО Фабрика-1 (Mock)", + Email: "factory1@example.com", + Phone: "+7 (495) 234-56-78", + Address: "г. Нижний Новгород, Промзона, д. 1", + URL: "https://factory1.example.com", + }, + { + Name: "ООО Фабрика-2 (Mock)", + Email: "factory2@example.com", + Phone: "+7 (495) 345-67-89", + Address: "г. Нижний Новгород, Промзона, д. 2", + URL: "https://factory2.example.com", + }, + { + Name: "ООО Завод-1 (Mock)", + Email: "plant1@example.com", + Phone: "+7 (495) 456-78-90", + Address: "г. Челябинск, Индустриальная, д. 10", + URL: "https://plant1.example.com", + }, + { + Name: "ООО Завод-2 (Mock)", + Email: "plant2@example.com", + Phone: "+7 (495) 567-89-01", + Address: "г. Челябинск, Индустриальная, д. 20", + URL: "https://plant2.example.com", + }, + } +} diff --git a/internal/config/config.go b/internal/config/config.go new file mode 100644 index 0000000..9f9b061 --- /dev/null +++ b/internal/config/config.go @@ -0,0 +1,111 @@ +package config + +import ( + "fmt" + "os" + "regexp" + + "gopkg.in/yaml.v3" +) + +type Config struct { + Database DatabaseConfig `yaml:"database"` + AI AIConfig `yaml:"ai"` + Security SecurityConfig `yaml:"security"` + GRPC GRPCConfig `yaml:"grpc"` + Logging LoggingConfig `yaml:"logging"` +} + +type DatabaseConfig struct { + Host string `yaml:"host"` + Port int `yaml:"port"` + Name string `yaml:"name"` + User string `yaml:"user"` + Password string `yaml:"password"` + SSLMode string `yaml:"ssl_mode"` + MaxConns int `yaml:"max_conns"` + MinConns int `yaml:"min_conns"` +} + +type AIConfig struct { + OpenAIKey string `yaml:"openai_key"` + PerplexityKey string `yaml:"perplexity_key"` +} + +type SecurityConfig struct { + JWTSecret string `yaml:"jwt_secret"` + CryptoSecret string `yaml:"crypto_secret"` +} + +type GRPCConfig struct { + Port int `yaml:"port"` + MaxConnections int `yaml:"max_connections"` +} + +type LoggingConfig struct { + Level string `yaml:"level"` +} + +func Load(path string) (*Config, error) { + data, err := os.ReadFile(path) + if err != nil { + return nil, fmt.Errorf("failed to read config file: %w", err) + } + + data = []byte(expandEnvWithDefaults(string(data))) + + var cfg Config + if err := yaml.Unmarshal(data, &cfg); err != nil { + return nil, fmt.Errorf("failed to unmarshal config: %w", err) + } + + if err := cfg.validate(); err != nil { + return nil, fmt.Errorf("invalid config: %w", err) + } + + return &cfg, nil +} + +func expandEnvWithDefaults(s string) string { + re := regexp.MustCompile(`\$\{([^:}]+):([^}]*)\}`) + result := re.ReplaceAllStringFunc(s, func(match string) string { + parts := re.FindStringSubmatch(match) + if len(parts) != 3 { + return match + } + envVar := parts[1] + defaultVal := parts[2] + if val := os.Getenv(envVar); val != "" { + return val + } + return defaultVal + }) + return os.ExpandEnv(result) +} + +func (c *Config) validate() error { + if c.Database.Host == "" { + return fmt.Errorf("database host is required") + } + if c.Database.Name == "" { + return fmt.Errorf("database name is required") + } + if c.Database.User == "" { + return fmt.Errorf("database user is required") + } + if c.Database.Password == "" { + return fmt.Errorf("database password is required") + } + if c.Security.JWTSecret == "" { + return fmt.Errorf("JWT secret is required") + } + if c.Security.CryptoSecret == "" { + return fmt.Errorf("crypto secret is required") + } + return nil +} + +func (c *Config) DatabaseURL() string { + return fmt.Sprintf("postgres://%s:%s@%s:%d/%s?sslmode=%s", + c.Database.User, c.Database.Password, c.Database.Host, c.Database.Port, c.Database.Name, c.Database.SSLMode) +} diff --git a/internal/database/migrations.go b/internal/database/migrations.go new file mode 100644 index 0000000..455fb10 --- /dev/null +++ b/internal/database/migrations.go @@ -0,0 +1,31 @@ +package database + +import ( + "database/sql" + "fmt" + + _ "github.com/jackc/pgx/v5/stdlib" + "github.com/pressly/goose/v3" +) + +func RunMigrations(databaseURL string) error { + db, err := sql.Open("pgx", databaseURL) + if err != nil { + return fmt.Errorf("failed to open database connection for migrations: %w", err) + } + defer db.Close() + + if err := db.Ping(); err != nil { + return fmt.Errorf("failed to ping database before migrations: %w", err) + } + + if err := goose.SetDialect("postgres"); err != nil { + return fmt.Errorf("failed to set goose dialect: %w", err) + } + + if err := goose.Up(db, "migrations"); err != nil { + return fmt.Errorf("failed to run migrations: %w", err) + } + + return nil +} diff --git a/internal/grpc/auth_handler.go b/internal/grpc/auth_handler.go new file mode 100644 index 0000000..43ae712 --- /dev/null +++ b/internal/grpc/auth_handler.go @@ -0,0 +1,70 @@ +package grpc + +import ( + "context" + + "smart-search-back/pkg/errors" + pb "smart-search-back/pkg/pb/api/proto/auth" + + "go.uber.org/zap" +) + +func (h *AuthHandler) Login(ctx context.Context, req *pb.LoginRequest) (*pb.LoginResponse, error) { + accessToken, refreshToken, err := h.authService.Login( + ctx, + req.Email, + req.Password, + req.Ip, + req.UserAgent, + ) + if err != nil { + return nil, errors.ToGRPCError(err, h.logger, "AuthService.Login") + } + + return &pb.LoginResponse{ + AccessToken: accessToken, + RefreshToken: refreshToken, + }, nil +} + +func (h *AuthHandler) Refresh(ctx context.Context, req *pb.RefreshRequest) (*pb.RefreshResponse, error) { + accessToken, err := h.authService.Refresh(ctx, req.RefreshToken) + if err != nil { + return nil, errors.ToGRPCError(err, h.logger, "AuthService.Refresh") + } + + return &pb.RefreshResponse{ + AccessToken: accessToken, + RefreshToken: req.RefreshToken, + }, nil +} + +func (h *AuthHandler) Validate(ctx context.Context, req *pb.ValidateRequest) (*pb.ValidateResponse, error) { + userID, err := h.authService.Validate(ctx, req.AccessToken) + if err != nil { + h.logger.Warn("Token validation failed", + zap.String("method", "AuthService.Validate"), + zap.Error(err), + ) + return &pb.ValidateResponse{ + Valid: false, + UserId: 0, + }, nil + } + + return &pb.ValidateResponse{ + Valid: true, + UserId: int64(userID), + }, nil +} + +func (h *AuthHandler) Logout(ctx context.Context, req *pb.LogoutRequest) (*pb.LogoutResponse, error) { + err := h.authService.Logout(ctx, req.AccessToken) + if err != nil { + return nil, errors.ToGRPCError(err, h.logger, "AuthService.Logout") + } + + return &pb.LogoutResponse{ + Success: true, + }, nil +} diff --git a/internal/grpc/invite_handler.go b/internal/grpc/invite_handler.go new file mode 100644 index 0000000..09efc5e --- /dev/null +++ b/internal/grpc/invite_handler.go @@ -0,0 +1,45 @@ +package grpc + +import ( + "context" + "strconv" + + "google.golang.org/protobuf/types/known/timestamppb" + "smart-search-back/pkg/errors" + pb "smart-search-back/pkg/pb/api/proto/invite" +) + +func (h *InviteHandler) Generate(ctx context.Context, req *pb.GenerateRequest) (*pb.GenerateResponse, error) { + invite, err := h.inviteService.Generate(ctx, int(req.UserId), int(req.TtlDays), int(req.MaxUses)) + if err != nil { + return nil, errors.ToGRPCError(err, h.logger, "InviteService.Generate") + } + + return &pb.GenerateResponse{ + Code: strconv.FormatInt(invite.Code, 10), + MaxUses: int32(invite.CanBeUsedCount), + ExpiresAt: timestamppb.New(invite.ExpiresAt), + }, nil +} + +func (h *InviteHandler) GetInfo(ctx context.Context, req *pb.GetInfoRequest) (*pb.GetInfoResponse, error) { + code, err := strconv.ParseInt(req.Code, 10, 64) + if err != nil { + return nil, errors.ToGRPCError(err, h.logger, "InviteService.GetInfo") + } + + invite, err := h.inviteService.GetInfo(ctx, code) + if err != nil { + return nil, errors.ToGRPCError(err, h.logger, "InviteService.GetInfo") + } + + return &pb.GetInfoResponse{ + Code: strconv.FormatInt(invite.Code, 10), + UserId: int64(invite.UserID), + CanBeUsedCount: int32(invite.CanBeUsedCount), + UsedCount: int32(invite.UsedCount), + ExpiresAt: timestamppb.New(invite.ExpiresAt), + IsActive: invite.IsActive, + CreatedAt: timestamppb.New(invite.CreatedAt), + }, nil +} diff --git a/internal/grpc/request_handler.go b/internal/grpc/request_handler.go new file mode 100644 index 0000000..e53730f --- /dev/null +++ b/internal/grpc/request_handler.go @@ -0,0 +1,91 @@ +package grpc + +import ( + "context" + "time" + + "github.com/google/uuid" + "google.golang.org/protobuf/types/known/timestamppb" + "smart-search-back/pkg/errors" + pb "smart-search-back/pkg/pb/api/proto/request" +) + +func (h *RequestHandler) CreateTZ(ctx context.Context, req *pb.CreateTZRequest) (*pb.CreateTZResponse, error) { + requestTxt := req.RequestTxt + if len(req.FileData) > 0 { + requestTxt += "\n[File: " + req.FileName + "]" + } + + requestID, tzText, err := h.requestService.CreateTZ(ctx, int(req.UserId), requestTxt) + if err != nil { + return nil, errors.ToGRPCError(err, h.logger, "RequestService.CreateTZ") + } + + return &pb.CreateTZResponse{ + RequestId: requestID.String(), + TzText: tzText, + }, nil +} + +func (h *RequestHandler) ApproveTZ(ctx context.Context, req *pb.ApproveTZRequest) (*pb.ApproveTZResponse, error) { + requestID, err := uuid.Parse(req.RequestId) + if err != nil { + return nil, errors.ToGRPCError(err, h.logger, "RequestService.ApproveTZ") + } + + _, err = h.requestService.ApproveTZ(ctx, requestID, req.FinalTz, int(req.UserId)) + if err != nil { + return nil, errors.ToGRPCError(err, h.logger, "RequestService.ApproveTZ") + } + + return &pb.ApproveTZResponse{ + Success: true, + MailingStatus: "sent", + }, nil +} + +func (h *RequestHandler) GetMailingList(ctx context.Context, req *pb.GetMailingListRequest) (*pb.GetMailingListResponse, error) { + requests, err := h.requestService.GetMailingList(ctx, int(req.UserId)) + if err != nil { + return nil, errors.ToGRPCError(err, h.logger, "RequestService.GetMailingList") + } + + items := make([]*pb.MailingItem, 0, len(requests)) + for _, r := range requests { + items = append(items, &pb.MailingItem{ + RequestId: r.ID.String(), + RequestTxt: r.RequestTxt, + FinalTz: r.FinalTZ, + MailingStatus: r.MailingStatus, + CreatedAt: timestamppb.New(r.CreatedAt), + SuppliersFound: 0, + }) + } + + return &pb.GetMailingListResponse{ + Items: items, + }, nil +} + +func (h *RequestHandler) GetMailingListByID(ctx context.Context, req *pb.GetMailingListByIDRequest) (*pb.GetMailingListByIDResponse, error) { + requestID, err := uuid.Parse(req.RequestId) + if err != nil { + return nil, errors.ToGRPCError(err, h.logger, "RequestService.GetMailingListByID") + } + + detail, err := h.requestService.GetMailingListByID(ctx, requestID) + if err != nil { + return nil, errors.ToGRPCError(err, h.logger, "RequestService.GetMailingListByID") + } + + return &pb.GetMailingListByIDResponse{ + Item: &pb.MailingItem{ + RequestId: detail.RequestID.String(), + RequestTxt: detail.Title, + FinalTz: detail.MailText, + MailingStatus: "sent", + CreatedAt: timestamppb.New(time.Now()), + SuppliersFound: int32(len(detail.Suppliers)), + }, + }, nil +} diff --git a/internal/grpc/server.go b/internal/grpc/server.go new file mode 100644 index 0000000..e41c0a1 --- /dev/null +++ b/internal/grpc/server.go @@ -0,0 +1,78 @@ +package grpc + +import ( + "smart-search-back/internal/ai" + "smart-search-back/internal/repository" + "smart-search-back/internal/service" + authpb "smart-search-back/pkg/pb/api/proto/auth" + invitepb "smart-search-back/pkg/pb/api/proto/invite" + requestpb "smart-search-back/pkg/pb/api/proto/request" + supplierpb "smart-search-back/pkg/pb/api/proto/supplier" + userpb "smart-search-back/pkg/pb/api/proto/user" + + "github.com/jackc/pgx/v5/pgxpool" + "go.uber.org/zap" + "google.golang.org/grpc" +) + +type AuthHandler struct { + authpb.UnimplementedAuthServiceServer + authService service.AuthService + logger *zap.Logger +} + +type UserHandler struct { + userpb.UnimplementedUserServiceServer + userService service.UserService + logger *zap.Logger +} + +type InviteHandler struct { + invitepb.UnimplementedInviteServiceServer + inviteService service.InviteService + logger *zap.Logger +} + +type RequestHandler struct { + requestpb.UnimplementedRequestServiceServer + requestService service.RequestService + logger *zap.Logger +} + +type SupplierHandler struct { + supplierpb.UnimplementedSupplierServiceServer + supplierService service.SupplierService + logger *zap.Logger +} + +func NewHandlers(pool *pgxpool.Pool, jwtSecret, cryptoSecret, openAIKey, perplexityKey string, logger *zap.Logger) (*AuthHandler, *UserHandler, *InviteHandler, *RequestHandler, *SupplierHandler) { + userRepo := repository.NewUserRepository(pool, cryptoSecret) + sessionRepo := repository.NewSessionRepository(pool) + inviteRepo := repository.NewInviteRepository(pool) + requestRepo := repository.NewRequestRepository(pool) + supplierRepo := repository.NewSupplierRepository(pool) + tokenUsageRepo := repository.NewTokenUsageRepository(pool) + + openAIClient := ai.NewOpenAIClient(openAIKey) + perplexityClient := ai.NewPerplexityClient(perplexityKey) + + authService := service.NewAuthService(userRepo, sessionRepo, jwtSecret, cryptoSecret) + userService := service.NewUserService(userRepo, requestRepo, cryptoSecret) + inviteService := service.NewInviteService(inviteRepo, userRepo) + requestService := service.NewRequestService(requestRepo, supplierRepo, tokenUsageRepo, userRepo, openAIClient, perplexityClient) + supplierService := service.NewSupplierService(supplierRepo) + + return &AuthHandler{authService: authService, logger: logger}, + &UserHandler{userService: userService, logger: logger}, + &InviteHandler{inviteService: inviteService, logger: logger}, + &RequestHandler{requestService: requestService, logger: logger}, + &SupplierHandler{supplierService: supplierService, logger: logger} +} + +func RegisterServices(s *grpc.Server, authH *AuthHandler, userH *UserHandler, inviteH *InviteHandler, requestH *RequestHandler, supplierH *SupplierHandler) { + authpb.RegisterAuthServiceServer(s, authH) + userpb.RegisterUserServiceServer(s, userH) + invitepb.RegisterInviteServiceServer(s, inviteH) + requestpb.RegisterRequestServiceServer(s, requestH) + supplierpb.RegisterSupplierServiceServer(s, supplierH) +} diff --git a/internal/grpc/supplier_handler.go b/internal/grpc/supplier_handler.go new file mode 100644 index 0000000..7e4bd26 --- /dev/null +++ b/internal/grpc/supplier_handler.go @@ -0,0 +1,29 @@ +package grpc + +import ( + "context" + + "github.com/google/uuid" + "smart-search-back/pkg/errors" + pb "smart-search-back/pkg/pb/api/proto/supplier" +) + +func (h *SupplierHandler) ExportExcel(ctx context.Context, req *pb.ExportExcelRequest) (*pb.ExportExcelResponse, error) { + requestID, err := uuid.Parse(req.RequestId) + if err != nil { + return nil, errors.ToGRPCError(err, h.logger, "SupplierService.ExportExcel") + } + + fileData, err := h.supplierService.ExportExcel(ctx, requestID) + if err != nil { + return nil, errors.ToGRPCError(err, h.logger, "SupplierService.ExportExcel") + } + + fileName := "suppliers_" + requestID.String() + ".xlsx" + + return &pb.ExportExcelResponse{ + FileData: fileData, + FileName: fileName, + MimeType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + }, nil +} diff --git a/internal/grpc/user_handler.go b/internal/grpc/user_handler.go new file mode 100644 index 0000000..186ac2e --- /dev/null +++ b/internal/grpc/user_handler.go @@ -0,0 +1,66 @@ +package grpc + +import ( + "context" + + "smart-search-back/pkg/errors" + pb "smart-search-back/pkg/pb/api/proto/user" +) + +func (h *UserHandler) GetInfo(ctx context.Context, req *pb.GetInfoRequest) (*pb.GetInfoResponse, error) { + user, err := h.userService.GetInfo(ctx, int(req.UserId)) + if err != nil { + return nil, errors.ToGRPCError(err, h.logger, "UserService.GetInfo") + } + + return &pb.GetInfoResponse{ + Email: user.Email, + Name: user.Name, + Phone: user.Phone, + CompanyName: user.CompanyName, + PaymentStatus: user.PaymentStatus, + }, nil +} + +func (h *UserHandler) GetBalance(ctx context.Context, req *pb.GetBalanceRequest) (*pb.GetBalanceResponse, error) { + balance, err := h.userService.GetBalance(ctx, int(req.UserId)) + if err != nil { + return nil, errors.ToGRPCError(err, h.logger, "UserService.GetBalance") + } + + return &pb.GetBalanceResponse{ + Balance: balance, + }, nil +} + +func (h *UserHandler) GetStatistics(ctx context.Context, req *pb.GetStatisticsRequest) (*pb.GetStatisticsResponse, error) { + stats, err := h.userService.GetStatistics(ctx, int(req.UserId)) + if err != nil { + return nil, errors.ToGRPCError(err, h.logger, "UserService.GetStatistics") + } + + return &pb.GetStatisticsResponse{ + TotalRequests: int32(stats.RequestsCount), + SuccessfulRequests: int32(stats.SuppliersCount), + FailedRequests: 0, + TotalSpent: 0, + }, nil +} + +func (h *UserHandler) GetBalanceStatistics(ctx context.Context, req *pb.GetBalanceStatisticsRequest) (*pb.GetBalanceStatisticsResponse, error) { + balance, err := h.userService.GetBalance(ctx, int(req.UserId)) + if err != nil { + return nil, errors.ToGRPCError(err, h.logger, "UserService.GetBalanceStatistics") + } + + stats, err := h.userService.GetStatistics(ctx, int(req.UserId)) + if err != nil { + return nil, errors.ToGRPCError(err, h.logger, "UserService.GetBalanceStatistics") + } + + return &pb.GetBalanceStatisticsResponse{ + Balance: balance, + TotalRequests: int32(stats.RequestsCount), + TotalSpent: 0, + }, nil +} diff --git a/internal/mocks/auth_service_mock.go b/internal/mocks/auth_service_mock.go new file mode 100644 index 0000000..0fce24f --- /dev/null +++ b/internal/mocks/auth_service_mock.go @@ -0,0 +1,1578 @@ +// Code generated by http://github.com/gojuno/minimock (v3.4.7). DO NOT EDIT. + +package mocks + +//go:generate minimock -i smart-search-back/internal/service.AuthService -o auth_service_mock.go -n AuthServiceMock -p mocks + +import ( + "context" + "sync" + mm_atomic "sync/atomic" + mm_time "time" + + "github.com/gojuno/minimock/v3" +) + +// AuthServiceMock implements mm_service.AuthService +type AuthServiceMock struct { + t minimock.Tester + finishOnce sync.Once + + funcLogin func(ctx context.Context, email string, password string, ip string, userAgent string) (accessToken string, refreshToken string, err error) + funcLoginOrigin string + inspectFuncLogin func(ctx context.Context, email string, password string, ip string, userAgent string) + afterLoginCounter uint64 + beforeLoginCounter uint64 + LoginMock mAuthServiceMockLogin + + funcLogout func(ctx context.Context, refreshToken string) (err error) + funcLogoutOrigin string + inspectFuncLogout func(ctx context.Context, refreshToken string) + afterLogoutCounter uint64 + beforeLogoutCounter uint64 + LogoutMock mAuthServiceMockLogout + + funcRefresh func(ctx context.Context, refreshToken string) (s1 string, err error) + funcRefreshOrigin string + inspectFuncRefresh func(ctx context.Context, refreshToken string) + afterRefreshCounter uint64 + beforeRefreshCounter uint64 + RefreshMock mAuthServiceMockRefresh + + funcValidate func(ctx context.Context, accessToken string) (i1 int, err error) + funcValidateOrigin string + inspectFuncValidate func(ctx context.Context, accessToken string) + afterValidateCounter uint64 + beforeValidateCounter uint64 + ValidateMock mAuthServiceMockValidate +} + +// NewAuthServiceMock returns a mock for mm_service.AuthService +func NewAuthServiceMock(t minimock.Tester) *AuthServiceMock { + m := &AuthServiceMock{t: t} + + if controller, ok := t.(minimock.MockController); ok { + controller.RegisterMocker(m) + } + + m.LoginMock = mAuthServiceMockLogin{mock: m} + m.LoginMock.callArgs = []*AuthServiceMockLoginParams{} + + m.LogoutMock = mAuthServiceMockLogout{mock: m} + m.LogoutMock.callArgs = []*AuthServiceMockLogoutParams{} + + m.RefreshMock = mAuthServiceMockRefresh{mock: m} + m.RefreshMock.callArgs = []*AuthServiceMockRefreshParams{} + + m.ValidateMock = mAuthServiceMockValidate{mock: m} + m.ValidateMock.callArgs = []*AuthServiceMockValidateParams{} + + t.Cleanup(m.MinimockFinish) + + return m +} + +type mAuthServiceMockLogin struct { + optional bool + mock *AuthServiceMock + defaultExpectation *AuthServiceMockLoginExpectation + expectations []*AuthServiceMockLoginExpectation + + callArgs []*AuthServiceMockLoginParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// AuthServiceMockLoginExpectation specifies expectation struct of the AuthService.Login +type AuthServiceMockLoginExpectation struct { + mock *AuthServiceMock + params *AuthServiceMockLoginParams + paramPtrs *AuthServiceMockLoginParamPtrs + expectationOrigins AuthServiceMockLoginExpectationOrigins + results *AuthServiceMockLoginResults + returnOrigin string + Counter uint64 +} + +// AuthServiceMockLoginParams contains parameters of the AuthService.Login +type AuthServiceMockLoginParams struct { + ctx context.Context + email string + password string + ip string + userAgent string +} + +// AuthServiceMockLoginParamPtrs contains pointers to parameters of the AuthService.Login +type AuthServiceMockLoginParamPtrs struct { + ctx *context.Context + email *string + password *string + ip *string + userAgent *string +} + +// AuthServiceMockLoginResults contains results of the AuthService.Login +type AuthServiceMockLoginResults struct { + accessToken string + refreshToken string + err error +} + +// AuthServiceMockLoginOrigins contains origins of expectations of the AuthService.Login +type AuthServiceMockLoginExpectationOrigins struct { + origin string + originCtx string + originEmail string + originPassword string + originIp string + originUserAgent string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmLogin *mAuthServiceMockLogin) Optional() *mAuthServiceMockLogin { + mmLogin.optional = true + return mmLogin +} + +// Expect sets up expected params for AuthService.Login +func (mmLogin *mAuthServiceMockLogin) Expect(ctx context.Context, email string, password string, ip string, userAgent string) *mAuthServiceMockLogin { + if mmLogin.mock.funcLogin != nil { + mmLogin.mock.t.Fatalf("AuthServiceMock.Login mock is already set by Set") + } + + if mmLogin.defaultExpectation == nil { + mmLogin.defaultExpectation = &AuthServiceMockLoginExpectation{} + } + + if mmLogin.defaultExpectation.paramPtrs != nil { + mmLogin.mock.t.Fatalf("AuthServiceMock.Login mock is already set by ExpectParams functions") + } + + mmLogin.defaultExpectation.params = &AuthServiceMockLoginParams{ctx, email, password, ip, userAgent} + mmLogin.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmLogin.expectations { + if minimock.Equal(e.params, mmLogin.defaultExpectation.params) { + mmLogin.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmLogin.defaultExpectation.params) + } + } + + return mmLogin +} + +// ExpectCtxParam1 sets up expected param ctx for AuthService.Login +func (mmLogin *mAuthServiceMockLogin) ExpectCtxParam1(ctx context.Context) *mAuthServiceMockLogin { + if mmLogin.mock.funcLogin != nil { + mmLogin.mock.t.Fatalf("AuthServiceMock.Login mock is already set by Set") + } + + if mmLogin.defaultExpectation == nil { + mmLogin.defaultExpectation = &AuthServiceMockLoginExpectation{} + } + + if mmLogin.defaultExpectation.params != nil { + mmLogin.mock.t.Fatalf("AuthServiceMock.Login mock is already set by Expect") + } + + if mmLogin.defaultExpectation.paramPtrs == nil { + mmLogin.defaultExpectation.paramPtrs = &AuthServiceMockLoginParamPtrs{} + } + mmLogin.defaultExpectation.paramPtrs.ctx = &ctx + mmLogin.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmLogin +} + +// ExpectEmailParam2 sets up expected param email for AuthService.Login +func (mmLogin *mAuthServiceMockLogin) ExpectEmailParam2(email string) *mAuthServiceMockLogin { + if mmLogin.mock.funcLogin != nil { + mmLogin.mock.t.Fatalf("AuthServiceMock.Login mock is already set by Set") + } + + if mmLogin.defaultExpectation == nil { + mmLogin.defaultExpectation = &AuthServiceMockLoginExpectation{} + } + + if mmLogin.defaultExpectation.params != nil { + mmLogin.mock.t.Fatalf("AuthServiceMock.Login mock is already set by Expect") + } + + if mmLogin.defaultExpectation.paramPtrs == nil { + mmLogin.defaultExpectation.paramPtrs = &AuthServiceMockLoginParamPtrs{} + } + mmLogin.defaultExpectation.paramPtrs.email = &email + mmLogin.defaultExpectation.expectationOrigins.originEmail = minimock.CallerInfo(1) + + return mmLogin +} + +// ExpectPasswordParam3 sets up expected param password for AuthService.Login +func (mmLogin *mAuthServiceMockLogin) ExpectPasswordParam3(password string) *mAuthServiceMockLogin { + if mmLogin.mock.funcLogin != nil { + mmLogin.mock.t.Fatalf("AuthServiceMock.Login mock is already set by Set") + } + + if mmLogin.defaultExpectation == nil { + mmLogin.defaultExpectation = &AuthServiceMockLoginExpectation{} + } + + if mmLogin.defaultExpectation.params != nil { + mmLogin.mock.t.Fatalf("AuthServiceMock.Login mock is already set by Expect") + } + + if mmLogin.defaultExpectation.paramPtrs == nil { + mmLogin.defaultExpectation.paramPtrs = &AuthServiceMockLoginParamPtrs{} + } + mmLogin.defaultExpectation.paramPtrs.password = &password + mmLogin.defaultExpectation.expectationOrigins.originPassword = minimock.CallerInfo(1) + + return mmLogin +} + +// ExpectIpParam4 sets up expected param ip for AuthService.Login +func (mmLogin *mAuthServiceMockLogin) ExpectIpParam4(ip string) *mAuthServiceMockLogin { + if mmLogin.mock.funcLogin != nil { + mmLogin.mock.t.Fatalf("AuthServiceMock.Login mock is already set by Set") + } + + if mmLogin.defaultExpectation == nil { + mmLogin.defaultExpectation = &AuthServiceMockLoginExpectation{} + } + + if mmLogin.defaultExpectation.params != nil { + mmLogin.mock.t.Fatalf("AuthServiceMock.Login mock is already set by Expect") + } + + if mmLogin.defaultExpectation.paramPtrs == nil { + mmLogin.defaultExpectation.paramPtrs = &AuthServiceMockLoginParamPtrs{} + } + mmLogin.defaultExpectation.paramPtrs.ip = &ip + mmLogin.defaultExpectation.expectationOrigins.originIp = minimock.CallerInfo(1) + + return mmLogin +} + +// ExpectUserAgentParam5 sets up expected param userAgent for AuthService.Login +func (mmLogin *mAuthServiceMockLogin) ExpectUserAgentParam5(userAgent string) *mAuthServiceMockLogin { + if mmLogin.mock.funcLogin != nil { + mmLogin.mock.t.Fatalf("AuthServiceMock.Login mock is already set by Set") + } + + if mmLogin.defaultExpectation == nil { + mmLogin.defaultExpectation = &AuthServiceMockLoginExpectation{} + } + + if mmLogin.defaultExpectation.params != nil { + mmLogin.mock.t.Fatalf("AuthServiceMock.Login mock is already set by Expect") + } + + if mmLogin.defaultExpectation.paramPtrs == nil { + mmLogin.defaultExpectation.paramPtrs = &AuthServiceMockLoginParamPtrs{} + } + mmLogin.defaultExpectation.paramPtrs.userAgent = &userAgent + mmLogin.defaultExpectation.expectationOrigins.originUserAgent = minimock.CallerInfo(1) + + return mmLogin +} + +// Inspect accepts an inspector function that has same arguments as the AuthService.Login +func (mmLogin *mAuthServiceMockLogin) Inspect(f func(ctx context.Context, email string, password string, ip string, userAgent string)) *mAuthServiceMockLogin { + if mmLogin.mock.inspectFuncLogin != nil { + mmLogin.mock.t.Fatalf("Inspect function is already set for AuthServiceMock.Login") + } + + mmLogin.mock.inspectFuncLogin = f + + return mmLogin +} + +// Return sets up results that will be returned by AuthService.Login +func (mmLogin *mAuthServiceMockLogin) Return(accessToken string, refreshToken string, err error) *AuthServiceMock { + if mmLogin.mock.funcLogin != nil { + mmLogin.mock.t.Fatalf("AuthServiceMock.Login mock is already set by Set") + } + + if mmLogin.defaultExpectation == nil { + mmLogin.defaultExpectation = &AuthServiceMockLoginExpectation{mock: mmLogin.mock} + } + mmLogin.defaultExpectation.results = &AuthServiceMockLoginResults{accessToken, refreshToken, err} + mmLogin.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmLogin.mock +} + +// Set uses given function f to mock the AuthService.Login method +func (mmLogin *mAuthServiceMockLogin) Set(f func(ctx context.Context, email string, password string, ip string, userAgent string) (accessToken string, refreshToken string, err error)) *AuthServiceMock { + if mmLogin.defaultExpectation != nil { + mmLogin.mock.t.Fatalf("Default expectation is already set for the AuthService.Login method") + } + + if len(mmLogin.expectations) > 0 { + mmLogin.mock.t.Fatalf("Some expectations are already set for the AuthService.Login method") + } + + mmLogin.mock.funcLogin = f + mmLogin.mock.funcLoginOrigin = minimock.CallerInfo(1) + return mmLogin.mock +} + +// When sets expectation for the AuthService.Login which will trigger the result defined by the following +// Then helper +func (mmLogin *mAuthServiceMockLogin) When(ctx context.Context, email string, password string, ip string, userAgent string) *AuthServiceMockLoginExpectation { + if mmLogin.mock.funcLogin != nil { + mmLogin.mock.t.Fatalf("AuthServiceMock.Login mock is already set by Set") + } + + expectation := &AuthServiceMockLoginExpectation{ + mock: mmLogin.mock, + params: &AuthServiceMockLoginParams{ctx, email, password, ip, userAgent}, + expectationOrigins: AuthServiceMockLoginExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmLogin.expectations = append(mmLogin.expectations, expectation) + return expectation +} + +// Then sets up AuthService.Login return parameters for the expectation previously defined by the When method +func (e *AuthServiceMockLoginExpectation) Then(accessToken string, refreshToken string, err error) *AuthServiceMock { + e.results = &AuthServiceMockLoginResults{accessToken, refreshToken, err} + return e.mock +} + +// Times sets number of times AuthService.Login should be invoked +func (mmLogin *mAuthServiceMockLogin) Times(n uint64) *mAuthServiceMockLogin { + if n == 0 { + mmLogin.mock.t.Fatalf("Times of AuthServiceMock.Login mock can not be zero") + } + mm_atomic.StoreUint64(&mmLogin.expectedInvocations, n) + mmLogin.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmLogin +} + +func (mmLogin *mAuthServiceMockLogin) invocationsDone() bool { + if len(mmLogin.expectations) == 0 && mmLogin.defaultExpectation == nil && mmLogin.mock.funcLogin == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmLogin.mock.afterLoginCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmLogin.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// Login implements mm_service.AuthService +func (mmLogin *AuthServiceMock) Login(ctx context.Context, email string, password string, ip string, userAgent string) (accessToken string, refreshToken string, err error) { + mm_atomic.AddUint64(&mmLogin.beforeLoginCounter, 1) + defer mm_atomic.AddUint64(&mmLogin.afterLoginCounter, 1) + + mmLogin.t.Helper() + + if mmLogin.inspectFuncLogin != nil { + mmLogin.inspectFuncLogin(ctx, email, password, ip, userAgent) + } + + mm_params := AuthServiceMockLoginParams{ctx, email, password, ip, userAgent} + + // Record call args + mmLogin.LoginMock.mutex.Lock() + mmLogin.LoginMock.callArgs = append(mmLogin.LoginMock.callArgs, &mm_params) + mmLogin.LoginMock.mutex.Unlock() + + for _, e := range mmLogin.LoginMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.accessToken, e.results.refreshToken, e.results.err + } + } + + if mmLogin.LoginMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmLogin.LoginMock.defaultExpectation.Counter, 1) + mm_want := mmLogin.LoginMock.defaultExpectation.params + mm_want_ptrs := mmLogin.LoginMock.defaultExpectation.paramPtrs + + mm_got := AuthServiceMockLoginParams{ctx, email, password, ip, userAgent} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmLogin.t.Errorf("AuthServiceMock.Login got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmLogin.LoginMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.email != nil && !minimock.Equal(*mm_want_ptrs.email, mm_got.email) { + mmLogin.t.Errorf("AuthServiceMock.Login got unexpected parameter email, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmLogin.LoginMock.defaultExpectation.expectationOrigins.originEmail, *mm_want_ptrs.email, mm_got.email, minimock.Diff(*mm_want_ptrs.email, mm_got.email)) + } + + if mm_want_ptrs.password != nil && !minimock.Equal(*mm_want_ptrs.password, mm_got.password) { + mmLogin.t.Errorf("AuthServiceMock.Login got unexpected parameter password, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmLogin.LoginMock.defaultExpectation.expectationOrigins.originPassword, *mm_want_ptrs.password, mm_got.password, minimock.Diff(*mm_want_ptrs.password, mm_got.password)) + } + + if mm_want_ptrs.ip != nil && !minimock.Equal(*mm_want_ptrs.ip, mm_got.ip) { + mmLogin.t.Errorf("AuthServiceMock.Login got unexpected parameter ip, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmLogin.LoginMock.defaultExpectation.expectationOrigins.originIp, *mm_want_ptrs.ip, mm_got.ip, minimock.Diff(*mm_want_ptrs.ip, mm_got.ip)) + } + + if mm_want_ptrs.userAgent != nil && !minimock.Equal(*mm_want_ptrs.userAgent, mm_got.userAgent) { + mmLogin.t.Errorf("AuthServiceMock.Login got unexpected parameter userAgent, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmLogin.LoginMock.defaultExpectation.expectationOrigins.originUserAgent, *mm_want_ptrs.userAgent, mm_got.userAgent, minimock.Diff(*mm_want_ptrs.userAgent, mm_got.userAgent)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmLogin.t.Errorf("AuthServiceMock.Login got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmLogin.LoginMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmLogin.LoginMock.defaultExpectation.results + if mm_results == nil { + mmLogin.t.Fatal("No results are set for the AuthServiceMock.Login") + } + return (*mm_results).accessToken, (*mm_results).refreshToken, (*mm_results).err + } + if mmLogin.funcLogin != nil { + return mmLogin.funcLogin(ctx, email, password, ip, userAgent) + } + mmLogin.t.Fatalf("Unexpected call to AuthServiceMock.Login. %v %v %v %v %v", ctx, email, password, ip, userAgent) + return +} + +// LoginAfterCounter returns a count of finished AuthServiceMock.Login invocations +func (mmLogin *AuthServiceMock) LoginAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmLogin.afterLoginCounter) +} + +// LoginBeforeCounter returns a count of AuthServiceMock.Login invocations +func (mmLogin *AuthServiceMock) LoginBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmLogin.beforeLoginCounter) +} + +// Calls returns a list of arguments used in each call to AuthServiceMock.Login. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmLogin *mAuthServiceMockLogin) Calls() []*AuthServiceMockLoginParams { + mmLogin.mutex.RLock() + + argCopy := make([]*AuthServiceMockLoginParams, len(mmLogin.callArgs)) + copy(argCopy, mmLogin.callArgs) + + mmLogin.mutex.RUnlock() + + return argCopy +} + +// MinimockLoginDone returns true if the count of the Login invocations corresponds +// the number of defined expectations +func (m *AuthServiceMock) MinimockLoginDone() bool { + if m.LoginMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.LoginMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.LoginMock.invocationsDone() +} + +// MinimockLoginInspect logs each unmet expectation +func (m *AuthServiceMock) MinimockLoginInspect() { + for _, e := range m.LoginMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to AuthServiceMock.Login at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterLoginCounter := mm_atomic.LoadUint64(&m.afterLoginCounter) + // if default expectation was set then invocations count should be greater than zero + if m.LoginMock.defaultExpectation != nil && afterLoginCounter < 1 { + if m.LoginMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to AuthServiceMock.Login at\n%s", m.LoginMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to AuthServiceMock.Login at\n%s with params: %#v", m.LoginMock.defaultExpectation.expectationOrigins.origin, *m.LoginMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcLogin != nil && afterLoginCounter < 1 { + m.t.Errorf("Expected call to AuthServiceMock.Login at\n%s", m.funcLoginOrigin) + } + + if !m.LoginMock.invocationsDone() && afterLoginCounter > 0 { + m.t.Errorf("Expected %d calls to AuthServiceMock.Login at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.LoginMock.expectedInvocations), m.LoginMock.expectedInvocationsOrigin, afterLoginCounter) + } +} + +type mAuthServiceMockLogout struct { + optional bool + mock *AuthServiceMock + defaultExpectation *AuthServiceMockLogoutExpectation + expectations []*AuthServiceMockLogoutExpectation + + callArgs []*AuthServiceMockLogoutParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// AuthServiceMockLogoutExpectation specifies expectation struct of the AuthService.Logout +type AuthServiceMockLogoutExpectation struct { + mock *AuthServiceMock + params *AuthServiceMockLogoutParams + paramPtrs *AuthServiceMockLogoutParamPtrs + expectationOrigins AuthServiceMockLogoutExpectationOrigins + results *AuthServiceMockLogoutResults + returnOrigin string + Counter uint64 +} + +// AuthServiceMockLogoutParams contains parameters of the AuthService.Logout +type AuthServiceMockLogoutParams struct { + ctx context.Context + refreshToken string +} + +// AuthServiceMockLogoutParamPtrs contains pointers to parameters of the AuthService.Logout +type AuthServiceMockLogoutParamPtrs struct { + ctx *context.Context + refreshToken *string +} + +// AuthServiceMockLogoutResults contains results of the AuthService.Logout +type AuthServiceMockLogoutResults struct { + err error +} + +// AuthServiceMockLogoutOrigins contains origins of expectations of the AuthService.Logout +type AuthServiceMockLogoutExpectationOrigins struct { + origin string + originCtx string + originRefreshToken string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmLogout *mAuthServiceMockLogout) Optional() *mAuthServiceMockLogout { + mmLogout.optional = true + return mmLogout +} + +// Expect sets up expected params for AuthService.Logout +func (mmLogout *mAuthServiceMockLogout) Expect(ctx context.Context, refreshToken string) *mAuthServiceMockLogout { + if mmLogout.mock.funcLogout != nil { + mmLogout.mock.t.Fatalf("AuthServiceMock.Logout mock is already set by Set") + } + + if mmLogout.defaultExpectation == nil { + mmLogout.defaultExpectation = &AuthServiceMockLogoutExpectation{} + } + + if mmLogout.defaultExpectation.paramPtrs != nil { + mmLogout.mock.t.Fatalf("AuthServiceMock.Logout mock is already set by ExpectParams functions") + } + + mmLogout.defaultExpectation.params = &AuthServiceMockLogoutParams{ctx, refreshToken} + mmLogout.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmLogout.expectations { + if minimock.Equal(e.params, mmLogout.defaultExpectation.params) { + mmLogout.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmLogout.defaultExpectation.params) + } + } + + return mmLogout +} + +// ExpectCtxParam1 sets up expected param ctx for AuthService.Logout +func (mmLogout *mAuthServiceMockLogout) ExpectCtxParam1(ctx context.Context) *mAuthServiceMockLogout { + if mmLogout.mock.funcLogout != nil { + mmLogout.mock.t.Fatalf("AuthServiceMock.Logout mock is already set by Set") + } + + if mmLogout.defaultExpectation == nil { + mmLogout.defaultExpectation = &AuthServiceMockLogoutExpectation{} + } + + if mmLogout.defaultExpectation.params != nil { + mmLogout.mock.t.Fatalf("AuthServiceMock.Logout mock is already set by Expect") + } + + if mmLogout.defaultExpectation.paramPtrs == nil { + mmLogout.defaultExpectation.paramPtrs = &AuthServiceMockLogoutParamPtrs{} + } + mmLogout.defaultExpectation.paramPtrs.ctx = &ctx + mmLogout.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmLogout +} + +// ExpectRefreshTokenParam2 sets up expected param refreshToken for AuthService.Logout +func (mmLogout *mAuthServiceMockLogout) ExpectRefreshTokenParam2(refreshToken string) *mAuthServiceMockLogout { + if mmLogout.mock.funcLogout != nil { + mmLogout.mock.t.Fatalf("AuthServiceMock.Logout mock is already set by Set") + } + + if mmLogout.defaultExpectation == nil { + mmLogout.defaultExpectation = &AuthServiceMockLogoutExpectation{} + } + + if mmLogout.defaultExpectation.params != nil { + mmLogout.mock.t.Fatalf("AuthServiceMock.Logout mock is already set by Expect") + } + + if mmLogout.defaultExpectation.paramPtrs == nil { + mmLogout.defaultExpectation.paramPtrs = &AuthServiceMockLogoutParamPtrs{} + } + mmLogout.defaultExpectation.paramPtrs.refreshToken = &refreshToken + mmLogout.defaultExpectation.expectationOrigins.originRefreshToken = minimock.CallerInfo(1) + + return mmLogout +} + +// Inspect accepts an inspector function that has same arguments as the AuthService.Logout +func (mmLogout *mAuthServiceMockLogout) Inspect(f func(ctx context.Context, refreshToken string)) *mAuthServiceMockLogout { + if mmLogout.mock.inspectFuncLogout != nil { + mmLogout.mock.t.Fatalf("Inspect function is already set for AuthServiceMock.Logout") + } + + mmLogout.mock.inspectFuncLogout = f + + return mmLogout +} + +// Return sets up results that will be returned by AuthService.Logout +func (mmLogout *mAuthServiceMockLogout) Return(err error) *AuthServiceMock { + if mmLogout.mock.funcLogout != nil { + mmLogout.mock.t.Fatalf("AuthServiceMock.Logout mock is already set by Set") + } + + if mmLogout.defaultExpectation == nil { + mmLogout.defaultExpectation = &AuthServiceMockLogoutExpectation{mock: mmLogout.mock} + } + mmLogout.defaultExpectation.results = &AuthServiceMockLogoutResults{err} + mmLogout.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmLogout.mock +} + +// Set uses given function f to mock the AuthService.Logout method +func (mmLogout *mAuthServiceMockLogout) Set(f func(ctx context.Context, refreshToken string) (err error)) *AuthServiceMock { + if mmLogout.defaultExpectation != nil { + mmLogout.mock.t.Fatalf("Default expectation is already set for the AuthService.Logout method") + } + + if len(mmLogout.expectations) > 0 { + mmLogout.mock.t.Fatalf("Some expectations are already set for the AuthService.Logout method") + } + + mmLogout.mock.funcLogout = f + mmLogout.mock.funcLogoutOrigin = minimock.CallerInfo(1) + return mmLogout.mock +} + +// When sets expectation for the AuthService.Logout which will trigger the result defined by the following +// Then helper +func (mmLogout *mAuthServiceMockLogout) When(ctx context.Context, refreshToken string) *AuthServiceMockLogoutExpectation { + if mmLogout.mock.funcLogout != nil { + mmLogout.mock.t.Fatalf("AuthServiceMock.Logout mock is already set by Set") + } + + expectation := &AuthServiceMockLogoutExpectation{ + mock: mmLogout.mock, + params: &AuthServiceMockLogoutParams{ctx, refreshToken}, + expectationOrigins: AuthServiceMockLogoutExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmLogout.expectations = append(mmLogout.expectations, expectation) + return expectation +} + +// Then sets up AuthService.Logout return parameters for the expectation previously defined by the When method +func (e *AuthServiceMockLogoutExpectation) Then(err error) *AuthServiceMock { + e.results = &AuthServiceMockLogoutResults{err} + return e.mock +} + +// Times sets number of times AuthService.Logout should be invoked +func (mmLogout *mAuthServiceMockLogout) Times(n uint64) *mAuthServiceMockLogout { + if n == 0 { + mmLogout.mock.t.Fatalf("Times of AuthServiceMock.Logout mock can not be zero") + } + mm_atomic.StoreUint64(&mmLogout.expectedInvocations, n) + mmLogout.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmLogout +} + +func (mmLogout *mAuthServiceMockLogout) invocationsDone() bool { + if len(mmLogout.expectations) == 0 && mmLogout.defaultExpectation == nil && mmLogout.mock.funcLogout == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmLogout.mock.afterLogoutCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmLogout.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// Logout implements mm_service.AuthService +func (mmLogout *AuthServiceMock) Logout(ctx context.Context, refreshToken string) (err error) { + mm_atomic.AddUint64(&mmLogout.beforeLogoutCounter, 1) + defer mm_atomic.AddUint64(&mmLogout.afterLogoutCounter, 1) + + mmLogout.t.Helper() + + if mmLogout.inspectFuncLogout != nil { + mmLogout.inspectFuncLogout(ctx, refreshToken) + } + + mm_params := AuthServiceMockLogoutParams{ctx, refreshToken} + + // Record call args + mmLogout.LogoutMock.mutex.Lock() + mmLogout.LogoutMock.callArgs = append(mmLogout.LogoutMock.callArgs, &mm_params) + mmLogout.LogoutMock.mutex.Unlock() + + for _, e := range mmLogout.LogoutMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.err + } + } + + if mmLogout.LogoutMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmLogout.LogoutMock.defaultExpectation.Counter, 1) + mm_want := mmLogout.LogoutMock.defaultExpectation.params + mm_want_ptrs := mmLogout.LogoutMock.defaultExpectation.paramPtrs + + mm_got := AuthServiceMockLogoutParams{ctx, refreshToken} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmLogout.t.Errorf("AuthServiceMock.Logout got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmLogout.LogoutMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.refreshToken != nil && !minimock.Equal(*mm_want_ptrs.refreshToken, mm_got.refreshToken) { + mmLogout.t.Errorf("AuthServiceMock.Logout got unexpected parameter refreshToken, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmLogout.LogoutMock.defaultExpectation.expectationOrigins.originRefreshToken, *mm_want_ptrs.refreshToken, mm_got.refreshToken, minimock.Diff(*mm_want_ptrs.refreshToken, mm_got.refreshToken)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmLogout.t.Errorf("AuthServiceMock.Logout got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmLogout.LogoutMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmLogout.LogoutMock.defaultExpectation.results + if mm_results == nil { + mmLogout.t.Fatal("No results are set for the AuthServiceMock.Logout") + } + return (*mm_results).err + } + if mmLogout.funcLogout != nil { + return mmLogout.funcLogout(ctx, refreshToken) + } + mmLogout.t.Fatalf("Unexpected call to AuthServiceMock.Logout. %v %v", ctx, refreshToken) + return +} + +// LogoutAfterCounter returns a count of finished AuthServiceMock.Logout invocations +func (mmLogout *AuthServiceMock) LogoutAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmLogout.afterLogoutCounter) +} + +// LogoutBeforeCounter returns a count of AuthServiceMock.Logout invocations +func (mmLogout *AuthServiceMock) LogoutBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmLogout.beforeLogoutCounter) +} + +// Calls returns a list of arguments used in each call to AuthServiceMock.Logout. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmLogout *mAuthServiceMockLogout) Calls() []*AuthServiceMockLogoutParams { + mmLogout.mutex.RLock() + + argCopy := make([]*AuthServiceMockLogoutParams, len(mmLogout.callArgs)) + copy(argCopy, mmLogout.callArgs) + + mmLogout.mutex.RUnlock() + + return argCopy +} + +// MinimockLogoutDone returns true if the count of the Logout invocations corresponds +// the number of defined expectations +func (m *AuthServiceMock) MinimockLogoutDone() bool { + if m.LogoutMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.LogoutMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.LogoutMock.invocationsDone() +} + +// MinimockLogoutInspect logs each unmet expectation +func (m *AuthServiceMock) MinimockLogoutInspect() { + for _, e := range m.LogoutMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to AuthServiceMock.Logout at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterLogoutCounter := mm_atomic.LoadUint64(&m.afterLogoutCounter) + // if default expectation was set then invocations count should be greater than zero + if m.LogoutMock.defaultExpectation != nil && afterLogoutCounter < 1 { + if m.LogoutMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to AuthServiceMock.Logout at\n%s", m.LogoutMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to AuthServiceMock.Logout at\n%s with params: %#v", m.LogoutMock.defaultExpectation.expectationOrigins.origin, *m.LogoutMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcLogout != nil && afterLogoutCounter < 1 { + m.t.Errorf("Expected call to AuthServiceMock.Logout at\n%s", m.funcLogoutOrigin) + } + + if !m.LogoutMock.invocationsDone() && afterLogoutCounter > 0 { + m.t.Errorf("Expected %d calls to AuthServiceMock.Logout at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.LogoutMock.expectedInvocations), m.LogoutMock.expectedInvocationsOrigin, afterLogoutCounter) + } +} + +type mAuthServiceMockRefresh struct { + optional bool + mock *AuthServiceMock + defaultExpectation *AuthServiceMockRefreshExpectation + expectations []*AuthServiceMockRefreshExpectation + + callArgs []*AuthServiceMockRefreshParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// AuthServiceMockRefreshExpectation specifies expectation struct of the AuthService.Refresh +type AuthServiceMockRefreshExpectation struct { + mock *AuthServiceMock + params *AuthServiceMockRefreshParams + paramPtrs *AuthServiceMockRefreshParamPtrs + expectationOrigins AuthServiceMockRefreshExpectationOrigins + results *AuthServiceMockRefreshResults + returnOrigin string + Counter uint64 +} + +// AuthServiceMockRefreshParams contains parameters of the AuthService.Refresh +type AuthServiceMockRefreshParams struct { + ctx context.Context + refreshToken string +} + +// AuthServiceMockRefreshParamPtrs contains pointers to parameters of the AuthService.Refresh +type AuthServiceMockRefreshParamPtrs struct { + ctx *context.Context + refreshToken *string +} + +// AuthServiceMockRefreshResults contains results of the AuthService.Refresh +type AuthServiceMockRefreshResults struct { + s1 string + err error +} + +// AuthServiceMockRefreshOrigins contains origins of expectations of the AuthService.Refresh +type AuthServiceMockRefreshExpectationOrigins struct { + origin string + originCtx string + originRefreshToken string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmRefresh *mAuthServiceMockRefresh) Optional() *mAuthServiceMockRefresh { + mmRefresh.optional = true + return mmRefresh +} + +// Expect sets up expected params for AuthService.Refresh +func (mmRefresh *mAuthServiceMockRefresh) Expect(ctx context.Context, refreshToken string) *mAuthServiceMockRefresh { + if mmRefresh.mock.funcRefresh != nil { + mmRefresh.mock.t.Fatalf("AuthServiceMock.Refresh mock is already set by Set") + } + + if mmRefresh.defaultExpectation == nil { + mmRefresh.defaultExpectation = &AuthServiceMockRefreshExpectation{} + } + + if mmRefresh.defaultExpectation.paramPtrs != nil { + mmRefresh.mock.t.Fatalf("AuthServiceMock.Refresh mock is already set by ExpectParams functions") + } + + mmRefresh.defaultExpectation.params = &AuthServiceMockRefreshParams{ctx, refreshToken} + mmRefresh.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmRefresh.expectations { + if minimock.Equal(e.params, mmRefresh.defaultExpectation.params) { + mmRefresh.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmRefresh.defaultExpectation.params) + } + } + + return mmRefresh +} + +// ExpectCtxParam1 sets up expected param ctx for AuthService.Refresh +func (mmRefresh *mAuthServiceMockRefresh) ExpectCtxParam1(ctx context.Context) *mAuthServiceMockRefresh { + if mmRefresh.mock.funcRefresh != nil { + mmRefresh.mock.t.Fatalf("AuthServiceMock.Refresh mock is already set by Set") + } + + if mmRefresh.defaultExpectation == nil { + mmRefresh.defaultExpectation = &AuthServiceMockRefreshExpectation{} + } + + if mmRefresh.defaultExpectation.params != nil { + mmRefresh.mock.t.Fatalf("AuthServiceMock.Refresh mock is already set by Expect") + } + + if mmRefresh.defaultExpectation.paramPtrs == nil { + mmRefresh.defaultExpectation.paramPtrs = &AuthServiceMockRefreshParamPtrs{} + } + mmRefresh.defaultExpectation.paramPtrs.ctx = &ctx + mmRefresh.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmRefresh +} + +// ExpectRefreshTokenParam2 sets up expected param refreshToken for AuthService.Refresh +func (mmRefresh *mAuthServiceMockRefresh) ExpectRefreshTokenParam2(refreshToken string) *mAuthServiceMockRefresh { + if mmRefresh.mock.funcRefresh != nil { + mmRefresh.mock.t.Fatalf("AuthServiceMock.Refresh mock is already set by Set") + } + + if mmRefresh.defaultExpectation == nil { + mmRefresh.defaultExpectation = &AuthServiceMockRefreshExpectation{} + } + + if mmRefresh.defaultExpectation.params != nil { + mmRefresh.mock.t.Fatalf("AuthServiceMock.Refresh mock is already set by Expect") + } + + if mmRefresh.defaultExpectation.paramPtrs == nil { + mmRefresh.defaultExpectation.paramPtrs = &AuthServiceMockRefreshParamPtrs{} + } + mmRefresh.defaultExpectation.paramPtrs.refreshToken = &refreshToken + mmRefresh.defaultExpectation.expectationOrigins.originRefreshToken = minimock.CallerInfo(1) + + return mmRefresh +} + +// Inspect accepts an inspector function that has same arguments as the AuthService.Refresh +func (mmRefresh *mAuthServiceMockRefresh) Inspect(f func(ctx context.Context, refreshToken string)) *mAuthServiceMockRefresh { + if mmRefresh.mock.inspectFuncRefresh != nil { + mmRefresh.mock.t.Fatalf("Inspect function is already set for AuthServiceMock.Refresh") + } + + mmRefresh.mock.inspectFuncRefresh = f + + return mmRefresh +} + +// Return sets up results that will be returned by AuthService.Refresh +func (mmRefresh *mAuthServiceMockRefresh) Return(s1 string, err error) *AuthServiceMock { + if mmRefresh.mock.funcRefresh != nil { + mmRefresh.mock.t.Fatalf("AuthServiceMock.Refresh mock is already set by Set") + } + + if mmRefresh.defaultExpectation == nil { + mmRefresh.defaultExpectation = &AuthServiceMockRefreshExpectation{mock: mmRefresh.mock} + } + mmRefresh.defaultExpectation.results = &AuthServiceMockRefreshResults{s1, err} + mmRefresh.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmRefresh.mock +} + +// Set uses given function f to mock the AuthService.Refresh method +func (mmRefresh *mAuthServiceMockRefresh) Set(f func(ctx context.Context, refreshToken string) (s1 string, err error)) *AuthServiceMock { + if mmRefresh.defaultExpectation != nil { + mmRefresh.mock.t.Fatalf("Default expectation is already set for the AuthService.Refresh method") + } + + if len(mmRefresh.expectations) > 0 { + mmRefresh.mock.t.Fatalf("Some expectations are already set for the AuthService.Refresh method") + } + + mmRefresh.mock.funcRefresh = f + mmRefresh.mock.funcRefreshOrigin = minimock.CallerInfo(1) + return mmRefresh.mock +} + +// When sets expectation for the AuthService.Refresh which will trigger the result defined by the following +// Then helper +func (mmRefresh *mAuthServiceMockRefresh) When(ctx context.Context, refreshToken string) *AuthServiceMockRefreshExpectation { + if mmRefresh.mock.funcRefresh != nil { + mmRefresh.mock.t.Fatalf("AuthServiceMock.Refresh mock is already set by Set") + } + + expectation := &AuthServiceMockRefreshExpectation{ + mock: mmRefresh.mock, + params: &AuthServiceMockRefreshParams{ctx, refreshToken}, + expectationOrigins: AuthServiceMockRefreshExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmRefresh.expectations = append(mmRefresh.expectations, expectation) + return expectation +} + +// Then sets up AuthService.Refresh return parameters for the expectation previously defined by the When method +func (e *AuthServiceMockRefreshExpectation) Then(s1 string, err error) *AuthServiceMock { + e.results = &AuthServiceMockRefreshResults{s1, err} + return e.mock +} + +// Times sets number of times AuthService.Refresh should be invoked +func (mmRefresh *mAuthServiceMockRefresh) Times(n uint64) *mAuthServiceMockRefresh { + if n == 0 { + mmRefresh.mock.t.Fatalf("Times of AuthServiceMock.Refresh mock can not be zero") + } + mm_atomic.StoreUint64(&mmRefresh.expectedInvocations, n) + mmRefresh.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmRefresh +} + +func (mmRefresh *mAuthServiceMockRefresh) invocationsDone() bool { + if len(mmRefresh.expectations) == 0 && mmRefresh.defaultExpectation == nil && mmRefresh.mock.funcRefresh == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmRefresh.mock.afterRefreshCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmRefresh.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// Refresh implements mm_service.AuthService +func (mmRefresh *AuthServiceMock) Refresh(ctx context.Context, refreshToken string) (s1 string, err error) { + mm_atomic.AddUint64(&mmRefresh.beforeRefreshCounter, 1) + defer mm_atomic.AddUint64(&mmRefresh.afterRefreshCounter, 1) + + mmRefresh.t.Helper() + + if mmRefresh.inspectFuncRefresh != nil { + mmRefresh.inspectFuncRefresh(ctx, refreshToken) + } + + mm_params := AuthServiceMockRefreshParams{ctx, refreshToken} + + // Record call args + mmRefresh.RefreshMock.mutex.Lock() + mmRefresh.RefreshMock.callArgs = append(mmRefresh.RefreshMock.callArgs, &mm_params) + mmRefresh.RefreshMock.mutex.Unlock() + + for _, e := range mmRefresh.RefreshMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.s1, e.results.err + } + } + + if mmRefresh.RefreshMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmRefresh.RefreshMock.defaultExpectation.Counter, 1) + mm_want := mmRefresh.RefreshMock.defaultExpectation.params + mm_want_ptrs := mmRefresh.RefreshMock.defaultExpectation.paramPtrs + + mm_got := AuthServiceMockRefreshParams{ctx, refreshToken} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmRefresh.t.Errorf("AuthServiceMock.Refresh got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmRefresh.RefreshMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.refreshToken != nil && !minimock.Equal(*mm_want_ptrs.refreshToken, mm_got.refreshToken) { + mmRefresh.t.Errorf("AuthServiceMock.Refresh got unexpected parameter refreshToken, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmRefresh.RefreshMock.defaultExpectation.expectationOrigins.originRefreshToken, *mm_want_ptrs.refreshToken, mm_got.refreshToken, minimock.Diff(*mm_want_ptrs.refreshToken, mm_got.refreshToken)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmRefresh.t.Errorf("AuthServiceMock.Refresh got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmRefresh.RefreshMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmRefresh.RefreshMock.defaultExpectation.results + if mm_results == nil { + mmRefresh.t.Fatal("No results are set for the AuthServiceMock.Refresh") + } + return (*mm_results).s1, (*mm_results).err + } + if mmRefresh.funcRefresh != nil { + return mmRefresh.funcRefresh(ctx, refreshToken) + } + mmRefresh.t.Fatalf("Unexpected call to AuthServiceMock.Refresh. %v %v", ctx, refreshToken) + return +} + +// RefreshAfterCounter returns a count of finished AuthServiceMock.Refresh invocations +func (mmRefresh *AuthServiceMock) RefreshAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmRefresh.afterRefreshCounter) +} + +// RefreshBeforeCounter returns a count of AuthServiceMock.Refresh invocations +func (mmRefresh *AuthServiceMock) RefreshBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmRefresh.beforeRefreshCounter) +} + +// Calls returns a list of arguments used in each call to AuthServiceMock.Refresh. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmRefresh *mAuthServiceMockRefresh) Calls() []*AuthServiceMockRefreshParams { + mmRefresh.mutex.RLock() + + argCopy := make([]*AuthServiceMockRefreshParams, len(mmRefresh.callArgs)) + copy(argCopy, mmRefresh.callArgs) + + mmRefresh.mutex.RUnlock() + + return argCopy +} + +// MinimockRefreshDone returns true if the count of the Refresh invocations corresponds +// the number of defined expectations +func (m *AuthServiceMock) MinimockRefreshDone() bool { + if m.RefreshMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.RefreshMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.RefreshMock.invocationsDone() +} + +// MinimockRefreshInspect logs each unmet expectation +func (m *AuthServiceMock) MinimockRefreshInspect() { + for _, e := range m.RefreshMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to AuthServiceMock.Refresh at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterRefreshCounter := mm_atomic.LoadUint64(&m.afterRefreshCounter) + // if default expectation was set then invocations count should be greater than zero + if m.RefreshMock.defaultExpectation != nil && afterRefreshCounter < 1 { + if m.RefreshMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to AuthServiceMock.Refresh at\n%s", m.RefreshMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to AuthServiceMock.Refresh at\n%s with params: %#v", m.RefreshMock.defaultExpectation.expectationOrigins.origin, *m.RefreshMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcRefresh != nil && afterRefreshCounter < 1 { + m.t.Errorf("Expected call to AuthServiceMock.Refresh at\n%s", m.funcRefreshOrigin) + } + + if !m.RefreshMock.invocationsDone() && afterRefreshCounter > 0 { + m.t.Errorf("Expected %d calls to AuthServiceMock.Refresh at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.RefreshMock.expectedInvocations), m.RefreshMock.expectedInvocationsOrigin, afterRefreshCounter) + } +} + +type mAuthServiceMockValidate struct { + optional bool + mock *AuthServiceMock + defaultExpectation *AuthServiceMockValidateExpectation + expectations []*AuthServiceMockValidateExpectation + + callArgs []*AuthServiceMockValidateParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// AuthServiceMockValidateExpectation specifies expectation struct of the AuthService.Validate +type AuthServiceMockValidateExpectation struct { + mock *AuthServiceMock + params *AuthServiceMockValidateParams + paramPtrs *AuthServiceMockValidateParamPtrs + expectationOrigins AuthServiceMockValidateExpectationOrigins + results *AuthServiceMockValidateResults + returnOrigin string + Counter uint64 +} + +// AuthServiceMockValidateParams contains parameters of the AuthService.Validate +type AuthServiceMockValidateParams struct { + ctx context.Context + accessToken string +} + +// AuthServiceMockValidateParamPtrs contains pointers to parameters of the AuthService.Validate +type AuthServiceMockValidateParamPtrs struct { + ctx *context.Context + accessToken *string +} + +// AuthServiceMockValidateResults contains results of the AuthService.Validate +type AuthServiceMockValidateResults struct { + i1 int + err error +} + +// AuthServiceMockValidateOrigins contains origins of expectations of the AuthService.Validate +type AuthServiceMockValidateExpectationOrigins struct { + origin string + originCtx string + originAccessToken string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmValidate *mAuthServiceMockValidate) Optional() *mAuthServiceMockValidate { + mmValidate.optional = true + return mmValidate +} + +// Expect sets up expected params for AuthService.Validate +func (mmValidate *mAuthServiceMockValidate) Expect(ctx context.Context, accessToken string) *mAuthServiceMockValidate { + if mmValidate.mock.funcValidate != nil { + mmValidate.mock.t.Fatalf("AuthServiceMock.Validate mock is already set by Set") + } + + if mmValidate.defaultExpectation == nil { + mmValidate.defaultExpectation = &AuthServiceMockValidateExpectation{} + } + + if mmValidate.defaultExpectation.paramPtrs != nil { + mmValidate.mock.t.Fatalf("AuthServiceMock.Validate mock is already set by ExpectParams functions") + } + + mmValidate.defaultExpectation.params = &AuthServiceMockValidateParams{ctx, accessToken} + mmValidate.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmValidate.expectations { + if minimock.Equal(e.params, mmValidate.defaultExpectation.params) { + mmValidate.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmValidate.defaultExpectation.params) + } + } + + return mmValidate +} + +// ExpectCtxParam1 sets up expected param ctx for AuthService.Validate +func (mmValidate *mAuthServiceMockValidate) ExpectCtxParam1(ctx context.Context) *mAuthServiceMockValidate { + if mmValidate.mock.funcValidate != nil { + mmValidate.mock.t.Fatalf("AuthServiceMock.Validate mock is already set by Set") + } + + if mmValidate.defaultExpectation == nil { + mmValidate.defaultExpectation = &AuthServiceMockValidateExpectation{} + } + + if mmValidate.defaultExpectation.params != nil { + mmValidate.mock.t.Fatalf("AuthServiceMock.Validate mock is already set by Expect") + } + + if mmValidate.defaultExpectation.paramPtrs == nil { + mmValidate.defaultExpectation.paramPtrs = &AuthServiceMockValidateParamPtrs{} + } + mmValidate.defaultExpectation.paramPtrs.ctx = &ctx + mmValidate.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmValidate +} + +// ExpectAccessTokenParam2 sets up expected param accessToken for AuthService.Validate +func (mmValidate *mAuthServiceMockValidate) ExpectAccessTokenParam2(accessToken string) *mAuthServiceMockValidate { + if mmValidate.mock.funcValidate != nil { + mmValidate.mock.t.Fatalf("AuthServiceMock.Validate mock is already set by Set") + } + + if mmValidate.defaultExpectation == nil { + mmValidate.defaultExpectation = &AuthServiceMockValidateExpectation{} + } + + if mmValidate.defaultExpectation.params != nil { + mmValidate.mock.t.Fatalf("AuthServiceMock.Validate mock is already set by Expect") + } + + if mmValidate.defaultExpectation.paramPtrs == nil { + mmValidate.defaultExpectation.paramPtrs = &AuthServiceMockValidateParamPtrs{} + } + mmValidate.defaultExpectation.paramPtrs.accessToken = &accessToken + mmValidate.defaultExpectation.expectationOrigins.originAccessToken = minimock.CallerInfo(1) + + return mmValidate +} + +// Inspect accepts an inspector function that has same arguments as the AuthService.Validate +func (mmValidate *mAuthServiceMockValidate) Inspect(f func(ctx context.Context, accessToken string)) *mAuthServiceMockValidate { + if mmValidate.mock.inspectFuncValidate != nil { + mmValidate.mock.t.Fatalf("Inspect function is already set for AuthServiceMock.Validate") + } + + mmValidate.mock.inspectFuncValidate = f + + return mmValidate +} + +// Return sets up results that will be returned by AuthService.Validate +func (mmValidate *mAuthServiceMockValidate) Return(i1 int, err error) *AuthServiceMock { + if mmValidate.mock.funcValidate != nil { + mmValidate.mock.t.Fatalf("AuthServiceMock.Validate mock is already set by Set") + } + + if mmValidate.defaultExpectation == nil { + mmValidate.defaultExpectation = &AuthServiceMockValidateExpectation{mock: mmValidate.mock} + } + mmValidate.defaultExpectation.results = &AuthServiceMockValidateResults{i1, err} + mmValidate.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmValidate.mock +} + +// Set uses given function f to mock the AuthService.Validate method +func (mmValidate *mAuthServiceMockValidate) Set(f func(ctx context.Context, accessToken string) (i1 int, err error)) *AuthServiceMock { + if mmValidate.defaultExpectation != nil { + mmValidate.mock.t.Fatalf("Default expectation is already set for the AuthService.Validate method") + } + + if len(mmValidate.expectations) > 0 { + mmValidate.mock.t.Fatalf("Some expectations are already set for the AuthService.Validate method") + } + + mmValidate.mock.funcValidate = f + mmValidate.mock.funcValidateOrigin = minimock.CallerInfo(1) + return mmValidate.mock +} + +// When sets expectation for the AuthService.Validate which will trigger the result defined by the following +// Then helper +func (mmValidate *mAuthServiceMockValidate) When(ctx context.Context, accessToken string) *AuthServiceMockValidateExpectation { + if mmValidate.mock.funcValidate != nil { + mmValidate.mock.t.Fatalf("AuthServiceMock.Validate mock is already set by Set") + } + + expectation := &AuthServiceMockValidateExpectation{ + mock: mmValidate.mock, + params: &AuthServiceMockValidateParams{ctx, accessToken}, + expectationOrigins: AuthServiceMockValidateExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmValidate.expectations = append(mmValidate.expectations, expectation) + return expectation +} + +// Then sets up AuthService.Validate return parameters for the expectation previously defined by the When method +func (e *AuthServiceMockValidateExpectation) Then(i1 int, err error) *AuthServiceMock { + e.results = &AuthServiceMockValidateResults{i1, err} + return e.mock +} + +// Times sets number of times AuthService.Validate should be invoked +func (mmValidate *mAuthServiceMockValidate) Times(n uint64) *mAuthServiceMockValidate { + if n == 0 { + mmValidate.mock.t.Fatalf("Times of AuthServiceMock.Validate mock can not be zero") + } + mm_atomic.StoreUint64(&mmValidate.expectedInvocations, n) + mmValidate.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmValidate +} + +func (mmValidate *mAuthServiceMockValidate) invocationsDone() bool { + if len(mmValidate.expectations) == 0 && mmValidate.defaultExpectation == nil && mmValidate.mock.funcValidate == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmValidate.mock.afterValidateCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmValidate.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// Validate implements mm_service.AuthService +func (mmValidate *AuthServiceMock) Validate(ctx context.Context, accessToken string) (i1 int, err error) { + mm_atomic.AddUint64(&mmValidate.beforeValidateCounter, 1) + defer mm_atomic.AddUint64(&mmValidate.afterValidateCounter, 1) + + mmValidate.t.Helper() + + if mmValidate.inspectFuncValidate != nil { + mmValidate.inspectFuncValidate(ctx, accessToken) + } + + mm_params := AuthServiceMockValidateParams{ctx, accessToken} + + // Record call args + mmValidate.ValidateMock.mutex.Lock() + mmValidate.ValidateMock.callArgs = append(mmValidate.ValidateMock.callArgs, &mm_params) + mmValidate.ValidateMock.mutex.Unlock() + + for _, e := range mmValidate.ValidateMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.i1, e.results.err + } + } + + if mmValidate.ValidateMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmValidate.ValidateMock.defaultExpectation.Counter, 1) + mm_want := mmValidate.ValidateMock.defaultExpectation.params + mm_want_ptrs := mmValidate.ValidateMock.defaultExpectation.paramPtrs + + mm_got := AuthServiceMockValidateParams{ctx, accessToken} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmValidate.t.Errorf("AuthServiceMock.Validate got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmValidate.ValidateMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.accessToken != nil && !minimock.Equal(*mm_want_ptrs.accessToken, mm_got.accessToken) { + mmValidate.t.Errorf("AuthServiceMock.Validate got unexpected parameter accessToken, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmValidate.ValidateMock.defaultExpectation.expectationOrigins.originAccessToken, *mm_want_ptrs.accessToken, mm_got.accessToken, minimock.Diff(*mm_want_ptrs.accessToken, mm_got.accessToken)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmValidate.t.Errorf("AuthServiceMock.Validate got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmValidate.ValidateMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmValidate.ValidateMock.defaultExpectation.results + if mm_results == nil { + mmValidate.t.Fatal("No results are set for the AuthServiceMock.Validate") + } + return (*mm_results).i1, (*mm_results).err + } + if mmValidate.funcValidate != nil { + return mmValidate.funcValidate(ctx, accessToken) + } + mmValidate.t.Fatalf("Unexpected call to AuthServiceMock.Validate. %v %v", ctx, accessToken) + return +} + +// ValidateAfterCounter returns a count of finished AuthServiceMock.Validate invocations +func (mmValidate *AuthServiceMock) ValidateAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmValidate.afterValidateCounter) +} + +// ValidateBeforeCounter returns a count of AuthServiceMock.Validate invocations +func (mmValidate *AuthServiceMock) ValidateBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmValidate.beforeValidateCounter) +} + +// Calls returns a list of arguments used in each call to AuthServiceMock.Validate. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmValidate *mAuthServiceMockValidate) Calls() []*AuthServiceMockValidateParams { + mmValidate.mutex.RLock() + + argCopy := make([]*AuthServiceMockValidateParams, len(mmValidate.callArgs)) + copy(argCopy, mmValidate.callArgs) + + mmValidate.mutex.RUnlock() + + return argCopy +} + +// MinimockValidateDone returns true if the count of the Validate invocations corresponds +// the number of defined expectations +func (m *AuthServiceMock) MinimockValidateDone() bool { + if m.ValidateMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.ValidateMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.ValidateMock.invocationsDone() +} + +// MinimockValidateInspect logs each unmet expectation +func (m *AuthServiceMock) MinimockValidateInspect() { + for _, e := range m.ValidateMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to AuthServiceMock.Validate at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterValidateCounter := mm_atomic.LoadUint64(&m.afterValidateCounter) + // if default expectation was set then invocations count should be greater than zero + if m.ValidateMock.defaultExpectation != nil && afterValidateCounter < 1 { + if m.ValidateMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to AuthServiceMock.Validate at\n%s", m.ValidateMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to AuthServiceMock.Validate at\n%s with params: %#v", m.ValidateMock.defaultExpectation.expectationOrigins.origin, *m.ValidateMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcValidate != nil && afterValidateCounter < 1 { + m.t.Errorf("Expected call to AuthServiceMock.Validate at\n%s", m.funcValidateOrigin) + } + + if !m.ValidateMock.invocationsDone() && afterValidateCounter > 0 { + m.t.Errorf("Expected %d calls to AuthServiceMock.Validate at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.ValidateMock.expectedInvocations), m.ValidateMock.expectedInvocationsOrigin, afterValidateCounter) + } +} + +// MinimockFinish checks that all mocked methods have been called the expected number of times +func (m *AuthServiceMock) MinimockFinish() { + m.finishOnce.Do(func() { + if !m.minimockDone() { + m.MinimockLoginInspect() + + m.MinimockLogoutInspect() + + m.MinimockRefreshInspect() + + m.MinimockValidateInspect() + } + }) +} + +// MinimockWait waits for all mocked methods to be called the expected number of times +func (m *AuthServiceMock) MinimockWait(timeout mm_time.Duration) { + timeoutCh := mm_time.After(timeout) + for { + if m.minimockDone() { + return + } + select { + case <-timeoutCh: + m.MinimockFinish() + return + case <-mm_time.After(10 * mm_time.Millisecond): + } + } +} + +func (m *AuthServiceMock) minimockDone() bool { + done := true + return done && + m.MinimockLoginDone() && + m.MinimockLogoutDone() && + m.MinimockRefreshDone() && + m.MinimockValidateDone() +} diff --git a/internal/mocks/invite_repository_mock.go b/internal/mocks/invite_repository_mock.go new file mode 100644 index 0000000..6e45f36 --- /dev/null +++ b/internal/mocks/invite_repository_mock.go @@ -0,0 +1,1809 @@ +// Code generated by http://github.com/gojuno/minimock (v3.4.7). DO NOT EDIT. + +package mocks + +//go:generate minimock -i smart-search-back/internal/repository.InviteRepository -o invite_repository_mock.go -n InviteRepositoryMock -p mocks + +import ( + "context" + "smart-search-back/internal/model" + "sync" + mm_atomic "sync/atomic" + mm_time "time" + + "github.com/gojuno/minimock/v3" +) + +// InviteRepositoryMock implements mm_repository.InviteRepository +type InviteRepositoryMock struct { + t minimock.Tester + finishOnce sync.Once + + funcCreate func(ctx context.Context, invite *model.InviteCode) (err error) + funcCreateOrigin string + inspectFuncCreate func(ctx context.Context, invite *model.InviteCode) + afterCreateCounter uint64 + beforeCreateCounter uint64 + CreateMock mInviteRepositoryMockCreate + + funcDeactivateExpired func(ctx context.Context) (i1 int, err error) + funcDeactivateExpiredOrigin string + inspectFuncDeactivateExpired func(ctx context.Context) + afterDeactivateExpiredCounter uint64 + beforeDeactivateExpiredCounter uint64 + DeactivateExpiredMock mInviteRepositoryMockDeactivateExpired + + funcFindByCode func(ctx context.Context, code int64) (ip1 *model.InviteCode, err error) + funcFindByCodeOrigin string + inspectFuncFindByCode func(ctx context.Context, code int64) + afterFindByCodeCounter uint64 + beforeFindByCodeCounter uint64 + FindByCodeMock mInviteRepositoryMockFindByCode + + funcGetUserInvites func(ctx context.Context, userID int) (ipa1 []*model.InviteCode, err error) + funcGetUserInvitesOrigin string + inspectFuncGetUserInvites func(ctx context.Context, userID int) + afterGetUserInvitesCounter uint64 + beforeGetUserInvitesCounter uint64 + GetUserInvitesMock mInviteRepositoryMockGetUserInvites + + funcIncrementUsedCount func(ctx context.Context, code int64) (err error) + funcIncrementUsedCountOrigin string + inspectFuncIncrementUsedCount func(ctx context.Context, code int64) + afterIncrementUsedCountCounter uint64 + beforeIncrementUsedCountCounter uint64 + IncrementUsedCountMock mInviteRepositoryMockIncrementUsedCount +} + +// NewInviteRepositoryMock returns a mock for mm_repository.InviteRepository +func NewInviteRepositoryMock(t minimock.Tester) *InviteRepositoryMock { + m := &InviteRepositoryMock{t: t} + + if controller, ok := t.(minimock.MockController); ok { + controller.RegisterMocker(m) + } + + m.CreateMock = mInviteRepositoryMockCreate{mock: m} + m.CreateMock.callArgs = []*InviteRepositoryMockCreateParams{} + + m.DeactivateExpiredMock = mInviteRepositoryMockDeactivateExpired{mock: m} + m.DeactivateExpiredMock.callArgs = []*InviteRepositoryMockDeactivateExpiredParams{} + + m.FindByCodeMock = mInviteRepositoryMockFindByCode{mock: m} + m.FindByCodeMock.callArgs = []*InviteRepositoryMockFindByCodeParams{} + + m.GetUserInvitesMock = mInviteRepositoryMockGetUserInvites{mock: m} + m.GetUserInvitesMock.callArgs = []*InviteRepositoryMockGetUserInvitesParams{} + + m.IncrementUsedCountMock = mInviteRepositoryMockIncrementUsedCount{mock: m} + m.IncrementUsedCountMock.callArgs = []*InviteRepositoryMockIncrementUsedCountParams{} + + t.Cleanup(m.MinimockFinish) + + return m +} + +type mInviteRepositoryMockCreate struct { + optional bool + mock *InviteRepositoryMock + defaultExpectation *InviteRepositoryMockCreateExpectation + expectations []*InviteRepositoryMockCreateExpectation + + callArgs []*InviteRepositoryMockCreateParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// InviteRepositoryMockCreateExpectation specifies expectation struct of the InviteRepository.Create +type InviteRepositoryMockCreateExpectation struct { + mock *InviteRepositoryMock + params *InviteRepositoryMockCreateParams + paramPtrs *InviteRepositoryMockCreateParamPtrs + expectationOrigins InviteRepositoryMockCreateExpectationOrigins + results *InviteRepositoryMockCreateResults + returnOrigin string + Counter uint64 +} + +// InviteRepositoryMockCreateParams contains parameters of the InviteRepository.Create +type InviteRepositoryMockCreateParams struct { + ctx context.Context + invite *model.InviteCode +} + +// InviteRepositoryMockCreateParamPtrs contains pointers to parameters of the InviteRepository.Create +type InviteRepositoryMockCreateParamPtrs struct { + ctx *context.Context + invite **model.InviteCode +} + +// InviteRepositoryMockCreateResults contains results of the InviteRepository.Create +type InviteRepositoryMockCreateResults struct { + err error +} + +// InviteRepositoryMockCreateOrigins contains origins of expectations of the InviteRepository.Create +type InviteRepositoryMockCreateExpectationOrigins struct { + origin string + originCtx string + originInvite string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmCreate *mInviteRepositoryMockCreate) Optional() *mInviteRepositoryMockCreate { + mmCreate.optional = true + return mmCreate +} + +// Expect sets up expected params for InviteRepository.Create +func (mmCreate *mInviteRepositoryMockCreate) Expect(ctx context.Context, invite *model.InviteCode) *mInviteRepositoryMockCreate { + if mmCreate.mock.funcCreate != nil { + mmCreate.mock.t.Fatalf("InviteRepositoryMock.Create mock is already set by Set") + } + + if mmCreate.defaultExpectation == nil { + mmCreate.defaultExpectation = &InviteRepositoryMockCreateExpectation{} + } + + if mmCreate.defaultExpectation.paramPtrs != nil { + mmCreate.mock.t.Fatalf("InviteRepositoryMock.Create mock is already set by ExpectParams functions") + } + + mmCreate.defaultExpectation.params = &InviteRepositoryMockCreateParams{ctx, invite} + mmCreate.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmCreate.expectations { + if minimock.Equal(e.params, mmCreate.defaultExpectation.params) { + mmCreate.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmCreate.defaultExpectation.params) + } + } + + return mmCreate +} + +// ExpectCtxParam1 sets up expected param ctx for InviteRepository.Create +func (mmCreate *mInviteRepositoryMockCreate) ExpectCtxParam1(ctx context.Context) *mInviteRepositoryMockCreate { + if mmCreate.mock.funcCreate != nil { + mmCreate.mock.t.Fatalf("InviteRepositoryMock.Create mock is already set by Set") + } + + if mmCreate.defaultExpectation == nil { + mmCreate.defaultExpectation = &InviteRepositoryMockCreateExpectation{} + } + + if mmCreate.defaultExpectation.params != nil { + mmCreate.mock.t.Fatalf("InviteRepositoryMock.Create mock is already set by Expect") + } + + if mmCreate.defaultExpectation.paramPtrs == nil { + mmCreate.defaultExpectation.paramPtrs = &InviteRepositoryMockCreateParamPtrs{} + } + mmCreate.defaultExpectation.paramPtrs.ctx = &ctx + mmCreate.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmCreate +} + +// ExpectInviteParam2 sets up expected param invite for InviteRepository.Create +func (mmCreate *mInviteRepositoryMockCreate) ExpectInviteParam2(invite *model.InviteCode) *mInviteRepositoryMockCreate { + if mmCreate.mock.funcCreate != nil { + mmCreate.mock.t.Fatalf("InviteRepositoryMock.Create mock is already set by Set") + } + + if mmCreate.defaultExpectation == nil { + mmCreate.defaultExpectation = &InviteRepositoryMockCreateExpectation{} + } + + if mmCreate.defaultExpectation.params != nil { + mmCreate.mock.t.Fatalf("InviteRepositoryMock.Create mock is already set by Expect") + } + + if mmCreate.defaultExpectation.paramPtrs == nil { + mmCreate.defaultExpectation.paramPtrs = &InviteRepositoryMockCreateParamPtrs{} + } + mmCreate.defaultExpectation.paramPtrs.invite = &invite + mmCreate.defaultExpectation.expectationOrigins.originInvite = minimock.CallerInfo(1) + + return mmCreate +} + +// Inspect accepts an inspector function that has same arguments as the InviteRepository.Create +func (mmCreate *mInviteRepositoryMockCreate) Inspect(f func(ctx context.Context, invite *model.InviteCode)) *mInviteRepositoryMockCreate { + if mmCreate.mock.inspectFuncCreate != nil { + mmCreate.mock.t.Fatalf("Inspect function is already set for InviteRepositoryMock.Create") + } + + mmCreate.mock.inspectFuncCreate = f + + return mmCreate +} + +// Return sets up results that will be returned by InviteRepository.Create +func (mmCreate *mInviteRepositoryMockCreate) Return(err error) *InviteRepositoryMock { + if mmCreate.mock.funcCreate != nil { + mmCreate.mock.t.Fatalf("InviteRepositoryMock.Create mock is already set by Set") + } + + if mmCreate.defaultExpectation == nil { + mmCreate.defaultExpectation = &InviteRepositoryMockCreateExpectation{mock: mmCreate.mock} + } + mmCreate.defaultExpectation.results = &InviteRepositoryMockCreateResults{err} + mmCreate.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmCreate.mock +} + +// Set uses given function f to mock the InviteRepository.Create method +func (mmCreate *mInviteRepositoryMockCreate) Set(f func(ctx context.Context, invite *model.InviteCode) (err error)) *InviteRepositoryMock { + if mmCreate.defaultExpectation != nil { + mmCreate.mock.t.Fatalf("Default expectation is already set for the InviteRepository.Create method") + } + + if len(mmCreate.expectations) > 0 { + mmCreate.mock.t.Fatalf("Some expectations are already set for the InviteRepository.Create method") + } + + mmCreate.mock.funcCreate = f + mmCreate.mock.funcCreateOrigin = minimock.CallerInfo(1) + return mmCreate.mock +} + +// When sets expectation for the InviteRepository.Create which will trigger the result defined by the following +// Then helper +func (mmCreate *mInviteRepositoryMockCreate) When(ctx context.Context, invite *model.InviteCode) *InviteRepositoryMockCreateExpectation { + if mmCreate.mock.funcCreate != nil { + mmCreate.mock.t.Fatalf("InviteRepositoryMock.Create mock is already set by Set") + } + + expectation := &InviteRepositoryMockCreateExpectation{ + mock: mmCreate.mock, + params: &InviteRepositoryMockCreateParams{ctx, invite}, + expectationOrigins: InviteRepositoryMockCreateExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmCreate.expectations = append(mmCreate.expectations, expectation) + return expectation +} + +// Then sets up InviteRepository.Create return parameters for the expectation previously defined by the When method +func (e *InviteRepositoryMockCreateExpectation) Then(err error) *InviteRepositoryMock { + e.results = &InviteRepositoryMockCreateResults{err} + return e.mock +} + +// Times sets number of times InviteRepository.Create should be invoked +func (mmCreate *mInviteRepositoryMockCreate) Times(n uint64) *mInviteRepositoryMockCreate { + if n == 0 { + mmCreate.mock.t.Fatalf("Times of InviteRepositoryMock.Create mock can not be zero") + } + mm_atomic.StoreUint64(&mmCreate.expectedInvocations, n) + mmCreate.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmCreate +} + +func (mmCreate *mInviteRepositoryMockCreate) invocationsDone() bool { + if len(mmCreate.expectations) == 0 && mmCreate.defaultExpectation == nil && mmCreate.mock.funcCreate == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmCreate.mock.afterCreateCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmCreate.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// Create implements mm_repository.InviteRepository +func (mmCreate *InviteRepositoryMock) Create(ctx context.Context, invite *model.InviteCode) (err error) { + mm_atomic.AddUint64(&mmCreate.beforeCreateCounter, 1) + defer mm_atomic.AddUint64(&mmCreate.afterCreateCounter, 1) + + mmCreate.t.Helper() + + if mmCreate.inspectFuncCreate != nil { + mmCreate.inspectFuncCreate(ctx, invite) + } + + mm_params := InviteRepositoryMockCreateParams{ctx, invite} + + // Record call args + mmCreate.CreateMock.mutex.Lock() + mmCreate.CreateMock.callArgs = append(mmCreate.CreateMock.callArgs, &mm_params) + mmCreate.CreateMock.mutex.Unlock() + + for _, e := range mmCreate.CreateMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.err + } + } + + if mmCreate.CreateMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmCreate.CreateMock.defaultExpectation.Counter, 1) + mm_want := mmCreate.CreateMock.defaultExpectation.params + mm_want_ptrs := mmCreate.CreateMock.defaultExpectation.paramPtrs + + mm_got := InviteRepositoryMockCreateParams{ctx, invite} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmCreate.t.Errorf("InviteRepositoryMock.Create got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmCreate.CreateMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.invite != nil && !minimock.Equal(*mm_want_ptrs.invite, mm_got.invite) { + mmCreate.t.Errorf("InviteRepositoryMock.Create got unexpected parameter invite, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmCreate.CreateMock.defaultExpectation.expectationOrigins.originInvite, *mm_want_ptrs.invite, mm_got.invite, minimock.Diff(*mm_want_ptrs.invite, mm_got.invite)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmCreate.t.Errorf("InviteRepositoryMock.Create got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmCreate.CreateMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmCreate.CreateMock.defaultExpectation.results + if mm_results == nil { + mmCreate.t.Fatal("No results are set for the InviteRepositoryMock.Create") + } + return (*mm_results).err + } + if mmCreate.funcCreate != nil { + return mmCreate.funcCreate(ctx, invite) + } + mmCreate.t.Fatalf("Unexpected call to InviteRepositoryMock.Create. %v %v", ctx, invite) + return +} + +// CreateAfterCounter returns a count of finished InviteRepositoryMock.Create invocations +func (mmCreate *InviteRepositoryMock) CreateAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmCreate.afterCreateCounter) +} + +// CreateBeforeCounter returns a count of InviteRepositoryMock.Create invocations +func (mmCreate *InviteRepositoryMock) CreateBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmCreate.beforeCreateCounter) +} + +// Calls returns a list of arguments used in each call to InviteRepositoryMock.Create. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmCreate *mInviteRepositoryMockCreate) Calls() []*InviteRepositoryMockCreateParams { + mmCreate.mutex.RLock() + + argCopy := make([]*InviteRepositoryMockCreateParams, len(mmCreate.callArgs)) + copy(argCopy, mmCreate.callArgs) + + mmCreate.mutex.RUnlock() + + return argCopy +} + +// MinimockCreateDone returns true if the count of the Create invocations corresponds +// the number of defined expectations +func (m *InviteRepositoryMock) MinimockCreateDone() bool { + if m.CreateMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.CreateMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.CreateMock.invocationsDone() +} + +// MinimockCreateInspect logs each unmet expectation +func (m *InviteRepositoryMock) MinimockCreateInspect() { + for _, e := range m.CreateMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to InviteRepositoryMock.Create at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterCreateCounter := mm_atomic.LoadUint64(&m.afterCreateCounter) + // if default expectation was set then invocations count should be greater than zero + if m.CreateMock.defaultExpectation != nil && afterCreateCounter < 1 { + if m.CreateMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to InviteRepositoryMock.Create at\n%s", m.CreateMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to InviteRepositoryMock.Create at\n%s with params: %#v", m.CreateMock.defaultExpectation.expectationOrigins.origin, *m.CreateMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcCreate != nil && afterCreateCounter < 1 { + m.t.Errorf("Expected call to InviteRepositoryMock.Create at\n%s", m.funcCreateOrigin) + } + + if !m.CreateMock.invocationsDone() && afterCreateCounter > 0 { + m.t.Errorf("Expected %d calls to InviteRepositoryMock.Create at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.CreateMock.expectedInvocations), m.CreateMock.expectedInvocationsOrigin, afterCreateCounter) + } +} + +type mInviteRepositoryMockDeactivateExpired struct { + optional bool + mock *InviteRepositoryMock + defaultExpectation *InviteRepositoryMockDeactivateExpiredExpectation + expectations []*InviteRepositoryMockDeactivateExpiredExpectation + + callArgs []*InviteRepositoryMockDeactivateExpiredParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// InviteRepositoryMockDeactivateExpiredExpectation specifies expectation struct of the InviteRepository.DeactivateExpired +type InviteRepositoryMockDeactivateExpiredExpectation struct { + mock *InviteRepositoryMock + params *InviteRepositoryMockDeactivateExpiredParams + paramPtrs *InviteRepositoryMockDeactivateExpiredParamPtrs + expectationOrigins InviteRepositoryMockDeactivateExpiredExpectationOrigins + results *InviteRepositoryMockDeactivateExpiredResults + returnOrigin string + Counter uint64 +} + +// InviteRepositoryMockDeactivateExpiredParams contains parameters of the InviteRepository.DeactivateExpired +type InviteRepositoryMockDeactivateExpiredParams struct { + ctx context.Context +} + +// InviteRepositoryMockDeactivateExpiredParamPtrs contains pointers to parameters of the InviteRepository.DeactivateExpired +type InviteRepositoryMockDeactivateExpiredParamPtrs struct { + ctx *context.Context +} + +// InviteRepositoryMockDeactivateExpiredResults contains results of the InviteRepository.DeactivateExpired +type InviteRepositoryMockDeactivateExpiredResults struct { + i1 int + err error +} + +// InviteRepositoryMockDeactivateExpiredOrigins contains origins of expectations of the InviteRepository.DeactivateExpired +type InviteRepositoryMockDeactivateExpiredExpectationOrigins struct { + origin string + originCtx string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmDeactivateExpired *mInviteRepositoryMockDeactivateExpired) Optional() *mInviteRepositoryMockDeactivateExpired { + mmDeactivateExpired.optional = true + return mmDeactivateExpired +} + +// Expect sets up expected params for InviteRepository.DeactivateExpired +func (mmDeactivateExpired *mInviteRepositoryMockDeactivateExpired) Expect(ctx context.Context) *mInviteRepositoryMockDeactivateExpired { + if mmDeactivateExpired.mock.funcDeactivateExpired != nil { + mmDeactivateExpired.mock.t.Fatalf("InviteRepositoryMock.DeactivateExpired mock is already set by Set") + } + + if mmDeactivateExpired.defaultExpectation == nil { + mmDeactivateExpired.defaultExpectation = &InviteRepositoryMockDeactivateExpiredExpectation{} + } + + if mmDeactivateExpired.defaultExpectation.paramPtrs != nil { + mmDeactivateExpired.mock.t.Fatalf("InviteRepositoryMock.DeactivateExpired mock is already set by ExpectParams functions") + } + + mmDeactivateExpired.defaultExpectation.params = &InviteRepositoryMockDeactivateExpiredParams{ctx} + mmDeactivateExpired.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmDeactivateExpired.expectations { + if minimock.Equal(e.params, mmDeactivateExpired.defaultExpectation.params) { + mmDeactivateExpired.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDeactivateExpired.defaultExpectation.params) + } + } + + return mmDeactivateExpired +} + +// ExpectCtxParam1 sets up expected param ctx for InviteRepository.DeactivateExpired +func (mmDeactivateExpired *mInviteRepositoryMockDeactivateExpired) ExpectCtxParam1(ctx context.Context) *mInviteRepositoryMockDeactivateExpired { + if mmDeactivateExpired.mock.funcDeactivateExpired != nil { + mmDeactivateExpired.mock.t.Fatalf("InviteRepositoryMock.DeactivateExpired mock is already set by Set") + } + + if mmDeactivateExpired.defaultExpectation == nil { + mmDeactivateExpired.defaultExpectation = &InviteRepositoryMockDeactivateExpiredExpectation{} + } + + if mmDeactivateExpired.defaultExpectation.params != nil { + mmDeactivateExpired.mock.t.Fatalf("InviteRepositoryMock.DeactivateExpired mock is already set by Expect") + } + + if mmDeactivateExpired.defaultExpectation.paramPtrs == nil { + mmDeactivateExpired.defaultExpectation.paramPtrs = &InviteRepositoryMockDeactivateExpiredParamPtrs{} + } + mmDeactivateExpired.defaultExpectation.paramPtrs.ctx = &ctx + mmDeactivateExpired.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmDeactivateExpired +} + +// Inspect accepts an inspector function that has same arguments as the InviteRepository.DeactivateExpired +func (mmDeactivateExpired *mInviteRepositoryMockDeactivateExpired) Inspect(f func(ctx context.Context)) *mInviteRepositoryMockDeactivateExpired { + if mmDeactivateExpired.mock.inspectFuncDeactivateExpired != nil { + mmDeactivateExpired.mock.t.Fatalf("Inspect function is already set for InviteRepositoryMock.DeactivateExpired") + } + + mmDeactivateExpired.mock.inspectFuncDeactivateExpired = f + + return mmDeactivateExpired +} + +// Return sets up results that will be returned by InviteRepository.DeactivateExpired +func (mmDeactivateExpired *mInviteRepositoryMockDeactivateExpired) Return(i1 int, err error) *InviteRepositoryMock { + if mmDeactivateExpired.mock.funcDeactivateExpired != nil { + mmDeactivateExpired.mock.t.Fatalf("InviteRepositoryMock.DeactivateExpired mock is already set by Set") + } + + if mmDeactivateExpired.defaultExpectation == nil { + mmDeactivateExpired.defaultExpectation = &InviteRepositoryMockDeactivateExpiredExpectation{mock: mmDeactivateExpired.mock} + } + mmDeactivateExpired.defaultExpectation.results = &InviteRepositoryMockDeactivateExpiredResults{i1, err} + mmDeactivateExpired.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmDeactivateExpired.mock +} + +// Set uses given function f to mock the InviteRepository.DeactivateExpired method +func (mmDeactivateExpired *mInviteRepositoryMockDeactivateExpired) Set(f func(ctx context.Context) (i1 int, err error)) *InviteRepositoryMock { + if mmDeactivateExpired.defaultExpectation != nil { + mmDeactivateExpired.mock.t.Fatalf("Default expectation is already set for the InviteRepository.DeactivateExpired method") + } + + if len(mmDeactivateExpired.expectations) > 0 { + mmDeactivateExpired.mock.t.Fatalf("Some expectations are already set for the InviteRepository.DeactivateExpired method") + } + + mmDeactivateExpired.mock.funcDeactivateExpired = f + mmDeactivateExpired.mock.funcDeactivateExpiredOrigin = minimock.CallerInfo(1) + return mmDeactivateExpired.mock +} + +// When sets expectation for the InviteRepository.DeactivateExpired which will trigger the result defined by the following +// Then helper +func (mmDeactivateExpired *mInviteRepositoryMockDeactivateExpired) When(ctx context.Context) *InviteRepositoryMockDeactivateExpiredExpectation { + if mmDeactivateExpired.mock.funcDeactivateExpired != nil { + mmDeactivateExpired.mock.t.Fatalf("InviteRepositoryMock.DeactivateExpired mock is already set by Set") + } + + expectation := &InviteRepositoryMockDeactivateExpiredExpectation{ + mock: mmDeactivateExpired.mock, + params: &InviteRepositoryMockDeactivateExpiredParams{ctx}, + expectationOrigins: InviteRepositoryMockDeactivateExpiredExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmDeactivateExpired.expectations = append(mmDeactivateExpired.expectations, expectation) + return expectation +} + +// Then sets up InviteRepository.DeactivateExpired return parameters for the expectation previously defined by the When method +func (e *InviteRepositoryMockDeactivateExpiredExpectation) Then(i1 int, err error) *InviteRepositoryMock { + e.results = &InviteRepositoryMockDeactivateExpiredResults{i1, err} + return e.mock +} + +// Times sets number of times InviteRepository.DeactivateExpired should be invoked +func (mmDeactivateExpired *mInviteRepositoryMockDeactivateExpired) Times(n uint64) *mInviteRepositoryMockDeactivateExpired { + if n == 0 { + mmDeactivateExpired.mock.t.Fatalf("Times of InviteRepositoryMock.DeactivateExpired mock can not be zero") + } + mm_atomic.StoreUint64(&mmDeactivateExpired.expectedInvocations, n) + mmDeactivateExpired.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmDeactivateExpired +} + +func (mmDeactivateExpired *mInviteRepositoryMockDeactivateExpired) invocationsDone() bool { + if len(mmDeactivateExpired.expectations) == 0 && mmDeactivateExpired.defaultExpectation == nil && mmDeactivateExpired.mock.funcDeactivateExpired == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmDeactivateExpired.mock.afterDeactivateExpiredCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmDeactivateExpired.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// DeactivateExpired implements mm_repository.InviteRepository +func (mmDeactivateExpired *InviteRepositoryMock) DeactivateExpired(ctx context.Context) (i1 int, err error) { + mm_atomic.AddUint64(&mmDeactivateExpired.beforeDeactivateExpiredCounter, 1) + defer mm_atomic.AddUint64(&mmDeactivateExpired.afterDeactivateExpiredCounter, 1) + + mmDeactivateExpired.t.Helper() + + if mmDeactivateExpired.inspectFuncDeactivateExpired != nil { + mmDeactivateExpired.inspectFuncDeactivateExpired(ctx) + } + + mm_params := InviteRepositoryMockDeactivateExpiredParams{ctx} + + // Record call args + mmDeactivateExpired.DeactivateExpiredMock.mutex.Lock() + mmDeactivateExpired.DeactivateExpiredMock.callArgs = append(mmDeactivateExpired.DeactivateExpiredMock.callArgs, &mm_params) + mmDeactivateExpired.DeactivateExpiredMock.mutex.Unlock() + + for _, e := range mmDeactivateExpired.DeactivateExpiredMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.i1, e.results.err + } + } + + if mmDeactivateExpired.DeactivateExpiredMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmDeactivateExpired.DeactivateExpiredMock.defaultExpectation.Counter, 1) + mm_want := mmDeactivateExpired.DeactivateExpiredMock.defaultExpectation.params + mm_want_ptrs := mmDeactivateExpired.DeactivateExpiredMock.defaultExpectation.paramPtrs + + mm_got := InviteRepositoryMockDeactivateExpiredParams{ctx} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmDeactivateExpired.t.Errorf("InviteRepositoryMock.DeactivateExpired got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmDeactivateExpired.DeactivateExpiredMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmDeactivateExpired.t.Errorf("InviteRepositoryMock.DeactivateExpired got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmDeactivateExpired.DeactivateExpiredMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmDeactivateExpired.DeactivateExpiredMock.defaultExpectation.results + if mm_results == nil { + mmDeactivateExpired.t.Fatal("No results are set for the InviteRepositoryMock.DeactivateExpired") + } + return (*mm_results).i1, (*mm_results).err + } + if mmDeactivateExpired.funcDeactivateExpired != nil { + return mmDeactivateExpired.funcDeactivateExpired(ctx) + } + mmDeactivateExpired.t.Fatalf("Unexpected call to InviteRepositoryMock.DeactivateExpired. %v", ctx) + return +} + +// DeactivateExpiredAfterCounter returns a count of finished InviteRepositoryMock.DeactivateExpired invocations +func (mmDeactivateExpired *InviteRepositoryMock) DeactivateExpiredAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmDeactivateExpired.afterDeactivateExpiredCounter) +} + +// DeactivateExpiredBeforeCounter returns a count of InviteRepositoryMock.DeactivateExpired invocations +func (mmDeactivateExpired *InviteRepositoryMock) DeactivateExpiredBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmDeactivateExpired.beforeDeactivateExpiredCounter) +} + +// Calls returns a list of arguments used in each call to InviteRepositoryMock.DeactivateExpired. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmDeactivateExpired *mInviteRepositoryMockDeactivateExpired) Calls() []*InviteRepositoryMockDeactivateExpiredParams { + mmDeactivateExpired.mutex.RLock() + + argCopy := make([]*InviteRepositoryMockDeactivateExpiredParams, len(mmDeactivateExpired.callArgs)) + copy(argCopy, mmDeactivateExpired.callArgs) + + mmDeactivateExpired.mutex.RUnlock() + + return argCopy +} + +// MinimockDeactivateExpiredDone returns true if the count of the DeactivateExpired invocations corresponds +// the number of defined expectations +func (m *InviteRepositoryMock) MinimockDeactivateExpiredDone() bool { + if m.DeactivateExpiredMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.DeactivateExpiredMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.DeactivateExpiredMock.invocationsDone() +} + +// MinimockDeactivateExpiredInspect logs each unmet expectation +func (m *InviteRepositoryMock) MinimockDeactivateExpiredInspect() { + for _, e := range m.DeactivateExpiredMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to InviteRepositoryMock.DeactivateExpired at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterDeactivateExpiredCounter := mm_atomic.LoadUint64(&m.afterDeactivateExpiredCounter) + // if default expectation was set then invocations count should be greater than zero + if m.DeactivateExpiredMock.defaultExpectation != nil && afterDeactivateExpiredCounter < 1 { + if m.DeactivateExpiredMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to InviteRepositoryMock.DeactivateExpired at\n%s", m.DeactivateExpiredMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to InviteRepositoryMock.DeactivateExpired at\n%s with params: %#v", m.DeactivateExpiredMock.defaultExpectation.expectationOrigins.origin, *m.DeactivateExpiredMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcDeactivateExpired != nil && afterDeactivateExpiredCounter < 1 { + m.t.Errorf("Expected call to InviteRepositoryMock.DeactivateExpired at\n%s", m.funcDeactivateExpiredOrigin) + } + + if !m.DeactivateExpiredMock.invocationsDone() && afterDeactivateExpiredCounter > 0 { + m.t.Errorf("Expected %d calls to InviteRepositoryMock.DeactivateExpired at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.DeactivateExpiredMock.expectedInvocations), m.DeactivateExpiredMock.expectedInvocationsOrigin, afterDeactivateExpiredCounter) + } +} + +type mInviteRepositoryMockFindByCode struct { + optional bool + mock *InviteRepositoryMock + defaultExpectation *InviteRepositoryMockFindByCodeExpectation + expectations []*InviteRepositoryMockFindByCodeExpectation + + callArgs []*InviteRepositoryMockFindByCodeParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// InviteRepositoryMockFindByCodeExpectation specifies expectation struct of the InviteRepository.FindByCode +type InviteRepositoryMockFindByCodeExpectation struct { + mock *InviteRepositoryMock + params *InviteRepositoryMockFindByCodeParams + paramPtrs *InviteRepositoryMockFindByCodeParamPtrs + expectationOrigins InviteRepositoryMockFindByCodeExpectationOrigins + results *InviteRepositoryMockFindByCodeResults + returnOrigin string + Counter uint64 +} + +// InviteRepositoryMockFindByCodeParams contains parameters of the InviteRepository.FindByCode +type InviteRepositoryMockFindByCodeParams struct { + ctx context.Context + code int64 +} + +// InviteRepositoryMockFindByCodeParamPtrs contains pointers to parameters of the InviteRepository.FindByCode +type InviteRepositoryMockFindByCodeParamPtrs struct { + ctx *context.Context + code *int64 +} + +// InviteRepositoryMockFindByCodeResults contains results of the InviteRepository.FindByCode +type InviteRepositoryMockFindByCodeResults struct { + ip1 *model.InviteCode + err error +} + +// InviteRepositoryMockFindByCodeOrigins contains origins of expectations of the InviteRepository.FindByCode +type InviteRepositoryMockFindByCodeExpectationOrigins struct { + origin string + originCtx string + originCode string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmFindByCode *mInviteRepositoryMockFindByCode) Optional() *mInviteRepositoryMockFindByCode { + mmFindByCode.optional = true + return mmFindByCode +} + +// Expect sets up expected params for InviteRepository.FindByCode +func (mmFindByCode *mInviteRepositoryMockFindByCode) Expect(ctx context.Context, code int64) *mInviteRepositoryMockFindByCode { + if mmFindByCode.mock.funcFindByCode != nil { + mmFindByCode.mock.t.Fatalf("InviteRepositoryMock.FindByCode mock is already set by Set") + } + + if mmFindByCode.defaultExpectation == nil { + mmFindByCode.defaultExpectation = &InviteRepositoryMockFindByCodeExpectation{} + } + + if mmFindByCode.defaultExpectation.paramPtrs != nil { + mmFindByCode.mock.t.Fatalf("InviteRepositoryMock.FindByCode mock is already set by ExpectParams functions") + } + + mmFindByCode.defaultExpectation.params = &InviteRepositoryMockFindByCodeParams{ctx, code} + mmFindByCode.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmFindByCode.expectations { + if minimock.Equal(e.params, mmFindByCode.defaultExpectation.params) { + mmFindByCode.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmFindByCode.defaultExpectation.params) + } + } + + return mmFindByCode +} + +// ExpectCtxParam1 sets up expected param ctx for InviteRepository.FindByCode +func (mmFindByCode *mInviteRepositoryMockFindByCode) ExpectCtxParam1(ctx context.Context) *mInviteRepositoryMockFindByCode { + if mmFindByCode.mock.funcFindByCode != nil { + mmFindByCode.mock.t.Fatalf("InviteRepositoryMock.FindByCode mock is already set by Set") + } + + if mmFindByCode.defaultExpectation == nil { + mmFindByCode.defaultExpectation = &InviteRepositoryMockFindByCodeExpectation{} + } + + if mmFindByCode.defaultExpectation.params != nil { + mmFindByCode.mock.t.Fatalf("InviteRepositoryMock.FindByCode mock is already set by Expect") + } + + if mmFindByCode.defaultExpectation.paramPtrs == nil { + mmFindByCode.defaultExpectation.paramPtrs = &InviteRepositoryMockFindByCodeParamPtrs{} + } + mmFindByCode.defaultExpectation.paramPtrs.ctx = &ctx + mmFindByCode.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmFindByCode +} + +// ExpectCodeParam2 sets up expected param code for InviteRepository.FindByCode +func (mmFindByCode *mInviteRepositoryMockFindByCode) ExpectCodeParam2(code int64) *mInviteRepositoryMockFindByCode { + if mmFindByCode.mock.funcFindByCode != nil { + mmFindByCode.mock.t.Fatalf("InviteRepositoryMock.FindByCode mock is already set by Set") + } + + if mmFindByCode.defaultExpectation == nil { + mmFindByCode.defaultExpectation = &InviteRepositoryMockFindByCodeExpectation{} + } + + if mmFindByCode.defaultExpectation.params != nil { + mmFindByCode.mock.t.Fatalf("InviteRepositoryMock.FindByCode mock is already set by Expect") + } + + if mmFindByCode.defaultExpectation.paramPtrs == nil { + mmFindByCode.defaultExpectation.paramPtrs = &InviteRepositoryMockFindByCodeParamPtrs{} + } + mmFindByCode.defaultExpectation.paramPtrs.code = &code + mmFindByCode.defaultExpectation.expectationOrigins.originCode = minimock.CallerInfo(1) + + return mmFindByCode +} + +// Inspect accepts an inspector function that has same arguments as the InviteRepository.FindByCode +func (mmFindByCode *mInviteRepositoryMockFindByCode) Inspect(f func(ctx context.Context, code int64)) *mInviteRepositoryMockFindByCode { + if mmFindByCode.mock.inspectFuncFindByCode != nil { + mmFindByCode.mock.t.Fatalf("Inspect function is already set for InviteRepositoryMock.FindByCode") + } + + mmFindByCode.mock.inspectFuncFindByCode = f + + return mmFindByCode +} + +// Return sets up results that will be returned by InviteRepository.FindByCode +func (mmFindByCode *mInviteRepositoryMockFindByCode) Return(ip1 *model.InviteCode, err error) *InviteRepositoryMock { + if mmFindByCode.mock.funcFindByCode != nil { + mmFindByCode.mock.t.Fatalf("InviteRepositoryMock.FindByCode mock is already set by Set") + } + + if mmFindByCode.defaultExpectation == nil { + mmFindByCode.defaultExpectation = &InviteRepositoryMockFindByCodeExpectation{mock: mmFindByCode.mock} + } + mmFindByCode.defaultExpectation.results = &InviteRepositoryMockFindByCodeResults{ip1, err} + mmFindByCode.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmFindByCode.mock +} + +// Set uses given function f to mock the InviteRepository.FindByCode method +func (mmFindByCode *mInviteRepositoryMockFindByCode) Set(f func(ctx context.Context, code int64) (ip1 *model.InviteCode, err error)) *InviteRepositoryMock { + if mmFindByCode.defaultExpectation != nil { + mmFindByCode.mock.t.Fatalf("Default expectation is already set for the InviteRepository.FindByCode method") + } + + if len(mmFindByCode.expectations) > 0 { + mmFindByCode.mock.t.Fatalf("Some expectations are already set for the InviteRepository.FindByCode method") + } + + mmFindByCode.mock.funcFindByCode = f + mmFindByCode.mock.funcFindByCodeOrigin = minimock.CallerInfo(1) + return mmFindByCode.mock +} + +// When sets expectation for the InviteRepository.FindByCode which will trigger the result defined by the following +// Then helper +func (mmFindByCode *mInviteRepositoryMockFindByCode) When(ctx context.Context, code int64) *InviteRepositoryMockFindByCodeExpectation { + if mmFindByCode.mock.funcFindByCode != nil { + mmFindByCode.mock.t.Fatalf("InviteRepositoryMock.FindByCode mock is already set by Set") + } + + expectation := &InviteRepositoryMockFindByCodeExpectation{ + mock: mmFindByCode.mock, + params: &InviteRepositoryMockFindByCodeParams{ctx, code}, + expectationOrigins: InviteRepositoryMockFindByCodeExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmFindByCode.expectations = append(mmFindByCode.expectations, expectation) + return expectation +} + +// Then sets up InviteRepository.FindByCode return parameters for the expectation previously defined by the When method +func (e *InviteRepositoryMockFindByCodeExpectation) Then(ip1 *model.InviteCode, err error) *InviteRepositoryMock { + e.results = &InviteRepositoryMockFindByCodeResults{ip1, err} + return e.mock +} + +// Times sets number of times InviteRepository.FindByCode should be invoked +func (mmFindByCode *mInviteRepositoryMockFindByCode) Times(n uint64) *mInviteRepositoryMockFindByCode { + if n == 0 { + mmFindByCode.mock.t.Fatalf("Times of InviteRepositoryMock.FindByCode mock can not be zero") + } + mm_atomic.StoreUint64(&mmFindByCode.expectedInvocations, n) + mmFindByCode.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmFindByCode +} + +func (mmFindByCode *mInviteRepositoryMockFindByCode) invocationsDone() bool { + if len(mmFindByCode.expectations) == 0 && mmFindByCode.defaultExpectation == nil && mmFindByCode.mock.funcFindByCode == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmFindByCode.mock.afterFindByCodeCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmFindByCode.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// FindByCode implements mm_repository.InviteRepository +func (mmFindByCode *InviteRepositoryMock) FindByCode(ctx context.Context, code int64) (ip1 *model.InviteCode, err error) { + mm_atomic.AddUint64(&mmFindByCode.beforeFindByCodeCounter, 1) + defer mm_atomic.AddUint64(&mmFindByCode.afterFindByCodeCounter, 1) + + mmFindByCode.t.Helper() + + if mmFindByCode.inspectFuncFindByCode != nil { + mmFindByCode.inspectFuncFindByCode(ctx, code) + } + + mm_params := InviteRepositoryMockFindByCodeParams{ctx, code} + + // Record call args + mmFindByCode.FindByCodeMock.mutex.Lock() + mmFindByCode.FindByCodeMock.callArgs = append(mmFindByCode.FindByCodeMock.callArgs, &mm_params) + mmFindByCode.FindByCodeMock.mutex.Unlock() + + for _, e := range mmFindByCode.FindByCodeMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.ip1, e.results.err + } + } + + if mmFindByCode.FindByCodeMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmFindByCode.FindByCodeMock.defaultExpectation.Counter, 1) + mm_want := mmFindByCode.FindByCodeMock.defaultExpectation.params + mm_want_ptrs := mmFindByCode.FindByCodeMock.defaultExpectation.paramPtrs + + mm_got := InviteRepositoryMockFindByCodeParams{ctx, code} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmFindByCode.t.Errorf("InviteRepositoryMock.FindByCode got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmFindByCode.FindByCodeMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.code != nil && !minimock.Equal(*mm_want_ptrs.code, mm_got.code) { + mmFindByCode.t.Errorf("InviteRepositoryMock.FindByCode got unexpected parameter code, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmFindByCode.FindByCodeMock.defaultExpectation.expectationOrigins.originCode, *mm_want_ptrs.code, mm_got.code, minimock.Diff(*mm_want_ptrs.code, mm_got.code)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmFindByCode.t.Errorf("InviteRepositoryMock.FindByCode got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmFindByCode.FindByCodeMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmFindByCode.FindByCodeMock.defaultExpectation.results + if mm_results == nil { + mmFindByCode.t.Fatal("No results are set for the InviteRepositoryMock.FindByCode") + } + return (*mm_results).ip1, (*mm_results).err + } + if mmFindByCode.funcFindByCode != nil { + return mmFindByCode.funcFindByCode(ctx, code) + } + mmFindByCode.t.Fatalf("Unexpected call to InviteRepositoryMock.FindByCode. %v %v", ctx, code) + return +} + +// FindByCodeAfterCounter returns a count of finished InviteRepositoryMock.FindByCode invocations +func (mmFindByCode *InviteRepositoryMock) FindByCodeAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmFindByCode.afterFindByCodeCounter) +} + +// FindByCodeBeforeCounter returns a count of InviteRepositoryMock.FindByCode invocations +func (mmFindByCode *InviteRepositoryMock) FindByCodeBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmFindByCode.beforeFindByCodeCounter) +} + +// Calls returns a list of arguments used in each call to InviteRepositoryMock.FindByCode. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmFindByCode *mInviteRepositoryMockFindByCode) Calls() []*InviteRepositoryMockFindByCodeParams { + mmFindByCode.mutex.RLock() + + argCopy := make([]*InviteRepositoryMockFindByCodeParams, len(mmFindByCode.callArgs)) + copy(argCopy, mmFindByCode.callArgs) + + mmFindByCode.mutex.RUnlock() + + return argCopy +} + +// MinimockFindByCodeDone returns true if the count of the FindByCode invocations corresponds +// the number of defined expectations +func (m *InviteRepositoryMock) MinimockFindByCodeDone() bool { + if m.FindByCodeMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.FindByCodeMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.FindByCodeMock.invocationsDone() +} + +// MinimockFindByCodeInspect logs each unmet expectation +func (m *InviteRepositoryMock) MinimockFindByCodeInspect() { + for _, e := range m.FindByCodeMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to InviteRepositoryMock.FindByCode at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterFindByCodeCounter := mm_atomic.LoadUint64(&m.afterFindByCodeCounter) + // if default expectation was set then invocations count should be greater than zero + if m.FindByCodeMock.defaultExpectation != nil && afterFindByCodeCounter < 1 { + if m.FindByCodeMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to InviteRepositoryMock.FindByCode at\n%s", m.FindByCodeMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to InviteRepositoryMock.FindByCode at\n%s with params: %#v", m.FindByCodeMock.defaultExpectation.expectationOrigins.origin, *m.FindByCodeMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcFindByCode != nil && afterFindByCodeCounter < 1 { + m.t.Errorf("Expected call to InviteRepositoryMock.FindByCode at\n%s", m.funcFindByCodeOrigin) + } + + if !m.FindByCodeMock.invocationsDone() && afterFindByCodeCounter > 0 { + m.t.Errorf("Expected %d calls to InviteRepositoryMock.FindByCode at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.FindByCodeMock.expectedInvocations), m.FindByCodeMock.expectedInvocationsOrigin, afterFindByCodeCounter) + } +} + +type mInviteRepositoryMockGetUserInvites struct { + optional bool + mock *InviteRepositoryMock + defaultExpectation *InviteRepositoryMockGetUserInvitesExpectation + expectations []*InviteRepositoryMockGetUserInvitesExpectation + + callArgs []*InviteRepositoryMockGetUserInvitesParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// InviteRepositoryMockGetUserInvitesExpectation specifies expectation struct of the InviteRepository.GetUserInvites +type InviteRepositoryMockGetUserInvitesExpectation struct { + mock *InviteRepositoryMock + params *InviteRepositoryMockGetUserInvitesParams + paramPtrs *InviteRepositoryMockGetUserInvitesParamPtrs + expectationOrigins InviteRepositoryMockGetUserInvitesExpectationOrigins + results *InviteRepositoryMockGetUserInvitesResults + returnOrigin string + Counter uint64 +} + +// InviteRepositoryMockGetUserInvitesParams contains parameters of the InviteRepository.GetUserInvites +type InviteRepositoryMockGetUserInvitesParams struct { + ctx context.Context + userID int +} + +// InviteRepositoryMockGetUserInvitesParamPtrs contains pointers to parameters of the InviteRepository.GetUserInvites +type InviteRepositoryMockGetUserInvitesParamPtrs struct { + ctx *context.Context + userID *int +} + +// InviteRepositoryMockGetUserInvitesResults contains results of the InviteRepository.GetUserInvites +type InviteRepositoryMockGetUserInvitesResults struct { + ipa1 []*model.InviteCode + err error +} + +// InviteRepositoryMockGetUserInvitesOrigins contains origins of expectations of the InviteRepository.GetUserInvites +type InviteRepositoryMockGetUserInvitesExpectationOrigins struct { + origin string + originCtx string + originUserID string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmGetUserInvites *mInviteRepositoryMockGetUserInvites) Optional() *mInviteRepositoryMockGetUserInvites { + mmGetUserInvites.optional = true + return mmGetUserInvites +} + +// Expect sets up expected params for InviteRepository.GetUserInvites +func (mmGetUserInvites *mInviteRepositoryMockGetUserInvites) Expect(ctx context.Context, userID int) *mInviteRepositoryMockGetUserInvites { + if mmGetUserInvites.mock.funcGetUserInvites != nil { + mmGetUserInvites.mock.t.Fatalf("InviteRepositoryMock.GetUserInvites mock is already set by Set") + } + + if mmGetUserInvites.defaultExpectation == nil { + mmGetUserInvites.defaultExpectation = &InviteRepositoryMockGetUserInvitesExpectation{} + } + + if mmGetUserInvites.defaultExpectation.paramPtrs != nil { + mmGetUserInvites.mock.t.Fatalf("InviteRepositoryMock.GetUserInvites mock is already set by ExpectParams functions") + } + + mmGetUserInvites.defaultExpectation.params = &InviteRepositoryMockGetUserInvitesParams{ctx, userID} + mmGetUserInvites.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmGetUserInvites.expectations { + if minimock.Equal(e.params, mmGetUserInvites.defaultExpectation.params) { + mmGetUserInvites.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetUserInvites.defaultExpectation.params) + } + } + + return mmGetUserInvites +} + +// ExpectCtxParam1 sets up expected param ctx for InviteRepository.GetUserInvites +func (mmGetUserInvites *mInviteRepositoryMockGetUserInvites) ExpectCtxParam1(ctx context.Context) *mInviteRepositoryMockGetUserInvites { + if mmGetUserInvites.mock.funcGetUserInvites != nil { + mmGetUserInvites.mock.t.Fatalf("InviteRepositoryMock.GetUserInvites mock is already set by Set") + } + + if mmGetUserInvites.defaultExpectation == nil { + mmGetUserInvites.defaultExpectation = &InviteRepositoryMockGetUserInvitesExpectation{} + } + + if mmGetUserInvites.defaultExpectation.params != nil { + mmGetUserInvites.mock.t.Fatalf("InviteRepositoryMock.GetUserInvites mock is already set by Expect") + } + + if mmGetUserInvites.defaultExpectation.paramPtrs == nil { + mmGetUserInvites.defaultExpectation.paramPtrs = &InviteRepositoryMockGetUserInvitesParamPtrs{} + } + mmGetUserInvites.defaultExpectation.paramPtrs.ctx = &ctx + mmGetUserInvites.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmGetUserInvites +} + +// ExpectUserIDParam2 sets up expected param userID for InviteRepository.GetUserInvites +func (mmGetUserInvites *mInviteRepositoryMockGetUserInvites) ExpectUserIDParam2(userID int) *mInviteRepositoryMockGetUserInvites { + if mmGetUserInvites.mock.funcGetUserInvites != nil { + mmGetUserInvites.mock.t.Fatalf("InviteRepositoryMock.GetUserInvites mock is already set by Set") + } + + if mmGetUserInvites.defaultExpectation == nil { + mmGetUserInvites.defaultExpectation = &InviteRepositoryMockGetUserInvitesExpectation{} + } + + if mmGetUserInvites.defaultExpectation.params != nil { + mmGetUserInvites.mock.t.Fatalf("InviteRepositoryMock.GetUserInvites mock is already set by Expect") + } + + if mmGetUserInvites.defaultExpectation.paramPtrs == nil { + mmGetUserInvites.defaultExpectation.paramPtrs = &InviteRepositoryMockGetUserInvitesParamPtrs{} + } + mmGetUserInvites.defaultExpectation.paramPtrs.userID = &userID + mmGetUserInvites.defaultExpectation.expectationOrigins.originUserID = minimock.CallerInfo(1) + + return mmGetUserInvites +} + +// Inspect accepts an inspector function that has same arguments as the InviteRepository.GetUserInvites +func (mmGetUserInvites *mInviteRepositoryMockGetUserInvites) Inspect(f func(ctx context.Context, userID int)) *mInviteRepositoryMockGetUserInvites { + if mmGetUserInvites.mock.inspectFuncGetUserInvites != nil { + mmGetUserInvites.mock.t.Fatalf("Inspect function is already set for InviteRepositoryMock.GetUserInvites") + } + + mmGetUserInvites.mock.inspectFuncGetUserInvites = f + + return mmGetUserInvites +} + +// Return sets up results that will be returned by InviteRepository.GetUserInvites +func (mmGetUserInvites *mInviteRepositoryMockGetUserInvites) Return(ipa1 []*model.InviteCode, err error) *InviteRepositoryMock { + if mmGetUserInvites.mock.funcGetUserInvites != nil { + mmGetUserInvites.mock.t.Fatalf("InviteRepositoryMock.GetUserInvites mock is already set by Set") + } + + if mmGetUserInvites.defaultExpectation == nil { + mmGetUserInvites.defaultExpectation = &InviteRepositoryMockGetUserInvitesExpectation{mock: mmGetUserInvites.mock} + } + mmGetUserInvites.defaultExpectation.results = &InviteRepositoryMockGetUserInvitesResults{ipa1, err} + mmGetUserInvites.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmGetUserInvites.mock +} + +// Set uses given function f to mock the InviteRepository.GetUserInvites method +func (mmGetUserInvites *mInviteRepositoryMockGetUserInvites) Set(f func(ctx context.Context, userID int) (ipa1 []*model.InviteCode, err error)) *InviteRepositoryMock { + if mmGetUserInvites.defaultExpectation != nil { + mmGetUserInvites.mock.t.Fatalf("Default expectation is already set for the InviteRepository.GetUserInvites method") + } + + if len(mmGetUserInvites.expectations) > 0 { + mmGetUserInvites.mock.t.Fatalf("Some expectations are already set for the InviteRepository.GetUserInvites method") + } + + mmGetUserInvites.mock.funcGetUserInvites = f + mmGetUserInvites.mock.funcGetUserInvitesOrigin = minimock.CallerInfo(1) + return mmGetUserInvites.mock +} + +// When sets expectation for the InviteRepository.GetUserInvites which will trigger the result defined by the following +// Then helper +func (mmGetUserInvites *mInviteRepositoryMockGetUserInvites) When(ctx context.Context, userID int) *InviteRepositoryMockGetUserInvitesExpectation { + if mmGetUserInvites.mock.funcGetUserInvites != nil { + mmGetUserInvites.mock.t.Fatalf("InviteRepositoryMock.GetUserInvites mock is already set by Set") + } + + expectation := &InviteRepositoryMockGetUserInvitesExpectation{ + mock: mmGetUserInvites.mock, + params: &InviteRepositoryMockGetUserInvitesParams{ctx, userID}, + expectationOrigins: InviteRepositoryMockGetUserInvitesExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmGetUserInvites.expectations = append(mmGetUserInvites.expectations, expectation) + return expectation +} + +// Then sets up InviteRepository.GetUserInvites return parameters for the expectation previously defined by the When method +func (e *InviteRepositoryMockGetUserInvitesExpectation) Then(ipa1 []*model.InviteCode, err error) *InviteRepositoryMock { + e.results = &InviteRepositoryMockGetUserInvitesResults{ipa1, err} + return e.mock +} + +// Times sets number of times InviteRepository.GetUserInvites should be invoked +func (mmGetUserInvites *mInviteRepositoryMockGetUserInvites) Times(n uint64) *mInviteRepositoryMockGetUserInvites { + if n == 0 { + mmGetUserInvites.mock.t.Fatalf("Times of InviteRepositoryMock.GetUserInvites mock can not be zero") + } + mm_atomic.StoreUint64(&mmGetUserInvites.expectedInvocations, n) + mmGetUserInvites.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmGetUserInvites +} + +func (mmGetUserInvites *mInviteRepositoryMockGetUserInvites) invocationsDone() bool { + if len(mmGetUserInvites.expectations) == 0 && mmGetUserInvites.defaultExpectation == nil && mmGetUserInvites.mock.funcGetUserInvites == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmGetUserInvites.mock.afterGetUserInvitesCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmGetUserInvites.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// GetUserInvites implements mm_repository.InviteRepository +func (mmGetUserInvites *InviteRepositoryMock) GetUserInvites(ctx context.Context, userID int) (ipa1 []*model.InviteCode, err error) { + mm_atomic.AddUint64(&mmGetUserInvites.beforeGetUserInvitesCounter, 1) + defer mm_atomic.AddUint64(&mmGetUserInvites.afterGetUserInvitesCounter, 1) + + mmGetUserInvites.t.Helper() + + if mmGetUserInvites.inspectFuncGetUserInvites != nil { + mmGetUserInvites.inspectFuncGetUserInvites(ctx, userID) + } + + mm_params := InviteRepositoryMockGetUserInvitesParams{ctx, userID} + + // Record call args + mmGetUserInvites.GetUserInvitesMock.mutex.Lock() + mmGetUserInvites.GetUserInvitesMock.callArgs = append(mmGetUserInvites.GetUserInvitesMock.callArgs, &mm_params) + mmGetUserInvites.GetUserInvitesMock.mutex.Unlock() + + for _, e := range mmGetUserInvites.GetUserInvitesMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.ipa1, e.results.err + } + } + + if mmGetUserInvites.GetUserInvitesMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmGetUserInvites.GetUserInvitesMock.defaultExpectation.Counter, 1) + mm_want := mmGetUserInvites.GetUserInvitesMock.defaultExpectation.params + mm_want_ptrs := mmGetUserInvites.GetUserInvitesMock.defaultExpectation.paramPtrs + + mm_got := InviteRepositoryMockGetUserInvitesParams{ctx, userID} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmGetUserInvites.t.Errorf("InviteRepositoryMock.GetUserInvites got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetUserInvites.GetUserInvitesMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.userID != nil && !minimock.Equal(*mm_want_ptrs.userID, mm_got.userID) { + mmGetUserInvites.t.Errorf("InviteRepositoryMock.GetUserInvites got unexpected parameter userID, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetUserInvites.GetUserInvitesMock.defaultExpectation.expectationOrigins.originUserID, *mm_want_ptrs.userID, mm_got.userID, minimock.Diff(*mm_want_ptrs.userID, mm_got.userID)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmGetUserInvites.t.Errorf("InviteRepositoryMock.GetUserInvites got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetUserInvites.GetUserInvitesMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmGetUserInvites.GetUserInvitesMock.defaultExpectation.results + if mm_results == nil { + mmGetUserInvites.t.Fatal("No results are set for the InviteRepositoryMock.GetUserInvites") + } + return (*mm_results).ipa1, (*mm_results).err + } + if mmGetUserInvites.funcGetUserInvites != nil { + return mmGetUserInvites.funcGetUserInvites(ctx, userID) + } + mmGetUserInvites.t.Fatalf("Unexpected call to InviteRepositoryMock.GetUserInvites. %v %v", ctx, userID) + return +} + +// GetUserInvitesAfterCounter returns a count of finished InviteRepositoryMock.GetUserInvites invocations +func (mmGetUserInvites *InviteRepositoryMock) GetUserInvitesAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetUserInvites.afterGetUserInvitesCounter) +} + +// GetUserInvitesBeforeCounter returns a count of InviteRepositoryMock.GetUserInvites invocations +func (mmGetUserInvites *InviteRepositoryMock) GetUserInvitesBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetUserInvites.beforeGetUserInvitesCounter) +} + +// Calls returns a list of arguments used in each call to InviteRepositoryMock.GetUserInvites. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmGetUserInvites *mInviteRepositoryMockGetUserInvites) Calls() []*InviteRepositoryMockGetUserInvitesParams { + mmGetUserInvites.mutex.RLock() + + argCopy := make([]*InviteRepositoryMockGetUserInvitesParams, len(mmGetUserInvites.callArgs)) + copy(argCopy, mmGetUserInvites.callArgs) + + mmGetUserInvites.mutex.RUnlock() + + return argCopy +} + +// MinimockGetUserInvitesDone returns true if the count of the GetUserInvites invocations corresponds +// the number of defined expectations +func (m *InviteRepositoryMock) MinimockGetUserInvitesDone() bool { + if m.GetUserInvitesMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.GetUserInvitesMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.GetUserInvitesMock.invocationsDone() +} + +// MinimockGetUserInvitesInspect logs each unmet expectation +func (m *InviteRepositoryMock) MinimockGetUserInvitesInspect() { + for _, e := range m.GetUserInvitesMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to InviteRepositoryMock.GetUserInvites at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterGetUserInvitesCounter := mm_atomic.LoadUint64(&m.afterGetUserInvitesCounter) + // if default expectation was set then invocations count should be greater than zero + if m.GetUserInvitesMock.defaultExpectation != nil && afterGetUserInvitesCounter < 1 { + if m.GetUserInvitesMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to InviteRepositoryMock.GetUserInvites at\n%s", m.GetUserInvitesMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to InviteRepositoryMock.GetUserInvites at\n%s with params: %#v", m.GetUserInvitesMock.defaultExpectation.expectationOrigins.origin, *m.GetUserInvitesMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcGetUserInvites != nil && afterGetUserInvitesCounter < 1 { + m.t.Errorf("Expected call to InviteRepositoryMock.GetUserInvites at\n%s", m.funcGetUserInvitesOrigin) + } + + if !m.GetUserInvitesMock.invocationsDone() && afterGetUserInvitesCounter > 0 { + m.t.Errorf("Expected %d calls to InviteRepositoryMock.GetUserInvites at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.GetUserInvitesMock.expectedInvocations), m.GetUserInvitesMock.expectedInvocationsOrigin, afterGetUserInvitesCounter) + } +} + +type mInviteRepositoryMockIncrementUsedCount struct { + optional bool + mock *InviteRepositoryMock + defaultExpectation *InviteRepositoryMockIncrementUsedCountExpectation + expectations []*InviteRepositoryMockIncrementUsedCountExpectation + + callArgs []*InviteRepositoryMockIncrementUsedCountParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// InviteRepositoryMockIncrementUsedCountExpectation specifies expectation struct of the InviteRepository.IncrementUsedCount +type InviteRepositoryMockIncrementUsedCountExpectation struct { + mock *InviteRepositoryMock + params *InviteRepositoryMockIncrementUsedCountParams + paramPtrs *InviteRepositoryMockIncrementUsedCountParamPtrs + expectationOrigins InviteRepositoryMockIncrementUsedCountExpectationOrigins + results *InviteRepositoryMockIncrementUsedCountResults + returnOrigin string + Counter uint64 +} + +// InviteRepositoryMockIncrementUsedCountParams contains parameters of the InviteRepository.IncrementUsedCount +type InviteRepositoryMockIncrementUsedCountParams struct { + ctx context.Context + code int64 +} + +// InviteRepositoryMockIncrementUsedCountParamPtrs contains pointers to parameters of the InviteRepository.IncrementUsedCount +type InviteRepositoryMockIncrementUsedCountParamPtrs struct { + ctx *context.Context + code *int64 +} + +// InviteRepositoryMockIncrementUsedCountResults contains results of the InviteRepository.IncrementUsedCount +type InviteRepositoryMockIncrementUsedCountResults struct { + err error +} + +// InviteRepositoryMockIncrementUsedCountOrigins contains origins of expectations of the InviteRepository.IncrementUsedCount +type InviteRepositoryMockIncrementUsedCountExpectationOrigins struct { + origin string + originCtx string + originCode string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmIncrementUsedCount *mInviteRepositoryMockIncrementUsedCount) Optional() *mInviteRepositoryMockIncrementUsedCount { + mmIncrementUsedCount.optional = true + return mmIncrementUsedCount +} + +// Expect sets up expected params for InviteRepository.IncrementUsedCount +func (mmIncrementUsedCount *mInviteRepositoryMockIncrementUsedCount) Expect(ctx context.Context, code int64) *mInviteRepositoryMockIncrementUsedCount { + if mmIncrementUsedCount.mock.funcIncrementUsedCount != nil { + mmIncrementUsedCount.mock.t.Fatalf("InviteRepositoryMock.IncrementUsedCount mock is already set by Set") + } + + if mmIncrementUsedCount.defaultExpectation == nil { + mmIncrementUsedCount.defaultExpectation = &InviteRepositoryMockIncrementUsedCountExpectation{} + } + + if mmIncrementUsedCount.defaultExpectation.paramPtrs != nil { + mmIncrementUsedCount.mock.t.Fatalf("InviteRepositoryMock.IncrementUsedCount mock is already set by ExpectParams functions") + } + + mmIncrementUsedCount.defaultExpectation.params = &InviteRepositoryMockIncrementUsedCountParams{ctx, code} + mmIncrementUsedCount.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmIncrementUsedCount.expectations { + if minimock.Equal(e.params, mmIncrementUsedCount.defaultExpectation.params) { + mmIncrementUsedCount.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmIncrementUsedCount.defaultExpectation.params) + } + } + + return mmIncrementUsedCount +} + +// ExpectCtxParam1 sets up expected param ctx for InviteRepository.IncrementUsedCount +func (mmIncrementUsedCount *mInviteRepositoryMockIncrementUsedCount) ExpectCtxParam1(ctx context.Context) *mInviteRepositoryMockIncrementUsedCount { + if mmIncrementUsedCount.mock.funcIncrementUsedCount != nil { + mmIncrementUsedCount.mock.t.Fatalf("InviteRepositoryMock.IncrementUsedCount mock is already set by Set") + } + + if mmIncrementUsedCount.defaultExpectation == nil { + mmIncrementUsedCount.defaultExpectation = &InviteRepositoryMockIncrementUsedCountExpectation{} + } + + if mmIncrementUsedCount.defaultExpectation.params != nil { + mmIncrementUsedCount.mock.t.Fatalf("InviteRepositoryMock.IncrementUsedCount mock is already set by Expect") + } + + if mmIncrementUsedCount.defaultExpectation.paramPtrs == nil { + mmIncrementUsedCount.defaultExpectation.paramPtrs = &InviteRepositoryMockIncrementUsedCountParamPtrs{} + } + mmIncrementUsedCount.defaultExpectation.paramPtrs.ctx = &ctx + mmIncrementUsedCount.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmIncrementUsedCount +} + +// ExpectCodeParam2 sets up expected param code for InviteRepository.IncrementUsedCount +func (mmIncrementUsedCount *mInviteRepositoryMockIncrementUsedCount) ExpectCodeParam2(code int64) *mInviteRepositoryMockIncrementUsedCount { + if mmIncrementUsedCount.mock.funcIncrementUsedCount != nil { + mmIncrementUsedCount.mock.t.Fatalf("InviteRepositoryMock.IncrementUsedCount mock is already set by Set") + } + + if mmIncrementUsedCount.defaultExpectation == nil { + mmIncrementUsedCount.defaultExpectation = &InviteRepositoryMockIncrementUsedCountExpectation{} + } + + if mmIncrementUsedCount.defaultExpectation.params != nil { + mmIncrementUsedCount.mock.t.Fatalf("InviteRepositoryMock.IncrementUsedCount mock is already set by Expect") + } + + if mmIncrementUsedCount.defaultExpectation.paramPtrs == nil { + mmIncrementUsedCount.defaultExpectation.paramPtrs = &InviteRepositoryMockIncrementUsedCountParamPtrs{} + } + mmIncrementUsedCount.defaultExpectation.paramPtrs.code = &code + mmIncrementUsedCount.defaultExpectation.expectationOrigins.originCode = minimock.CallerInfo(1) + + return mmIncrementUsedCount +} + +// Inspect accepts an inspector function that has same arguments as the InviteRepository.IncrementUsedCount +func (mmIncrementUsedCount *mInviteRepositoryMockIncrementUsedCount) Inspect(f func(ctx context.Context, code int64)) *mInviteRepositoryMockIncrementUsedCount { + if mmIncrementUsedCount.mock.inspectFuncIncrementUsedCount != nil { + mmIncrementUsedCount.mock.t.Fatalf("Inspect function is already set for InviteRepositoryMock.IncrementUsedCount") + } + + mmIncrementUsedCount.mock.inspectFuncIncrementUsedCount = f + + return mmIncrementUsedCount +} + +// Return sets up results that will be returned by InviteRepository.IncrementUsedCount +func (mmIncrementUsedCount *mInviteRepositoryMockIncrementUsedCount) Return(err error) *InviteRepositoryMock { + if mmIncrementUsedCount.mock.funcIncrementUsedCount != nil { + mmIncrementUsedCount.mock.t.Fatalf("InviteRepositoryMock.IncrementUsedCount mock is already set by Set") + } + + if mmIncrementUsedCount.defaultExpectation == nil { + mmIncrementUsedCount.defaultExpectation = &InviteRepositoryMockIncrementUsedCountExpectation{mock: mmIncrementUsedCount.mock} + } + mmIncrementUsedCount.defaultExpectation.results = &InviteRepositoryMockIncrementUsedCountResults{err} + mmIncrementUsedCount.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmIncrementUsedCount.mock +} + +// Set uses given function f to mock the InviteRepository.IncrementUsedCount method +func (mmIncrementUsedCount *mInviteRepositoryMockIncrementUsedCount) Set(f func(ctx context.Context, code int64) (err error)) *InviteRepositoryMock { + if mmIncrementUsedCount.defaultExpectation != nil { + mmIncrementUsedCount.mock.t.Fatalf("Default expectation is already set for the InviteRepository.IncrementUsedCount method") + } + + if len(mmIncrementUsedCount.expectations) > 0 { + mmIncrementUsedCount.mock.t.Fatalf("Some expectations are already set for the InviteRepository.IncrementUsedCount method") + } + + mmIncrementUsedCount.mock.funcIncrementUsedCount = f + mmIncrementUsedCount.mock.funcIncrementUsedCountOrigin = minimock.CallerInfo(1) + return mmIncrementUsedCount.mock +} + +// When sets expectation for the InviteRepository.IncrementUsedCount which will trigger the result defined by the following +// Then helper +func (mmIncrementUsedCount *mInviteRepositoryMockIncrementUsedCount) When(ctx context.Context, code int64) *InviteRepositoryMockIncrementUsedCountExpectation { + if mmIncrementUsedCount.mock.funcIncrementUsedCount != nil { + mmIncrementUsedCount.mock.t.Fatalf("InviteRepositoryMock.IncrementUsedCount mock is already set by Set") + } + + expectation := &InviteRepositoryMockIncrementUsedCountExpectation{ + mock: mmIncrementUsedCount.mock, + params: &InviteRepositoryMockIncrementUsedCountParams{ctx, code}, + expectationOrigins: InviteRepositoryMockIncrementUsedCountExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmIncrementUsedCount.expectations = append(mmIncrementUsedCount.expectations, expectation) + return expectation +} + +// Then sets up InviteRepository.IncrementUsedCount return parameters for the expectation previously defined by the When method +func (e *InviteRepositoryMockIncrementUsedCountExpectation) Then(err error) *InviteRepositoryMock { + e.results = &InviteRepositoryMockIncrementUsedCountResults{err} + return e.mock +} + +// Times sets number of times InviteRepository.IncrementUsedCount should be invoked +func (mmIncrementUsedCount *mInviteRepositoryMockIncrementUsedCount) Times(n uint64) *mInviteRepositoryMockIncrementUsedCount { + if n == 0 { + mmIncrementUsedCount.mock.t.Fatalf("Times of InviteRepositoryMock.IncrementUsedCount mock can not be zero") + } + mm_atomic.StoreUint64(&mmIncrementUsedCount.expectedInvocations, n) + mmIncrementUsedCount.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmIncrementUsedCount +} + +func (mmIncrementUsedCount *mInviteRepositoryMockIncrementUsedCount) invocationsDone() bool { + if len(mmIncrementUsedCount.expectations) == 0 && mmIncrementUsedCount.defaultExpectation == nil && mmIncrementUsedCount.mock.funcIncrementUsedCount == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmIncrementUsedCount.mock.afterIncrementUsedCountCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmIncrementUsedCount.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// IncrementUsedCount implements mm_repository.InviteRepository +func (mmIncrementUsedCount *InviteRepositoryMock) IncrementUsedCount(ctx context.Context, code int64) (err error) { + mm_atomic.AddUint64(&mmIncrementUsedCount.beforeIncrementUsedCountCounter, 1) + defer mm_atomic.AddUint64(&mmIncrementUsedCount.afterIncrementUsedCountCounter, 1) + + mmIncrementUsedCount.t.Helper() + + if mmIncrementUsedCount.inspectFuncIncrementUsedCount != nil { + mmIncrementUsedCount.inspectFuncIncrementUsedCount(ctx, code) + } + + mm_params := InviteRepositoryMockIncrementUsedCountParams{ctx, code} + + // Record call args + mmIncrementUsedCount.IncrementUsedCountMock.mutex.Lock() + mmIncrementUsedCount.IncrementUsedCountMock.callArgs = append(mmIncrementUsedCount.IncrementUsedCountMock.callArgs, &mm_params) + mmIncrementUsedCount.IncrementUsedCountMock.mutex.Unlock() + + for _, e := range mmIncrementUsedCount.IncrementUsedCountMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.err + } + } + + if mmIncrementUsedCount.IncrementUsedCountMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmIncrementUsedCount.IncrementUsedCountMock.defaultExpectation.Counter, 1) + mm_want := mmIncrementUsedCount.IncrementUsedCountMock.defaultExpectation.params + mm_want_ptrs := mmIncrementUsedCount.IncrementUsedCountMock.defaultExpectation.paramPtrs + + mm_got := InviteRepositoryMockIncrementUsedCountParams{ctx, code} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmIncrementUsedCount.t.Errorf("InviteRepositoryMock.IncrementUsedCount got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmIncrementUsedCount.IncrementUsedCountMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.code != nil && !minimock.Equal(*mm_want_ptrs.code, mm_got.code) { + mmIncrementUsedCount.t.Errorf("InviteRepositoryMock.IncrementUsedCount got unexpected parameter code, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmIncrementUsedCount.IncrementUsedCountMock.defaultExpectation.expectationOrigins.originCode, *mm_want_ptrs.code, mm_got.code, minimock.Diff(*mm_want_ptrs.code, mm_got.code)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmIncrementUsedCount.t.Errorf("InviteRepositoryMock.IncrementUsedCount got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmIncrementUsedCount.IncrementUsedCountMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmIncrementUsedCount.IncrementUsedCountMock.defaultExpectation.results + if mm_results == nil { + mmIncrementUsedCount.t.Fatal("No results are set for the InviteRepositoryMock.IncrementUsedCount") + } + return (*mm_results).err + } + if mmIncrementUsedCount.funcIncrementUsedCount != nil { + return mmIncrementUsedCount.funcIncrementUsedCount(ctx, code) + } + mmIncrementUsedCount.t.Fatalf("Unexpected call to InviteRepositoryMock.IncrementUsedCount. %v %v", ctx, code) + return +} + +// IncrementUsedCountAfterCounter returns a count of finished InviteRepositoryMock.IncrementUsedCount invocations +func (mmIncrementUsedCount *InviteRepositoryMock) IncrementUsedCountAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmIncrementUsedCount.afterIncrementUsedCountCounter) +} + +// IncrementUsedCountBeforeCounter returns a count of InviteRepositoryMock.IncrementUsedCount invocations +func (mmIncrementUsedCount *InviteRepositoryMock) IncrementUsedCountBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmIncrementUsedCount.beforeIncrementUsedCountCounter) +} + +// Calls returns a list of arguments used in each call to InviteRepositoryMock.IncrementUsedCount. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmIncrementUsedCount *mInviteRepositoryMockIncrementUsedCount) Calls() []*InviteRepositoryMockIncrementUsedCountParams { + mmIncrementUsedCount.mutex.RLock() + + argCopy := make([]*InviteRepositoryMockIncrementUsedCountParams, len(mmIncrementUsedCount.callArgs)) + copy(argCopy, mmIncrementUsedCount.callArgs) + + mmIncrementUsedCount.mutex.RUnlock() + + return argCopy +} + +// MinimockIncrementUsedCountDone returns true if the count of the IncrementUsedCount invocations corresponds +// the number of defined expectations +func (m *InviteRepositoryMock) MinimockIncrementUsedCountDone() bool { + if m.IncrementUsedCountMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.IncrementUsedCountMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.IncrementUsedCountMock.invocationsDone() +} + +// MinimockIncrementUsedCountInspect logs each unmet expectation +func (m *InviteRepositoryMock) MinimockIncrementUsedCountInspect() { + for _, e := range m.IncrementUsedCountMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to InviteRepositoryMock.IncrementUsedCount at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterIncrementUsedCountCounter := mm_atomic.LoadUint64(&m.afterIncrementUsedCountCounter) + // if default expectation was set then invocations count should be greater than zero + if m.IncrementUsedCountMock.defaultExpectation != nil && afterIncrementUsedCountCounter < 1 { + if m.IncrementUsedCountMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to InviteRepositoryMock.IncrementUsedCount at\n%s", m.IncrementUsedCountMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to InviteRepositoryMock.IncrementUsedCount at\n%s with params: %#v", m.IncrementUsedCountMock.defaultExpectation.expectationOrigins.origin, *m.IncrementUsedCountMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcIncrementUsedCount != nil && afterIncrementUsedCountCounter < 1 { + m.t.Errorf("Expected call to InviteRepositoryMock.IncrementUsedCount at\n%s", m.funcIncrementUsedCountOrigin) + } + + if !m.IncrementUsedCountMock.invocationsDone() && afterIncrementUsedCountCounter > 0 { + m.t.Errorf("Expected %d calls to InviteRepositoryMock.IncrementUsedCount at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.IncrementUsedCountMock.expectedInvocations), m.IncrementUsedCountMock.expectedInvocationsOrigin, afterIncrementUsedCountCounter) + } +} + +// MinimockFinish checks that all mocked methods have been called the expected number of times +func (m *InviteRepositoryMock) MinimockFinish() { + m.finishOnce.Do(func() { + if !m.minimockDone() { + m.MinimockCreateInspect() + + m.MinimockDeactivateExpiredInspect() + + m.MinimockFindByCodeInspect() + + m.MinimockGetUserInvitesInspect() + + m.MinimockIncrementUsedCountInspect() + } + }) +} + +// MinimockWait waits for all mocked methods to be called the expected number of times +func (m *InviteRepositoryMock) MinimockWait(timeout mm_time.Duration) { + timeoutCh := mm_time.After(timeout) + for { + if m.minimockDone() { + return + } + select { + case <-timeoutCh: + m.MinimockFinish() + return + case <-mm_time.After(10 * mm_time.Millisecond): + } + } +} + +func (m *InviteRepositoryMock) minimockDone() bool { + done := true + return done && + m.MinimockCreateDone() && + m.MinimockDeactivateExpiredDone() && + m.MinimockFindByCodeDone() && + m.MinimockGetUserInvitesDone() && + m.MinimockIncrementUsedCountDone() +} diff --git a/internal/mocks/invite_service_mock.go b/internal/mocks/invite_service_mock.go new file mode 100644 index 0000000..a0dedb9 --- /dev/null +++ b/internal/mocks/invite_service_mock.go @@ -0,0 +1,836 @@ +// Code generated by http://github.com/gojuno/minimock (v3.4.7). DO NOT EDIT. + +package mocks + +//go:generate minimock -i smart-search-back/internal/service.InviteService -o invite_service_mock.go -n InviteServiceMock -p mocks + +import ( + "context" + "smart-search-back/internal/model" + "sync" + mm_atomic "sync/atomic" + mm_time "time" + + "github.com/gojuno/minimock/v3" +) + +// InviteServiceMock implements mm_service.InviteService +type InviteServiceMock struct { + t minimock.Tester + finishOnce sync.Once + + funcGenerate func(ctx context.Context, userID int, maxUses int, ttlDays int) (ip1 *model.InviteCode, err error) + funcGenerateOrigin string + inspectFuncGenerate func(ctx context.Context, userID int, maxUses int, ttlDays int) + afterGenerateCounter uint64 + beforeGenerateCounter uint64 + GenerateMock mInviteServiceMockGenerate + + funcGetInfo func(ctx context.Context, code int64) (ip1 *model.InviteCode, err error) + funcGetInfoOrigin string + inspectFuncGetInfo func(ctx context.Context, code int64) + afterGetInfoCounter uint64 + beforeGetInfoCounter uint64 + GetInfoMock mInviteServiceMockGetInfo +} + +// NewInviteServiceMock returns a mock for mm_service.InviteService +func NewInviteServiceMock(t minimock.Tester) *InviteServiceMock { + m := &InviteServiceMock{t: t} + + if controller, ok := t.(minimock.MockController); ok { + controller.RegisterMocker(m) + } + + m.GenerateMock = mInviteServiceMockGenerate{mock: m} + m.GenerateMock.callArgs = []*InviteServiceMockGenerateParams{} + + m.GetInfoMock = mInviteServiceMockGetInfo{mock: m} + m.GetInfoMock.callArgs = []*InviteServiceMockGetInfoParams{} + + t.Cleanup(m.MinimockFinish) + + return m +} + +type mInviteServiceMockGenerate struct { + optional bool + mock *InviteServiceMock + defaultExpectation *InviteServiceMockGenerateExpectation + expectations []*InviteServiceMockGenerateExpectation + + callArgs []*InviteServiceMockGenerateParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// InviteServiceMockGenerateExpectation specifies expectation struct of the InviteService.Generate +type InviteServiceMockGenerateExpectation struct { + mock *InviteServiceMock + params *InviteServiceMockGenerateParams + paramPtrs *InviteServiceMockGenerateParamPtrs + expectationOrigins InviteServiceMockGenerateExpectationOrigins + results *InviteServiceMockGenerateResults + returnOrigin string + Counter uint64 +} + +// InviteServiceMockGenerateParams contains parameters of the InviteService.Generate +type InviteServiceMockGenerateParams struct { + ctx context.Context + userID int + maxUses int + ttlDays int +} + +// InviteServiceMockGenerateParamPtrs contains pointers to parameters of the InviteService.Generate +type InviteServiceMockGenerateParamPtrs struct { + ctx *context.Context + userID *int + maxUses *int + ttlDays *int +} + +// InviteServiceMockGenerateResults contains results of the InviteService.Generate +type InviteServiceMockGenerateResults struct { + ip1 *model.InviteCode + err error +} + +// InviteServiceMockGenerateOrigins contains origins of expectations of the InviteService.Generate +type InviteServiceMockGenerateExpectationOrigins struct { + origin string + originCtx string + originUserID string + originMaxUses string + originTtlDays string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmGenerate *mInviteServiceMockGenerate) Optional() *mInviteServiceMockGenerate { + mmGenerate.optional = true + return mmGenerate +} + +// Expect sets up expected params for InviteService.Generate +func (mmGenerate *mInviteServiceMockGenerate) Expect(ctx context.Context, userID int, maxUses int, ttlDays int) *mInviteServiceMockGenerate { + if mmGenerate.mock.funcGenerate != nil { + mmGenerate.mock.t.Fatalf("InviteServiceMock.Generate mock is already set by Set") + } + + if mmGenerate.defaultExpectation == nil { + mmGenerate.defaultExpectation = &InviteServiceMockGenerateExpectation{} + } + + if mmGenerate.defaultExpectation.paramPtrs != nil { + mmGenerate.mock.t.Fatalf("InviteServiceMock.Generate mock is already set by ExpectParams functions") + } + + mmGenerate.defaultExpectation.params = &InviteServiceMockGenerateParams{ctx, userID, maxUses, ttlDays} + mmGenerate.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmGenerate.expectations { + if minimock.Equal(e.params, mmGenerate.defaultExpectation.params) { + mmGenerate.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGenerate.defaultExpectation.params) + } + } + + return mmGenerate +} + +// ExpectCtxParam1 sets up expected param ctx for InviteService.Generate +func (mmGenerate *mInviteServiceMockGenerate) ExpectCtxParam1(ctx context.Context) *mInviteServiceMockGenerate { + if mmGenerate.mock.funcGenerate != nil { + mmGenerate.mock.t.Fatalf("InviteServiceMock.Generate mock is already set by Set") + } + + if mmGenerate.defaultExpectation == nil { + mmGenerate.defaultExpectation = &InviteServiceMockGenerateExpectation{} + } + + if mmGenerate.defaultExpectation.params != nil { + mmGenerate.mock.t.Fatalf("InviteServiceMock.Generate mock is already set by Expect") + } + + if mmGenerate.defaultExpectation.paramPtrs == nil { + mmGenerate.defaultExpectation.paramPtrs = &InviteServiceMockGenerateParamPtrs{} + } + mmGenerate.defaultExpectation.paramPtrs.ctx = &ctx + mmGenerate.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmGenerate +} + +// ExpectUserIDParam2 sets up expected param userID for InviteService.Generate +func (mmGenerate *mInviteServiceMockGenerate) ExpectUserIDParam2(userID int) *mInviteServiceMockGenerate { + if mmGenerate.mock.funcGenerate != nil { + mmGenerate.mock.t.Fatalf("InviteServiceMock.Generate mock is already set by Set") + } + + if mmGenerate.defaultExpectation == nil { + mmGenerate.defaultExpectation = &InviteServiceMockGenerateExpectation{} + } + + if mmGenerate.defaultExpectation.params != nil { + mmGenerate.mock.t.Fatalf("InviteServiceMock.Generate mock is already set by Expect") + } + + if mmGenerate.defaultExpectation.paramPtrs == nil { + mmGenerate.defaultExpectation.paramPtrs = &InviteServiceMockGenerateParamPtrs{} + } + mmGenerate.defaultExpectation.paramPtrs.userID = &userID + mmGenerate.defaultExpectation.expectationOrigins.originUserID = minimock.CallerInfo(1) + + return mmGenerate +} + +// ExpectMaxUsesParam3 sets up expected param maxUses for InviteService.Generate +func (mmGenerate *mInviteServiceMockGenerate) ExpectMaxUsesParam3(maxUses int) *mInviteServiceMockGenerate { + if mmGenerate.mock.funcGenerate != nil { + mmGenerate.mock.t.Fatalf("InviteServiceMock.Generate mock is already set by Set") + } + + if mmGenerate.defaultExpectation == nil { + mmGenerate.defaultExpectation = &InviteServiceMockGenerateExpectation{} + } + + if mmGenerate.defaultExpectation.params != nil { + mmGenerate.mock.t.Fatalf("InviteServiceMock.Generate mock is already set by Expect") + } + + if mmGenerate.defaultExpectation.paramPtrs == nil { + mmGenerate.defaultExpectation.paramPtrs = &InviteServiceMockGenerateParamPtrs{} + } + mmGenerate.defaultExpectation.paramPtrs.maxUses = &maxUses + mmGenerate.defaultExpectation.expectationOrigins.originMaxUses = minimock.CallerInfo(1) + + return mmGenerate +} + +// ExpectTtlDaysParam4 sets up expected param ttlDays for InviteService.Generate +func (mmGenerate *mInviteServiceMockGenerate) ExpectTtlDaysParam4(ttlDays int) *mInviteServiceMockGenerate { + if mmGenerate.mock.funcGenerate != nil { + mmGenerate.mock.t.Fatalf("InviteServiceMock.Generate mock is already set by Set") + } + + if mmGenerate.defaultExpectation == nil { + mmGenerate.defaultExpectation = &InviteServiceMockGenerateExpectation{} + } + + if mmGenerate.defaultExpectation.params != nil { + mmGenerate.mock.t.Fatalf("InviteServiceMock.Generate mock is already set by Expect") + } + + if mmGenerate.defaultExpectation.paramPtrs == nil { + mmGenerate.defaultExpectation.paramPtrs = &InviteServiceMockGenerateParamPtrs{} + } + mmGenerate.defaultExpectation.paramPtrs.ttlDays = &ttlDays + mmGenerate.defaultExpectation.expectationOrigins.originTtlDays = minimock.CallerInfo(1) + + return mmGenerate +} + +// Inspect accepts an inspector function that has same arguments as the InviteService.Generate +func (mmGenerate *mInviteServiceMockGenerate) Inspect(f func(ctx context.Context, userID int, maxUses int, ttlDays int)) *mInviteServiceMockGenerate { + if mmGenerate.mock.inspectFuncGenerate != nil { + mmGenerate.mock.t.Fatalf("Inspect function is already set for InviteServiceMock.Generate") + } + + mmGenerate.mock.inspectFuncGenerate = f + + return mmGenerate +} + +// Return sets up results that will be returned by InviteService.Generate +func (mmGenerate *mInviteServiceMockGenerate) Return(ip1 *model.InviteCode, err error) *InviteServiceMock { + if mmGenerate.mock.funcGenerate != nil { + mmGenerate.mock.t.Fatalf("InviteServiceMock.Generate mock is already set by Set") + } + + if mmGenerate.defaultExpectation == nil { + mmGenerate.defaultExpectation = &InviteServiceMockGenerateExpectation{mock: mmGenerate.mock} + } + mmGenerate.defaultExpectation.results = &InviteServiceMockGenerateResults{ip1, err} + mmGenerate.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmGenerate.mock +} + +// Set uses given function f to mock the InviteService.Generate method +func (mmGenerate *mInviteServiceMockGenerate) Set(f func(ctx context.Context, userID int, maxUses int, ttlDays int) (ip1 *model.InviteCode, err error)) *InviteServiceMock { + if mmGenerate.defaultExpectation != nil { + mmGenerate.mock.t.Fatalf("Default expectation is already set for the InviteService.Generate method") + } + + if len(mmGenerate.expectations) > 0 { + mmGenerate.mock.t.Fatalf("Some expectations are already set for the InviteService.Generate method") + } + + mmGenerate.mock.funcGenerate = f + mmGenerate.mock.funcGenerateOrigin = minimock.CallerInfo(1) + return mmGenerate.mock +} + +// When sets expectation for the InviteService.Generate which will trigger the result defined by the following +// Then helper +func (mmGenerate *mInviteServiceMockGenerate) When(ctx context.Context, userID int, maxUses int, ttlDays int) *InviteServiceMockGenerateExpectation { + if mmGenerate.mock.funcGenerate != nil { + mmGenerate.mock.t.Fatalf("InviteServiceMock.Generate mock is already set by Set") + } + + expectation := &InviteServiceMockGenerateExpectation{ + mock: mmGenerate.mock, + params: &InviteServiceMockGenerateParams{ctx, userID, maxUses, ttlDays}, + expectationOrigins: InviteServiceMockGenerateExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmGenerate.expectations = append(mmGenerate.expectations, expectation) + return expectation +} + +// Then sets up InviteService.Generate return parameters for the expectation previously defined by the When method +func (e *InviteServiceMockGenerateExpectation) Then(ip1 *model.InviteCode, err error) *InviteServiceMock { + e.results = &InviteServiceMockGenerateResults{ip1, err} + return e.mock +} + +// Times sets number of times InviteService.Generate should be invoked +func (mmGenerate *mInviteServiceMockGenerate) Times(n uint64) *mInviteServiceMockGenerate { + if n == 0 { + mmGenerate.mock.t.Fatalf("Times of InviteServiceMock.Generate mock can not be zero") + } + mm_atomic.StoreUint64(&mmGenerate.expectedInvocations, n) + mmGenerate.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmGenerate +} + +func (mmGenerate *mInviteServiceMockGenerate) invocationsDone() bool { + if len(mmGenerate.expectations) == 0 && mmGenerate.defaultExpectation == nil && mmGenerate.mock.funcGenerate == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmGenerate.mock.afterGenerateCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmGenerate.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// Generate implements mm_service.InviteService +func (mmGenerate *InviteServiceMock) Generate(ctx context.Context, userID int, maxUses int, ttlDays int) (ip1 *model.InviteCode, err error) { + mm_atomic.AddUint64(&mmGenerate.beforeGenerateCounter, 1) + defer mm_atomic.AddUint64(&mmGenerate.afterGenerateCounter, 1) + + mmGenerate.t.Helper() + + if mmGenerate.inspectFuncGenerate != nil { + mmGenerate.inspectFuncGenerate(ctx, userID, maxUses, ttlDays) + } + + mm_params := InviteServiceMockGenerateParams{ctx, userID, maxUses, ttlDays} + + // Record call args + mmGenerate.GenerateMock.mutex.Lock() + mmGenerate.GenerateMock.callArgs = append(mmGenerate.GenerateMock.callArgs, &mm_params) + mmGenerate.GenerateMock.mutex.Unlock() + + for _, e := range mmGenerate.GenerateMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.ip1, e.results.err + } + } + + if mmGenerate.GenerateMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmGenerate.GenerateMock.defaultExpectation.Counter, 1) + mm_want := mmGenerate.GenerateMock.defaultExpectation.params + mm_want_ptrs := mmGenerate.GenerateMock.defaultExpectation.paramPtrs + + mm_got := InviteServiceMockGenerateParams{ctx, userID, maxUses, ttlDays} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmGenerate.t.Errorf("InviteServiceMock.Generate got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGenerate.GenerateMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.userID != nil && !minimock.Equal(*mm_want_ptrs.userID, mm_got.userID) { + mmGenerate.t.Errorf("InviteServiceMock.Generate got unexpected parameter userID, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGenerate.GenerateMock.defaultExpectation.expectationOrigins.originUserID, *mm_want_ptrs.userID, mm_got.userID, minimock.Diff(*mm_want_ptrs.userID, mm_got.userID)) + } + + if mm_want_ptrs.maxUses != nil && !minimock.Equal(*mm_want_ptrs.maxUses, mm_got.maxUses) { + mmGenerate.t.Errorf("InviteServiceMock.Generate got unexpected parameter maxUses, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGenerate.GenerateMock.defaultExpectation.expectationOrigins.originMaxUses, *mm_want_ptrs.maxUses, mm_got.maxUses, minimock.Diff(*mm_want_ptrs.maxUses, mm_got.maxUses)) + } + + if mm_want_ptrs.ttlDays != nil && !minimock.Equal(*mm_want_ptrs.ttlDays, mm_got.ttlDays) { + mmGenerate.t.Errorf("InviteServiceMock.Generate got unexpected parameter ttlDays, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGenerate.GenerateMock.defaultExpectation.expectationOrigins.originTtlDays, *mm_want_ptrs.ttlDays, mm_got.ttlDays, minimock.Diff(*mm_want_ptrs.ttlDays, mm_got.ttlDays)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmGenerate.t.Errorf("InviteServiceMock.Generate got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGenerate.GenerateMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmGenerate.GenerateMock.defaultExpectation.results + if mm_results == nil { + mmGenerate.t.Fatal("No results are set for the InviteServiceMock.Generate") + } + return (*mm_results).ip1, (*mm_results).err + } + if mmGenerate.funcGenerate != nil { + return mmGenerate.funcGenerate(ctx, userID, maxUses, ttlDays) + } + mmGenerate.t.Fatalf("Unexpected call to InviteServiceMock.Generate. %v %v %v %v", ctx, userID, maxUses, ttlDays) + return +} + +// GenerateAfterCounter returns a count of finished InviteServiceMock.Generate invocations +func (mmGenerate *InviteServiceMock) GenerateAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmGenerate.afterGenerateCounter) +} + +// GenerateBeforeCounter returns a count of InviteServiceMock.Generate invocations +func (mmGenerate *InviteServiceMock) GenerateBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmGenerate.beforeGenerateCounter) +} + +// Calls returns a list of arguments used in each call to InviteServiceMock.Generate. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmGenerate *mInviteServiceMockGenerate) Calls() []*InviteServiceMockGenerateParams { + mmGenerate.mutex.RLock() + + argCopy := make([]*InviteServiceMockGenerateParams, len(mmGenerate.callArgs)) + copy(argCopy, mmGenerate.callArgs) + + mmGenerate.mutex.RUnlock() + + return argCopy +} + +// MinimockGenerateDone returns true if the count of the Generate invocations corresponds +// the number of defined expectations +func (m *InviteServiceMock) MinimockGenerateDone() bool { + if m.GenerateMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.GenerateMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.GenerateMock.invocationsDone() +} + +// MinimockGenerateInspect logs each unmet expectation +func (m *InviteServiceMock) MinimockGenerateInspect() { + for _, e := range m.GenerateMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to InviteServiceMock.Generate at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterGenerateCounter := mm_atomic.LoadUint64(&m.afterGenerateCounter) + // if default expectation was set then invocations count should be greater than zero + if m.GenerateMock.defaultExpectation != nil && afterGenerateCounter < 1 { + if m.GenerateMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to InviteServiceMock.Generate at\n%s", m.GenerateMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to InviteServiceMock.Generate at\n%s with params: %#v", m.GenerateMock.defaultExpectation.expectationOrigins.origin, *m.GenerateMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcGenerate != nil && afterGenerateCounter < 1 { + m.t.Errorf("Expected call to InviteServiceMock.Generate at\n%s", m.funcGenerateOrigin) + } + + if !m.GenerateMock.invocationsDone() && afterGenerateCounter > 0 { + m.t.Errorf("Expected %d calls to InviteServiceMock.Generate at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.GenerateMock.expectedInvocations), m.GenerateMock.expectedInvocationsOrigin, afterGenerateCounter) + } +} + +type mInviteServiceMockGetInfo struct { + optional bool + mock *InviteServiceMock + defaultExpectation *InviteServiceMockGetInfoExpectation + expectations []*InviteServiceMockGetInfoExpectation + + callArgs []*InviteServiceMockGetInfoParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// InviteServiceMockGetInfoExpectation specifies expectation struct of the InviteService.GetInfo +type InviteServiceMockGetInfoExpectation struct { + mock *InviteServiceMock + params *InviteServiceMockGetInfoParams + paramPtrs *InviteServiceMockGetInfoParamPtrs + expectationOrigins InviteServiceMockGetInfoExpectationOrigins + results *InviteServiceMockGetInfoResults + returnOrigin string + Counter uint64 +} + +// InviteServiceMockGetInfoParams contains parameters of the InviteService.GetInfo +type InviteServiceMockGetInfoParams struct { + ctx context.Context + code int64 +} + +// InviteServiceMockGetInfoParamPtrs contains pointers to parameters of the InviteService.GetInfo +type InviteServiceMockGetInfoParamPtrs struct { + ctx *context.Context + code *int64 +} + +// InviteServiceMockGetInfoResults contains results of the InviteService.GetInfo +type InviteServiceMockGetInfoResults struct { + ip1 *model.InviteCode + err error +} + +// InviteServiceMockGetInfoOrigins contains origins of expectations of the InviteService.GetInfo +type InviteServiceMockGetInfoExpectationOrigins struct { + origin string + originCtx string + originCode string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmGetInfo *mInviteServiceMockGetInfo) Optional() *mInviteServiceMockGetInfo { + mmGetInfo.optional = true + return mmGetInfo +} + +// Expect sets up expected params for InviteService.GetInfo +func (mmGetInfo *mInviteServiceMockGetInfo) Expect(ctx context.Context, code int64) *mInviteServiceMockGetInfo { + if mmGetInfo.mock.funcGetInfo != nil { + mmGetInfo.mock.t.Fatalf("InviteServiceMock.GetInfo mock is already set by Set") + } + + if mmGetInfo.defaultExpectation == nil { + mmGetInfo.defaultExpectation = &InviteServiceMockGetInfoExpectation{} + } + + if mmGetInfo.defaultExpectation.paramPtrs != nil { + mmGetInfo.mock.t.Fatalf("InviteServiceMock.GetInfo mock is already set by ExpectParams functions") + } + + mmGetInfo.defaultExpectation.params = &InviteServiceMockGetInfoParams{ctx, code} + mmGetInfo.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmGetInfo.expectations { + if minimock.Equal(e.params, mmGetInfo.defaultExpectation.params) { + mmGetInfo.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetInfo.defaultExpectation.params) + } + } + + return mmGetInfo +} + +// ExpectCtxParam1 sets up expected param ctx for InviteService.GetInfo +func (mmGetInfo *mInviteServiceMockGetInfo) ExpectCtxParam1(ctx context.Context) *mInviteServiceMockGetInfo { + if mmGetInfo.mock.funcGetInfo != nil { + mmGetInfo.mock.t.Fatalf("InviteServiceMock.GetInfo mock is already set by Set") + } + + if mmGetInfo.defaultExpectation == nil { + mmGetInfo.defaultExpectation = &InviteServiceMockGetInfoExpectation{} + } + + if mmGetInfo.defaultExpectation.params != nil { + mmGetInfo.mock.t.Fatalf("InviteServiceMock.GetInfo mock is already set by Expect") + } + + if mmGetInfo.defaultExpectation.paramPtrs == nil { + mmGetInfo.defaultExpectation.paramPtrs = &InviteServiceMockGetInfoParamPtrs{} + } + mmGetInfo.defaultExpectation.paramPtrs.ctx = &ctx + mmGetInfo.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmGetInfo +} + +// ExpectCodeParam2 sets up expected param code for InviteService.GetInfo +func (mmGetInfo *mInviteServiceMockGetInfo) ExpectCodeParam2(code int64) *mInviteServiceMockGetInfo { + if mmGetInfo.mock.funcGetInfo != nil { + mmGetInfo.mock.t.Fatalf("InviteServiceMock.GetInfo mock is already set by Set") + } + + if mmGetInfo.defaultExpectation == nil { + mmGetInfo.defaultExpectation = &InviteServiceMockGetInfoExpectation{} + } + + if mmGetInfo.defaultExpectation.params != nil { + mmGetInfo.mock.t.Fatalf("InviteServiceMock.GetInfo mock is already set by Expect") + } + + if mmGetInfo.defaultExpectation.paramPtrs == nil { + mmGetInfo.defaultExpectation.paramPtrs = &InviteServiceMockGetInfoParamPtrs{} + } + mmGetInfo.defaultExpectation.paramPtrs.code = &code + mmGetInfo.defaultExpectation.expectationOrigins.originCode = minimock.CallerInfo(1) + + return mmGetInfo +} + +// Inspect accepts an inspector function that has same arguments as the InviteService.GetInfo +func (mmGetInfo *mInviteServiceMockGetInfo) Inspect(f func(ctx context.Context, code int64)) *mInviteServiceMockGetInfo { + if mmGetInfo.mock.inspectFuncGetInfo != nil { + mmGetInfo.mock.t.Fatalf("Inspect function is already set for InviteServiceMock.GetInfo") + } + + mmGetInfo.mock.inspectFuncGetInfo = f + + return mmGetInfo +} + +// Return sets up results that will be returned by InviteService.GetInfo +func (mmGetInfo *mInviteServiceMockGetInfo) Return(ip1 *model.InviteCode, err error) *InviteServiceMock { + if mmGetInfo.mock.funcGetInfo != nil { + mmGetInfo.mock.t.Fatalf("InviteServiceMock.GetInfo mock is already set by Set") + } + + if mmGetInfo.defaultExpectation == nil { + mmGetInfo.defaultExpectation = &InviteServiceMockGetInfoExpectation{mock: mmGetInfo.mock} + } + mmGetInfo.defaultExpectation.results = &InviteServiceMockGetInfoResults{ip1, err} + mmGetInfo.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmGetInfo.mock +} + +// Set uses given function f to mock the InviteService.GetInfo method +func (mmGetInfo *mInviteServiceMockGetInfo) Set(f func(ctx context.Context, code int64) (ip1 *model.InviteCode, err error)) *InviteServiceMock { + if mmGetInfo.defaultExpectation != nil { + mmGetInfo.mock.t.Fatalf("Default expectation is already set for the InviteService.GetInfo method") + } + + if len(mmGetInfo.expectations) > 0 { + mmGetInfo.mock.t.Fatalf("Some expectations are already set for the InviteService.GetInfo method") + } + + mmGetInfo.mock.funcGetInfo = f + mmGetInfo.mock.funcGetInfoOrigin = minimock.CallerInfo(1) + return mmGetInfo.mock +} + +// When sets expectation for the InviteService.GetInfo which will trigger the result defined by the following +// Then helper +func (mmGetInfo *mInviteServiceMockGetInfo) When(ctx context.Context, code int64) *InviteServiceMockGetInfoExpectation { + if mmGetInfo.mock.funcGetInfo != nil { + mmGetInfo.mock.t.Fatalf("InviteServiceMock.GetInfo mock is already set by Set") + } + + expectation := &InviteServiceMockGetInfoExpectation{ + mock: mmGetInfo.mock, + params: &InviteServiceMockGetInfoParams{ctx, code}, + expectationOrigins: InviteServiceMockGetInfoExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmGetInfo.expectations = append(mmGetInfo.expectations, expectation) + return expectation +} + +// Then sets up InviteService.GetInfo return parameters for the expectation previously defined by the When method +func (e *InviteServiceMockGetInfoExpectation) Then(ip1 *model.InviteCode, err error) *InviteServiceMock { + e.results = &InviteServiceMockGetInfoResults{ip1, err} + return e.mock +} + +// Times sets number of times InviteService.GetInfo should be invoked +func (mmGetInfo *mInviteServiceMockGetInfo) Times(n uint64) *mInviteServiceMockGetInfo { + if n == 0 { + mmGetInfo.mock.t.Fatalf("Times of InviteServiceMock.GetInfo mock can not be zero") + } + mm_atomic.StoreUint64(&mmGetInfo.expectedInvocations, n) + mmGetInfo.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmGetInfo +} + +func (mmGetInfo *mInviteServiceMockGetInfo) invocationsDone() bool { + if len(mmGetInfo.expectations) == 0 && mmGetInfo.defaultExpectation == nil && mmGetInfo.mock.funcGetInfo == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmGetInfo.mock.afterGetInfoCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmGetInfo.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// GetInfo implements mm_service.InviteService +func (mmGetInfo *InviteServiceMock) GetInfo(ctx context.Context, code int64) (ip1 *model.InviteCode, err error) { + mm_atomic.AddUint64(&mmGetInfo.beforeGetInfoCounter, 1) + defer mm_atomic.AddUint64(&mmGetInfo.afterGetInfoCounter, 1) + + mmGetInfo.t.Helper() + + if mmGetInfo.inspectFuncGetInfo != nil { + mmGetInfo.inspectFuncGetInfo(ctx, code) + } + + mm_params := InviteServiceMockGetInfoParams{ctx, code} + + // Record call args + mmGetInfo.GetInfoMock.mutex.Lock() + mmGetInfo.GetInfoMock.callArgs = append(mmGetInfo.GetInfoMock.callArgs, &mm_params) + mmGetInfo.GetInfoMock.mutex.Unlock() + + for _, e := range mmGetInfo.GetInfoMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.ip1, e.results.err + } + } + + if mmGetInfo.GetInfoMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmGetInfo.GetInfoMock.defaultExpectation.Counter, 1) + mm_want := mmGetInfo.GetInfoMock.defaultExpectation.params + mm_want_ptrs := mmGetInfo.GetInfoMock.defaultExpectation.paramPtrs + + mm_got := InviteServiceMockGetInfoParams{ctx, code} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmGetInfo.t.Errorf("InviteServiceMock.GetInfo got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetInfo.GetInfoMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.code != nil && !minimock.Equal(*mm_want_ptrs.code, mm_got.code) { + mmGetInfo.t.Errorf("InviteServiceMock.GetInfo got unexpected parameter code, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetInfo.GetInfoMock.defaultExpectation.expectationOrigins.originCode, *mm_want_ptrs.code, mm_got.code, minimock.Diff(*mm_want_ptrs.code, mm_got.code)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmGetInfo.t.Errorf("InviteServiceMock.GetInfo got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetInfo.GetInfoMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmGetInfo.GetInfoMock.defaultExpectation.results + if mm_results == nil { + mmGetInfo.t.Fatal("No results are set for the InviteServiceMock.GetInfo") + } + return (*mm_results).ip1, (*mm_results).err + } + if mmGetInfo.funcGetInfo != nil { + return mmGetInfo.funcGetInfo(ctx, code) + } + mmGetInfo.t.Fatalf("Unexpected call to InviteServiceMock.GetInfo. %v %v", ctx, code) + return +} + +// GetInfoAfterCounter returns a count of finished InviteServiceMock.GetInfo invocations +func (mmGetInfo *InviteServiceMock) GetInfoAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetInfo.afterGetInfoCounter) +} + +// GetInfoBeforeCounter returns a count of InviteServiceMock.GetInfo invocations +func (mmGetInfo *InviteServiceMock) GetInfoBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetInfo.beforeGetInfoCounter) +} + +// Calls returns a list of arguments used in each call to InviteServiceMock.GetInfo. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmGetInfo *mInviteServiceMockGetInfo) Calls() []*InviteServiceMockGetInfoParams { + mmGetInfo.mutex.RLock() + + argCopy := make([]*InviteServiceMockGetInfoParams, len(mmGetInfo.callArgs)) + copy(argCopy, mmGetInfo.callArgs) + + mmGetInfo.mutex.RUnlock() + + return argCopy +} + +// MinimockGetInfoDone returns true if the count of the GetInfo invocations corresponds +// the number of defined expectations +func (m *InviteServiceMock) MinimockGetInfoDone() bool { + if m.GetInfoMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.GetInfoMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.GetInfoMock.invocationsDone() +} + +// MinimockGetInfoInspect logs each unmet expectation +func (m *InviteServiceMock) MinimockGetInfoInspect() { + for _, e := range m.GetInfoMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to InviteServiceMock.GetInfo at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterGetInfoCounter := mm_atomic.LoadUint64(&m.afterGetInfoCounter) + // if default expectation was set then invocations count should be greater than zero + if m.GetInfoMock.defaultExpectation != nil && afterGetInfoCounter < 1 { + if m.GetInfoMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to InviteServiceMock.GetInfo at\n%s", m.GetInfoMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to InviteServiceMock.GetInfo at\n%s with params: %#v", m.GetInfoMock.defaultExpectation.expectationOrigins.origin, *m.GetInfoMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcGetInfo != nil && afterGetInfoCounter < 1 { + m.t.Errorf("Expected call to InviteServiceMock.GetInfo at\n%s", m.funcGetInfoOrigin) + } + + if !m.GetInfoMock.invocationsDone() && afterGetInfoCounter > 0 { + m.t.Errorf("Expected %d calls to InviteServiceMock.GetInfo at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.GetInfoMock.expectedInvocations), m.GetInfoMock.expectedInvocationsOrigin, afterGetInfoCounter) + } +} + +// MinimockFinish checks that all mocked methods have been called the expected number of times +func (m *InviteServiceMock) MinimockFinish() { + m.finishOnce.Do(func() { + if !m.minimockDone() { + m.MinimockGenerateInspect() + + m.MinimockGetInfoInspect() + } + }) +} + +// MinimockWait waits for all mocked methods to be called the expected number of times +func (m *InviteServiceMock) MinimockWait(timeout mm_time.Duration) { + timeoutCh := mm_time.After(timeout) + for { + if m.minimockDone() { + return + } + select { + case <-timeoutCh: + m.MinimockFinish() + return + case <-mm_time.After(10 * mm_time.Millisecond): + } + } +} + +func (m *InviteServiceMock) minimockDone() bool { + done := true + return done && + m.MinimockGenerateDone() && + m.MinimockGetInfoDone() +} diff --git a/internal/mocks/request_repository_mock.go b/internal/mocks/request_repository_mock.go new file mode 100644 index 0000000..ad7a6a4 --- /dev/null +++ b/internal/mocks/request_repository_mock.go @@ -0,0 +1,2647 @@ +// Code generated by http://github.com/gojuno/minimock (v3.4.7). DO NOT EDIT. + +package mocks + +//go:generate minimock -i smart-search-back/internal/repository.RequestRepository -o request_repository_mock.go -n RequestRepositoryMock -p mocks + +import ( + "context" + "smart-search-back/internal/model" + "sync" + mm_atomic "sync/atomic" + mm_time "time" + + "github.com/gojuno/minimock/v3" + "github.com/google/uuid" +) + +// RequestRepositoryMock implements mm_repository.RequestRepository +type RequestRepositoryMock struct { + t minimock.Tester + finishOnce sync.Once + + funcCreate func(ctx context.Context, req *model.Request) (err error) + funcCreateOrigin string + inspectFuncCreate func(ctx context.Context, req *model.Request) + afterCreateCounter uint64 + beforeCreateCounter uint64 + CreateMock mRequestRepositoryMockCreate + + funcGetByID func(ctx context.Context, id uuid.UUID) (rp1 *model.Request, err error) + funcGetByIDOrigin string + inspectFuncGetByID func(ctx context.Context, id uuid.UUID) + afterGetByIDCounter uint64 + beforeGetByIDCounter uint64 + GetByIDMock mRequestRepositoryMockGetByID + + funcGetByUserID func(ctx context.Context, userID int) (rpa1 []*model.Request, err error) + funcGetByUserIDOrigin string + inspectFuncGetByUserID func(ctx context.Context, userID int) + afterGetByUserIDCounter uint64 + beforeGetByUserIDCounter uint64 + GetByUserIDMock mRequestRepositoryMockGetByUserID + + funcGetDetailByID func(ctx context.Context, id uuid.UUID) (rp1 *model.RequestDetail, err error) + funcGetDetailByIDOrigin string + inspectFuncGetDetailByID func(ctx context.Context, id uuid.UUID) + afterGetDetailByIDCounter uint64 + beforeGetDetailByIDCounter uint64 + GetDetailByIDMock mRequestRepositoryMockGetDetailByID + + funcGetUserStatistics func(ctx context.Context, userID int) (requestsCount int, suppliersCount int, createdTZ int, err error) + funcGetUserStatisticsOrigin string + inspectFuncGetUserStatistics func(ctx context.Context, userID int) + afterGetUserStatisticsCounter uint64 + beforeGetUserStatisticsCounter uint64 + GetUserStatisticsMock mRequestRepositoryMockGetUserStatistics + + funcUpdateFinalTZ func(ctx context.Context, id uuid.UUID, finalTZ string) (err error) + funcUpdateFinalTZOrigin string + inspectFuncUpdateFinalTZ func(ctx context.Context, id uuid.UUID, finalTZ string) + afterUpdateFinalTZCounter uint64 + beforeUpdateFinalTZCounter uint64 + UpdateFinalTZMock mRequestRepositoryMockUpdateFinalTZ + + funcUpdateWithTZ func(ctx context.Context, id uuid.UUID, tz string, generated bool) (err error) + funcUpdateWithTZOrigin string + inspectFuncUpdateWithTZ func(ctx context.Context, id uuid.UUID, tz string, generated bool) + afterUpdateWithTZCounter uint64 + beforeUpdateWithTZCounter uint64 + UpdateWithTZMock mRequestRepositoryMockUpdateWithTZ +} + +// NewRequestRepositoryMock returns a mock for mm_repository.RequestRepository +func NewRequestRepositoryMock(t minimock.Tester) *RequestRepositoryMock { + m := &RequestRepositoryMock{t: t} + + if controller, ok := t.(minimock.MockController); ok { + controller.RegisterMocker(m) + } + + m.CreateMock = mRequestRepositoryMockCreate{mock: m} + m.CreateMock.callArgs = []*RequestRepositoryMockCreateParams{} + + m.GetByIDMock = mRequestRepositoryMockGetByID{mock: m} + m.GetByIDMock.callArgs = []*RequestRepositoryMockGetByIDParams{} + + m.GetByUserIDMock = mRequestRepositoryMockGetByUserID{mock: m} + m.GetByUserIDMock.callArgs = []*RequestRepositoryMockGetByUserIDParams{} + + m.GetDetailByIDMock = mRequestRepositoryMockGetDetailByID{mock: m} + m.GetDetailByIDMock.callArgs = []*RequestRepositoryMockGetDetailByIDParams{} + + m.GetUserStatisticsMock = mRequestRepositoryMockGetUserStatistics{mock: m} + m.GetUserStatisticsMock.callArgs = []*RequestRepositoryMockGetUserStatisticsParams{} + + m.UpdateFinalTZMock = mRequestRepositoryMockUpdateFinalTZ{mock: m} + m.UpdateFinalTZMock.callArgs = []*RequestRepositoryMockUpdateFinalTZParams{} + + m.UpdateWithTZMock = mRequestRepositoryMockUpdateWithTZ{mock: m} + m.UpdateWithTZMock.callArgs = []*RequestRepositoryMockUpdateWithTZParams{} + + t.Cleanup(m.MinimockFinish) + + return m +} + +type mRequestRepositoryMockCreate struct { + optional bool + mock *RequestRepositoryMock + defaultExpectation *RequestRepositoryMockCreateExpectation + expectations []*RequestRepositoryMockCreateExpectation + + callArgs []*RequestRepositoryMockCreateParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// RequestRepositoryMockCreateExpectation specifies expectation struct of the RequestRepository.Create +type RequestRepositoryMockCreateExpectation struct { + mock *RequestRepositoryMock + params *RequestRepositoryMockCreateParams + paramPtrs *RequestRepositoryMockCreateParamPtrs + expectationOrigins RequestRepositoryMockCreateExpectationOrigins + results *RequestRepositoryMockCreateResults + returnOrigin string + Counter uint64 +} + +// RequestRepositoryMockCreateParams contains parameters of the RequestRepository.Create +type RequestRepositoryMockCreateParams struct { + ctx context.Context + req *model.Request +} + +// RequestRepositoryMockCreateParamPtrs contains pointers to parameters of the RequestRepository.Create +type RequestRepositoryMockCreateParamPtrs struct { + ctx *context.Context + req **model.Request +} + +// RequestRepositoryMockCreateResults contains results of the RequestRepository.Create +type RequestRepositoryMockCreateResults struct { + err error +} + +// RequestRepositoryMockCreateOrigins contains origins of expectations of the RequestRepository.Create +type RequestRepositoryMockCreateExpectationOrigins struct { + origin string + originCtx string + originReq string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmCreate *mRequestRepositoryMockCreate) Optional() *mRequestRepositoryMockCreate { + mmCreate.optional = true + return mmCreate +} + +// Expect sets up expected params for RequestRepository.Create +func (mmCreate *mRequestRepositoryMockCreate) Expect(ctx context.Context, req *model.Request) *mRequestRepositoryMockCreate { + if mmCreate.mock.funcCreate != nil { + mmCreate.mock.t.Fatalf("RequestRepositoryMock.Create mock is already set by Set") + } + + if mmCreate.defaultExpectation == nil { + mmCreate.defaultExpectation = &RequestRepositoryMockCreateExpectation{} + } + + if mmCreate.defaultExpectation.paramPtrs != nil { + mmCreate.mock.t.Fatalf("RequestRepositoryMock.Create mock is already set by ExpectParams functions") + } + + mmCreate.defaultExpectation.params = &RequestRepositoryMockCreateParams{ctx, req} + mmCreate.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmCreate.expectations { + if minimock.Equal(e.params, mmCreate.defaultExpectation.params) { + mmCreate.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmCreate.defaultExpectation.params) + } + } + + return mmCreate +} + +// ExpectCtxParam1 sets up expected param ctx for RequestRepository.Create +func (mmCreate *mRequestRepositoryMockCreate) ExpectCtxParam1(ctx context.Context) *mRequestRepositoryMockCreate { + if mmCreate.mock.funcCreate != nil { + mmCreate.mock.t.Fatalf("RequestRepositoryMock.Create mock is already set by Set") + } + + if mmCreate.defaultExpectation == nil { + mmCreate.defaultExpectation = &RequestRepositoryMockCreateExpectation{} + } + + if mmCreate.defaultExpectation.params != nil { + mmCreate.mock.t.Fatalf("RequestRepositoryMock.Create mock is already set by Expect") + } + + if mmCreate.defaultExpectation.paramPtrs == nil { + mmCreate.defaultExpectation.paramPtrs = &RequestRepositoryMockCreateParamPtrs{} + } + mmCreate.defaultExpectation.paramPtrs.ctx = &ctx + mmCreate.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmCreate +} + +// ExpectReqParam2 sets up expected param req for RequestRepository.Create +func (mmCreate *mRequestRepositoryMockCreate) ExpectReqParam2(req *model.Request) *mRequestRepositoryMockCreate { + if mmCreate.mock.funcCreate != nil { + mmCreate.mock.t.Fatalf("RequestRepositoryMock.Create mock is already set by Set") + } + + if mmCreate.defaultExpectation == nil { + mmCreate.defaultExpectation = &RequestRepositoryMockCreateExpectation{} + } + + if mmCreate.defaultExpectation.params != nil { + mmCreate.mock.t.Fatalf("RequestRepositoryMock.Create mock is already set by Expect") + } + + if mmCreate.defaultExpectation.paramPtrs == nil { + mmCreate.defaultExpectation.paramPtrs = &RequestRepositoryMockCreateParamPtrs{} + } + mmCreate.defaultExpectation.paramPtrs.req = &req + mmCreate.defaultExpectation.expectationOrigins.originReq = minimock.CallerInfo(1) + + return mmCreate +} + +// Inspect accepts an inspector function that has same arguments as the RequestRepository.Create +func (mmCreate *mRequestRepositoryMockCreate) Inspect(f func(ctx context.Context, req *model.Request)) *mRequestRepositoryMockCreate { + if mmCreate.mock.inspectFuncCreate != nil { + mmCreate.mock.t.Fatalf("Inspect function is already set for RequestRepositoryMock.Create") + } + + mmCreate.mock.inspectFuncCreate = f + + return mmCreate +} + +// Return sets up results that will be returned by RequestRepository.Create +func (mmCreate *mRequestRepositoryMockCreate) Return(err error) *RequestRepositoryMock { + if mmCreate.mock.funcCreate != nil { + mmCreate.mock.t.Fatalf("RequestRepositoryMock.Create mock is already set by Set") + } + + if mmCreate.defaultExpectation == nil { + mmCreate.defaultExpectation = &RequestRepositoryMockCreateExpectation{mock: mmCreate.mock} + } + mmCreate.defaultExpectation.results = &RequestRepositoryMockCreateResults{err} + mmCreate.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmCreate.mock +} + +// Set uses given function f to mock the RequestRepository.Create method +func (mmCreate *mRequestRepositoryMockCreate) Set(f func(ctx context.Context, req *model.Request) (err error)) *RequestRepositoryMock { + if mmCreate.defaultExpectation != nil { + mmCreate.mock.t.Fatalf("Default expectation is already set for the RequestRepository.Create method") + } + + if len(mmCreate.expectations) > 0 { + mmCreate.mock.t.Fatalf("Some expectations are already set for the RequestRepository.Create method") + } + + mmCreate.mock.funcCreate = f + mmCreate.mock.funcCreateOrigin = minimock.CallerInfo(1) + return mmCreate.mock +} + +// When sets expectation for the RequestRepository.Create which will trigger the result defined by the following +// Then helper +func (mmCreate *mRequestRepositoryMockCreate) When(ctx context.Context, req *model.Request) *RequestRepositoryMockCreateExpectation { + if mmCreate.mock.funcCreate != nil { + mmCreate.mock.t.Fatalf("RequestRepositoryMock.Create mock is already set by Set") + } + + expectation := &RequestRepositoryMockCreateExpectation{ + mock: mmCreate.mock, + params: &RequestRepositoryMockCreateParams{ctx, req}, + expectationOrigins: RequestRepositoryMockCreateExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmCreate.expectations = append(mmCreate.expectations, expectation) + return expectation +} + +// Then sets up RequestRepository.Create return parameters for the expectation previously defined by the When method +func (e *RequestRepositoryMockCreateExpectation) Then(err error) *RequestRepositoryMock { + e.results = &RequestRepositoryMockCreateResults{err} + return e.mock +} + +// Times sets number of times RequestRepository.Create should be invoked +func (mmCreate *mRequestRepositoryMockCreate) Times(n uint64) *mRequestRepositoryMockCreate { + if n == 0 { + mmCreate.mock.t.Fatalf("Times of RequestRepositoryMock.Create mock can not be zero") + } + mm_atomic.StoreUint64(&mmCreate.expectedInvocations, n) + mmCreate.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmCreate +} + +func (mmCreate *mRequestRepositoryMockCreate) invocationsDone() bool { + if len(mmCreate.expectations) == 0 && mmCreate.defaultExpectation == nil && mmCreate.mock.funcCreate == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmCreate.mock.afterCreateCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmCreate.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// Create implements mm_repository.RequestRepository +func (mmCreate *RequestRepositoryMock) Create(ctx context.Context, req *model.Request) (err error) { + mm_atomic.AddUint64(&mmCreate.beforeCreateCounter, 1) + defer mm_atomic.AddUint64(&mmCreate.afterCreateCounter, 1) + + mmCreate.t.Helper() + + if mmCreate.inspectFuncCreate != nil { + mmCreate.inspectFuncCreate(ctx, req) + } + + mm_params := RequestRepositoryMockCreateParams{ctx, req} + + // Record call args + mmCreate.CreateMock.mutex.Lock() + mmCreate.CreateMock.callArgs = append(mmCreate.CreateMock.callArgs, &mm_params) + mmCreate.CreateMock.mutex.Unlock() + + for _, e := range mmCreate.CreateMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.err + } + } + + if mmCreate.CreateMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmCreate.CreateMock.defaultExpectation.Counter, 1) + mm_want := mmCreate.CreateMock.defaultExpectation.params + mm_want_ptrs := mmCreate.CreateMock.defaultExpectation.paramPtrs + + mm_got := RequestRepositoryMockCreateParams{ctx, req} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmCreate.t.Errorf("RequestRepositoryMock.Create got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmCreate.CreateMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.req != nil && !minimock.Equal(*mm_want_ptrs.req, mm_got.req) { + mmCreate.t.Errorf("RequestRepositoryMock.Create got unexpected parameter req, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmCreate.CreateMock.defaultExpectation.expectationOrigins.originReq, *mm_want_ptrs.req, mm_got.req, minimock.Diff(*mm_want_ptrs.req, mm_got.req)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmCreate.t.Errorf("RequestRepositoryMock.Create got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmCreate.CreateMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmCreate.CreateMock.defaultExpectation.results + if mm_results == nil { + mmCreate.t.Fatal("No results are set for the RequestRepositoryMock.Create") + } + return (*mm_results).err + } + if mmCreate.funcCreate != nil { + return mmCreate.funcCreate(ctx, req) + } + mmCreate.t.Fatalf("Unexpected call to RequestRepositoryMock.Create. %v %v", ctx, req) + return +} + +// CreateAfterCounter returns a count of finished RequestRepositoryMock.Create invocations +func (mmCreate *RequestRepositoryMock) CreateAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmCreate.afterCreateCounter) +} + +// CreateBeforeCounter returns a count of RequestRepositoryMock.Create invocations +func (mmCreate *RequestRepositoryMock) CreateBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmCreate.beforeCreateCounter) +} + +// Calls returns a list of arguments used in each call to RequestRepositoryMock.Create. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmCreate *mRequestRepositoryMockCreate) Calls() []*RequestRepositoryMockCreateParams { + mmCreate.mutex.RLock() + + argCopy := make([]*RequestRepositoryMockCreateParams, len(mmCreate.callArgs)) + copy(argCopy, mmCreate.callArgs) + + mmCreate.mutex.RUnlock() + + return argCopy +} + +// MinimockCreateDone returns true if the count of the Create invocations corresponds +// the number of defined expectations +func (m *RequestRepositoryMock) MinimockCreateDone() bool { + if m.CreateMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.CreateMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.CreateMock.invocationsDone() +} + +// MinimockCreateInspect logs each unmet expectation +func (m *RequestRepositoryMock) MinimockCreateInspect() { + for _, e := range m.CreateMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to RequestRepositoryMock.Create at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterCreateCounter := mm_atomic.LoadUint64(&m.afterCreateCounter) + // if default expectation was set then invocations count should be greater than zero + if m.CreateMock.defaultExpectation != nil && afterCreateCounter < 1 { + if m.CreateMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to RequestRepositoryMock.Create at\n%s", m.CreateMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to RequestRepositoryMock.Create at\n%s with params: %#v", m.CreateMock.defaultExpectation.expectationOrigins.origin, *m.CreateMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcCreate != nil && afterCreateCounter < 1 { + m.t.Errorf("Expected call to RequestRepositoryMock.Create at\n%s", m.funcCreateOrigin) + } + + if !m.CreateMock.invocationsDone() && afterCreateCounter > 0 { + m.t.Errorf("Expected %d calls to RequestRepositoryMock.Create at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.CreateMock.expectedInvocations), m.CreateMock.expectedInvocationsOrigin, afterCreateCounter) + } +} + +type mRequestRepositoryMockGetByID struct { + optional bool + mock *RequestRepositoryMock + defaultExpectation *RequestRepositoryMockGetByIDExpectation + expectations []*RequestRepositoryMockGetByIDExpectation + + callArgs []*RequestRepositoryMockGetByIDParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// RequestRepositoryMockGetByIDExpectation specifies expectation struct of the RequestRepository.GetByID +type RequestRepositoryMockGetByIDExpectation struct { + mock *RequestRepositoryMock + params *RequestRepositoryMockGetByIDParams + paramPtrs *RequestRepositoryMockGetByIDParamPtrs + expectationOrigins RequestRepositoryMockGetByIDExpectationOrigins + results *RequestRepositoryMockGetByIDResults + returnOrigin string + Counter uint64 +} + +// RequestRepositoryMockGetByIDParams contains parameters of the RequestRepository.GetByID +type RequestRepositoryMockGetByIDParams struct { + ctx context.Context + id uuid.UUID +} + +// RequestRepositoryMockGetByIDParamPtrs contains pointers to parameters of the RequestRepository.GetByID +type RequestRepositoryMockGetByIDParamPtrs struct { + ctx *context.Context + id *uuid.UUID +} + +// RequestRepositoryMockGetByIDResults contains results of the RequestRepository.GetByID +type RequestRepositoryMockGetByIDResults struct { + rp1 *model.Request + err error +} + +// RequestRepositoryMockGetByIDOrigins contains origins of expectations of the RequestRepository.GetByID +type RequestRepositoryMockGetByIDExpectationOrigins struct { + origin string + originCtx string + originId string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmGetByID *mRequestRepositoryMockGetByID) Optional() *mRequestRepositoryMockGetByID { + mmGetByID.optional = true + return mmGetByID +} + +// Expect sets up expected params for RequestRepository.GetByID +func (mmGetByID *mRequestRepositoryMockGetByID) Expect(ctx context.Context, id uuid.UUID) *mRequestRepositoryMockGetByID { + if mmGetByID.mock.funcGetByID != nil { + mmGetByID.mock.t.Fatalf("RequestRepositoryMock.GetByID mock is already set by Set") + } + + if mmGetByID.defaultExpectation == nil { + mmGetByID.defaultExpectation = &RequestRepositoryMockGetByIDExpectation{} + } + + if mmGetByID.defaultExpectation.paramPtrs != nil { + mmGetByID.mock.t.Fatalf("RequestRepositoryMock.GetByID mock is already set by ExpectParams functions") + } + + mmGetByID.defaultExpectation.params = &RequestRepositoryMockGetByIDParams{ctx, id} + mmGetByID.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmGetByID.expectations { + if minimock.Equal(e.params, mmGetByID.defaultExpectation.params) { + mmGetByID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByID.defaultExpectation.params) + } + } + + return mmGetByID +} + +// ExpectCtxParam1 sets up expected param ctx for RequestRepository.GetByID +func (mmGetByID *mRequestRepositoryMockGetByID) ExpectCtxParam1(ctx context.Context) *mRequestRepositoryMockGetByID { + if mmGetByID.mock.funcGetByID != nil { + mmGetByID.mock.t.Fatalf("RequestRepositoryMock.GetByID mock is already set by Set") + } + + if mmGetByID.defaultExpectation == nil { + mmGetByID.defaultExpectation = &RequestRepositoryMockGetByIDExpectation{} + } + + if mmGetByID.defaultExpectation.params != nil { + mmGetByID.mock.t.Fatalf("RequestRepositoryMock.GetByID mock is already set by Expect") + } + + if mmGetByID.defaultExpectation.paramPtrs == nil { + mmGetByID.defaultExpectation.paramPtrs = &RequestRepositoryMockGetByIDParamPtrs{} + } + mmGetByID.defaultExpectation.paramPtrs.ctx = &ctx + mmGetByID.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmGetByID +} + +// ExpectIdParam2 sets up expected param id for RequestRepository.GetByID +func (mmGetByID *mRequestRepositoryMockGetByID) ExpectIdParam2(id uuid.UUID) *mRequestRepositoryMockGetByID { + if mmGetByID.mock.funcGetByID != nil { + mmGetByID.mock.t.Fatalf("RequestRepositoryMock.GetByID mock is already set by Set") + } + + if mmGetByID.defaultExpectation == nil { + mmGetByID.defaultExpectation = &RequestRepositoryMockGetByIDExpectation{} + } + + if mmGetByID.defaultExpectation.params != nil { + mmGetByID.mock.t.Fatalf("RequestRepositoryMock.GetByID mock is already set by Expect") + } + + if mmGetByID.defaultExpectation.paramPtrs == nil { + mmGetByID.defaultExpectation.paramPtrs = &RequestRepositoryMockGetByIDParamPtrs{} + } + mmGetByID.defaultExpectation.paramPtrs.id = &id + mmGetByID.defaultExpectation.expectationOrigins.originId = minimock.CallerInfo(1) + + return mmGetByID +} + +// Inspect accepts an inspector function that has same arguments as the RequestRepository.GetByID +func (mmGetByID *mRequestRepositoryMockGetByID) Inspect(f func(ctx context.Context, id uuid.UUID)) *mRequestRepositoryMockGetByID { + if mmGetByID.mock.inspectFuncGetByID != nil { + mmGetByID.mock.t.Fatalf("Inspect function is already set for RequestRepositoryMock.GetByID") + } + + mmGetByID.mock.inspectFuncGetByID = f + + return mmGetByID +} + +// Return sets up results that will be returned by RequestRepository.GetByID +func (mmGetByID *mRequestRepositoryMockGetByID) Return(rp1 *model.Request, err error) *RequestRepositoryMock { + if mmGetByID.mock.funcGetByID != nil { + mmGetByID.mock.t.Fatalf("RequestRepositoryMock.GetByID mock is already set by Set") + } + + if mmGetByID.defaultExpectation == nil { + mmGetByID.defaultExpectation = &RequestRepositoryMockGetByIDExpectation{mock: mmGetByID.mock} + } + mmGetByID.defaultExpectation.results = &RequestRepositoryMockGetByIDResults{rp1, err} + mmGetByID.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmGetByID.mock +} + +// Set uses given function f to mock the RequestRepository.GetByID method +func (mmGetByID *mRequestRepositoryMockGetByID) Set(f func(ctx context.Context, id uuid.UUID) (rp1 *model.Request, err error)) *RequestRepositoryMock { + if mmGetByID.defaultExpectation != nil { + mmGetByID.mock.t.Fatalf("Default expectation is already set for the RequestRepository.GetByID method") + } + + if len(mmGetByID.expectations) > 0 { + mmGetByID.mock.t.Fatalf("Some expectations are already set for the RequestRepository.GetByID method") + } + + mmGetByID.mock.funcGetByID = f + mmGetByID.mock.funcGetByIDOrigin = minimock.CallerInfo(1) + return mmGetByID.mock +} + +// When sets expectation for the RequestRepository.GetByID which will trigger the result defined by the following +// Then helper +func (mmGetByID *mRequestRepositoryMockGetByID) When(ctx context.Context, id uuid.UUID) *RequestRepositoryMockGetByIDExpectation { + if mmGetByID.mock.funcGetByID != nil { + mmGetByID.mock.t.Fatalf("RequestRepositoryMock.GetByID mock is already set by Set") + } + + expectation := &RequestRepositoryMockGetByIDExpectation{ + mock: mmGetByID.mock, + params: &RequestRepositoryMockGetByIDParams{ctx, id}, + expectationOrigins: RequestRepositoryMockGetByIDExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmGetByID.expectations = append(mmGetByID.expectations, expectation) + return expectation +} + +// Then sets up RequestRepository.GetByID return parameters for the expectation previously defined by the When method +func (e *RequestRepositoryMockGetByIDExpectation) Then(rp1 *model.Request, err error) *RequestRepositoryMock { + e.results = &RequestRepositoryMockGetByIDResults{rp1, err} + return e.mock +} + +// Times sets number of times RequestRepository.GetByID should be invoked +func (mmGetByID *mRequestRepositoryMockGetByID) Times(n uint64) *mRequestRepositoryMockGetByID { + if n == 0 { + mmGetByID.mock.t.Fatalf("Times of RequestRepositoryMock.GetByID mock can not be zero") + } + mm_atomic.StoreUint64(&mmGetByID.expectedInvocations, n) + mmGetByID.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmGetByID +} + +func (mmGetByID *mRequestRepositoryMockGetByID) invocationsDone() bool { + if len(mmGetByID.expectations) == 0 && mmGetByID.defaultExpectation == nil && mmGetByID.mock.funcGetByID == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmGetByID.mock.afterGetByIDCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmGetByID.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// GetByID implements mm_repository.RequestRepository +func (mmGetByID *RequestRepositoryMock) GetByID(ctx context.Context, id uuid.UUID) (rp1 *model.Request, err error) { + mm_atomic.AddUint64(&mmGetByID.beforeGetByIDCounter, 1) + defer mm_atomic.AddUint64(&mmGetByID.afterGetByIDCounter, 1) + + mmGetByID.t.Helper() + + if mmGetByID.inspectFuncGetByID != nil { + mmGetByID.inspectFuncGetByID(ctx, id) + } + + mm_params := RequestRepositoryMockGetByIDParams{ctx, id} + + // Record call args + mmGetByID.GetByIDMock.mutex.Lock() + mmGetByID.GetByIDMock.callArgs = append(mmGetByID.GetByIDMock.callArgs, &mm_params) + mmGetByID.GetByIDMock.mutex.Unlock() + + for _, e := range mmGetByID.GetByIDMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.rp1, e.results.err + } + } + + if mmGetByID.GetByIDMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmGetByID.GetByIDMock.defaultExpectation.Counter, 1) + mm_want := mmGetByID.GetByIDMock.defaultExpectation.params + mm_want_ptrs := mmGetByID.GetByIDMock.defaultExpectation.paramPtrs + + mm_got := RequestRepositoryMockGetByIDParams{ctx, id} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmGetByID.t.Errorf("RequestRepositoryMock.GetByID got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetByID.GetByIDMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) { + mmGetByID.t.Errorf("RequestRepositoryMock.GetByID got unexpected parameter id, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetByID.GetByIDMock.defaultExpectation.expectationOrigins.originId, *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmGetByID.t.Errorf("RequestRepositoryMock.GetByID got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetByID.GetByIDMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmGetByID.GetByIDMock.defaultExpectation.results + if mm_results == nil { + mmGetByID.t.Fatal("No results are set for the RequestRepositoryMock.GetByID") + } + return (*mm_results).rp1, (*mm_results).err + } + if mmGetByID.funcGetByID != nil { + return mmGetByID.funcGetByID(ctx, id) + } + mmGetByID.t.Fatalf("Unexpected call to RequestRepositoryMock.GetByID. %v %v", ctx, id) + return +} + +// GetByIDAfterCounter returns a count of finished RequestRepositoryMock.GetByID invocations +func (mmGetByID *RequestRepositoryMock) GetByIDAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetByID.afterGetByIDCounter) +} + +// GetByIDBeforeCounter returns a count of RequestRepositoryMock.GetByID invocations +func (mmGetByID *RequestRepositoryMock) GetByIDBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetByID.beforeGetByIDCounter) +} + +// Calls returns a list of arguments used in each call to RequestRepositoryMock.GetByID. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmGetByID *mRequestRepositoryMockGetByID) Calls() []*RequestRepositoryMockGetByIDParams { + mmGetByID.mutex.RLock() + + argCopy := make([]*RequestRepositoryMockGetByIDParams, len(mmGetByID.callArgs)) + copy(argCopy, mmGetByID.callArgs) + + mmGetByID.mutex.RUnlock() + + return argCopy +} + +// MinimockGetByIDDone returns true if the count of the GetByID invocations corresponds +// the number of defined expectations +func (m *RequestRepositoryMock) MinimockGetByIDDone() bool { + if m.GetByIDMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.GetByIDMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.GetByIDMock.invocationsDone() +} + +// MinimockGetByIDInspect logs each unmet expectation +func (m *RequestRepositoryMock) MinimockGetByIDInspect() { + for _, e := range m.GetByIDMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to RequestRepositoryMock.GetByID at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterGetByIDCounter := mm_atomic.LoadUint64(&m.afterGetByIDCounter) + // if default expectation was set then invocations count should be greater than zero + if m.GetByIDMock.defaultExpectation != nil && afterGetByIDCounter < 1 { + if m.GetByIDMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to RequestRepositoryMock.GetByID at\n%s", m.GetByIDMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to RequestRepositoryMock.GetByID at\n%s with params: %#v", m.GetByIDMock.defaultExpectation.expectationOrigins.origin, *m.GetByIDMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcGetByID != nil && afterGetByIDCounter < 1 { + m.t.Errorf("Expected call to RequestRepositoryMock.GetByID at\n%s", m.funcGetByIDOrigin) + } + + if !m.GetByIDMock.invocationsDone() && afterGetByIDCounter > 0 { + m.t.Errorf("Expected %d calls to RequestRepositoryMock.GetByID at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.GetByIDMock.expectedInvocations), m.GetByIDMock.expectedInvocationsOrigin, afterGetByIDCounter) + } +} + +type mRequestRepositoryMockGetByUserID struct { + optional bool + mock *RequestRepositoryMock + defaultExpectation *RequestRepositoryMockGetByUserIDExpectation + expectations []*RequestRepositoryMockGetByUserIDExpectation + + callArgs []*RequestRepositoryMockGetByUserIDParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// RequestRepositoryMockGetByUserIDExpectation specifies expectation struct of the RequestRepository.GetByUserID +type RequestRepositoryMockGetByUserIDExpectation struct { + mock *RequestRepositoryMock + params *RequestRepositoryMockGetByUserIDParams + paramPtrs *RequestRepositoryMockGetByUserIDParamPtrs + expectationOrigins RequestRepositoryMockGetByUserIDExpectationOrigins + results *RequestRepositoryMockGetByUserIDResults + returnOrigin string + Counter uint64 +} + +// RequestRepositoryMockGetByUserIDParams contains parameters of the RequestRepository.GetByUserID +type RequestRepositoryMockGetByUserIDParams struct { + ctx context.Context + userID int +} + +// RequestRepositoryMockGetByUserIDParamPtrs contains pointers to parameters of the RequestRepository.GetByUserID +type RequestRepositoryMockGetByUserIDParamPtrs struct { + ctx *context.Context + userID *int +} + +// RequestRepositoryMockGetByUserIDResults contains results of the RequestRepository.GetByUserID +type RequestRepositoryMockGetByUserIDResults struct { + rpa1 []*model.Request + err error +} + +// RequestRepositoryMockGetByUserIDOrigins contains origins of expectations of the RequestRepository.GetByUserID +type RequestRepositoryMockGetByUserIDExpectationOrigins struct { + origin string + originCtx string + originUserID string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmGetByUserID *mRequestRepositoryMockGetByUserID) Optional() *mRequestRepositoryMockGetByUserID { + mmGetByUserID.optional = true + return mmGetByUserID +} + +// Expect sets up expected params for RequestRepository.GetByUserID +func (mmGetByUserID *mRequestRepositoryMockGetByUserID) Expect(ctx context.Context, userID int) *mRequestRepositoryMockGetByUserID { + if mmGetByUserID.mock.funcGetByUserID != nil { + mmGetByUserID.mock.t.Fatalf("RequestRepositoryMock.GetByUserID mock is already set by Set") + } + + if mmGetByUserID.defaultExpectation == nil { + mmGetByUserID.defaultExpectation = &RequestRepositoryMockGetByUserIDExpectation{} + } + + if mmGetByUserID.defaultExpectation.paramPtrs != nil { + mmGetByUserID.mock.t.Fatalf("RequestRepositoryMock.GetByUserID mock is already set by ExpectParams functions") + } + + mmGetByUserID.defaultExpectation.params = &RequestRepositoryMockGetByUserIDParams{ctx, userID} + mmGetByUserID.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmGetByUserID.expectations { + if minimock.Equal(e.params, mmGetByUserID.defaultExpectation.params) { + mmGetByUserID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByUserID.defaultExpectation.params) + } + } + + return mmGetByUserID +} + +// ExpectCtxParam1 sets up expected param ctx for RequestRepository.GetByUserID +func (mmGetByUserID *mRequestRepositoryMockGetByUserID) ExpectCtxParam1(ctx context.Context) *mRequestRepositoryMockGetByUserID { + if mmGetByUserID.mock.funcGetByUserID != nil { + mmGetByUserID.mock.t.Fatalf("RequestRepositoryMock.GetByUserID mock is already set by Set") + } + + if mmGetByUserID.defaultExpectation == nil { + mmGetByUserID.defaultExpectation = &RequestRepositoryMockGetByUserIDExpectation{} + } + + if mmGetByUserID.defaultExpectation.params != nil { + mmGetByUserID.mock.t.Fatalf("RequestRepositoryMock.GetByUserID mock is already set by Expect") + } + + if mmGetByUserID.defaultExpectation.paramPtrs == nil { + mmGetByUserID.defaultExpectation.paramPtrs = &RequestRepositoryMockGetByUserIDParamPtrs{} + } + mmGetByUserID.defaultExpectation.paramPtrs.ctx = &ctx + mmGetByUserID.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmGetByUserID +} + +// ExpectUserIDParam2 sets up expected param userID for RequestRepository.GetByUserID +func (mmGetByUserID *mRequestRepositoryMockGetByUserID) ExpectUserIDParam2(userID int) *mRequestRepositoryMockGetByUserID { + if mmGetByUserID.mock.funcGetByUserID != nil { + mmGetByUserID.mock.t.Fatalf("RequestRepositoryMock.GetByUserID mock is already set by Set") + } + + if mmGetByUserID.defaultExpectation == nil { + mmGetByUserID.defaultExpectation = &RequestRepositoryMockGetByUserIDExpectation{} + } + + if mmGetByUserID.defaultExpectation.params != nil { + mmGetByUserID.mock.t.Fatalf("RequestRepositoryMock.GetByUserID mock is already set by Expect") + } + + if mmGetByUserID.defaultExpectation.paramPtrs == nil { + mmGetByUserID.defaultExpectation.paramPtrs = &RequestRepositoryMockGetByUserIDParamPtrs{} + } + mmGetByUserID.defaultExpectation.paramPtrs.userID = &userID + mmGetByUserID.defaultExpectation.expectationOrigins.originUserID = minimock.CallerInfo(1) + + return mmGetByUserID +} + +// Inspect accepts an inspector function that has same arguments as the RequestRepository.GetByUserID +func (mmGetByUserID *mRequestRepositoryMockGetByUserID) Inspect(f func(ctx context.Context, userID int)) *mRequestRepositoryMockGetByUserID { + if mmGetByUserID.mock.inspectFuncGetByUserID != nil { + mmGetByUserID.mock.t.Fatalf("Inspect function is already set for RequestRepositoryMock.GetByUserID") + } + + mmGetByUserID.mock.inspectFuncGetByUserID = f + + return mmGetByUserID +} + +// Return sets up results that will be returned by RequestRepository.GetByUserID +func (mmGetByUserID *mRequestRepositoryMockGetByUserID) Return(rpa1 []*model.Request, err error) *RequestRepositoryMock { + if mmGetByUserID.mock.funcGetByUserID != nil { + mmGetByUserID.mock.t.Fatalf("RequestRepositoryMock.GetByUserID mock is already set by Set") + } + + if mmGetByUserID.defaultExpectation == nil { + mmGetByUserID.defaultExpectation = &RequestRepositoryMockGetByUserIDExpectation{mock: mmGetByUserID.mock} + } + mmGetByUserID.defaultExpectation.results = &RequestRepositoryMockGetByUserIDResults{rpa1, err} + mmGetByUserID.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmGetByUserID.mock +} + +// Set uses given function f to mock the RequestRepository.GetByUserID method +func (mmGetByUserID *mRequestRepositoryMockGetByUserID) Set(f func(ctx context.Context, userID int) (rpa1 []*model.Request, err error)) *RequestRepositoryMock { + if mmGetByUserID.defaultExpectation != nil { + mmGetByUserID.mock.t.Fatalf("Default expectation is already set for the RequestRepository.GetByUserID method") + } + + if len(mmGetByUserID.expectations) > 0 { + mmGetByUserID.mock.t.Fatalf("Some expectations are already set for the RequestRepository.GetByUserID method") + } + + mmGetByUserID.mock.funcGetByUserID = f + mmGetByUserID.mock.funcGetByUserIDOrigin = minimock.CallerInfo(1) + return mmGetByUserID.mock +} + +// When sets expectation for the RequestRepository.GetByUserID which will trigger the result defined by the following +// Then helper +func (mmGetByUserID *mRequestRepositoryMockGetByUserID) When(ctx context.Context, userID int) *RequestRepositoryMockGetByUserIDExpectation { + if mmGetByUserID.mock.funcGetByUserID != nil { + mmGetByUserID.mock.t.Fatalf("RequestRepositoryMock.GetByUserID mock is already set by Set") + } + + expectation := &RequestRepositoryMockGetByUserIDExpectation{ + mock: mmGetByUserID.mock, + params: &RequestRepositoryMockGetByUserIDParams{ctx, userID}, + expectationOrigins: RequestRepositoryMockGetByUserIDExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmGetByUserID.expectations = append(mmGetByUserID.expectations, expectation) + return expectation +} + +// Then sets up RequestRepository.GetByUserID return parameters for the expectation previously defined by the When method +func (e *RequestRepositoryMockGetByUserIDExpectation) Then(rpa1 []*model.Request, err error) *RequestRepositoryMock { + e.results = &RequestRepositoryMockGetByUserIDResults{rpa1, err} + return e.mock +} + +// Times sets number of times RequestRepository.GetByUserID should be invoked +func (mmGetByUserID *mRequestRepositoryMockGetByUserID) Times(n uint64) *mRequestRepositoryMockGetByUserID { + if n == 0 { + mmGetByUserID.mock.t.Fatalf("Times of RequestRepositoryMock.GetByUserID mock can not be zero") + } + mm_atomic.StoreUint64(&mmGetByUserID.expectedInvocations, n) + mmGetByUserID.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmGetByUserID +} + +func (mmGetByUserID *mRequestRepositoryMockGetByUserID) invocationsDone() bool { + if len(mmGetByUserID.expectations) == 0 && mmGetByUserID.defaultExpectation == nil && mmGetByUserID.mock.funcGetByUserID == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmGetByUserID.mock.afterGetByUserIDCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmGetByUserID.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// GetByUserID implements mm_repository.RequestRepository +func (mmGetByUserID *RequestRepositoryMock) GetByUserID(ctx context.Context, userID int) (rpa1 []*model.Request, err error) { + mm_atomic.AddUint64(&mmGetByUserID.beforeGetByUserIDCounter, 1) + defer mm_atomic.AddUint64(&mmGetByUserID.afterGetByUserIDCounter, 1) + + mmGetByUserID.t.Helper() + + if mmGetByUserID.inspectFuncGetByUserID != nil { + mmGetByUserID.inspectFuncGetByUserID(ctx, userID) + } + + mm_params := RequestRepositoryMockGetByUserIDParams{ctx, userID} + + // Record call args + mmGetByUserID.GetByUserIDMock.mutex.Lock() + mmGetByUserID.GetByUserIDMock.callArgs = append(mmGetByUserID.GetByUserIDMock.callArgs, &mm_params) + mmGetByUserID.GetByUserIDMock.mutex.Unlock() + + for _, e := range mmGetByUserID.GetByUserIDMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.rpa1, e.results.err + } + } + + if mmGetByUserID.GetByUserIDMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmGetByUserID.GetByUserIDMock.defaultExpectation.Counter, 1) + mm_want := mmGetByUserID.GetByUserIDMock.defaultExpectation.params + mm_want_ptrs := mmGetByUserID.GetByUserIDMock.defaultExpectation.paramPtrs + + mm_got := RequestRepositoryMockGetByUserIDParams{ctx, userID} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmGetByUserID.t.Errorf("RequestRepositoryMock.GetByUserID got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetByUserID.GetByUserIDMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.userID != nil && !minimock.Equal(*mm_want_ptrs.userID, mm_got.userID) { + mmGetByUserID.t.Errorf("RequestRepositoryMock.GetByUserID got unexpected parameter userID, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetByUserID.GetByUserIDMock.defaultExpectation.expectationOrigins.originUserID, *mm_want_ptrs.userID, mm_got.userID, minimock.Diff(*mm_want_ptrs.userID, mm_got.userID)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmGetByUserID.t.Errorf("RequestRepositoryMock.GetByUserID got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetByUserID.GetByUserIDMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmGetByUserID.GetByUserIDMock.defaultExpectation.results + if mm_results == nil { + mmGetByUserID.t.Fatal("No results are set for the RequestRepositoryMock.GetByUserID") + } + return (*mm_results).rpa1, (*mm_results).err + } + if mmGetByUserID.funcGetByUserID != nil { + return mmGetByUserID.funcGetByUserID(ctx, userID) + } + mmGetByUserID.t.Fatalf("Unexpected call to RequestRepositoryMock.GetByUserID. %v %v", ctx, userID) + return +} + +// GetByUserIDAfterCounter returns a count of finished RequestRepositoryMock.GetByUserID invocations +func (mmGetByUserID *RequestRepositoryMock) GetByUserIDAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetByUserID.afterGetByUserIDCounter) +} + +// GetByUserIDBeforeCounter returns a count of RequestRepositoryMock.GetByUserID invocations +func (mmGetByUserID *RequestRepositoryMock) GetByUserIDBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetByUserID.beforeGetByUserIDCounter) +} + +// Calls returns a list of arguments used in each call to RequestRepositoryMock.GetByUserID. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmGetByUserID *mRequestRepositoryMockGetByUserID) Calls() []*RequestRepositoryMockGetByUserIDParams { + mmGetByUserID.mutex.RLock() + + argCopy := make([]*RequestRepositoryMockGetByUserIDParams, len(mmGetByUserID.callArgs)) + copy(argCopy, mmGetByUserID.callArgs) + + mmGetByUserID.mutex.RUnlock() + + return argCopy +} + +// MinimockGetByUserIDDone returns true if the count of the GetByUserID invocations corresponds +// the number of defined expectations +func (m *RequestRepositoryMock) MinimockGetByUserIDDone() bool { + if m.GetByUserIDMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.GetByUserIDMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.GetByUserIDMock.invocationsDone() +} + +// MinimockGetByUserIDInspect logs each unmet expectation +func (m *RequestRepositoryMock) MinimockGetByUserIDInspect() { + for _, e := range m.GetByUserIDMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to RequestRepositoryMock.GetByUserID at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterGetByUserIDCounter := mm_atomic.LoadUint64(&m.afterGetByUserIDCounter) + // if default expectation was set then invocations count should be greater than zero + if m.GetByUserIDMock.defaultExpectation != nil && afterGetByUserIDCounter < 1 { + if m.GetByUserIDMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to RequestRepositoryMock.GetByUserID at\n%s", m.GetByUserIDMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to RequestRepositoryMock.GetByUserID at\n%s with params: %#v", m.GetByUserIDMock.defaultExpectation.expectationOrigins.origin, *m.GetByUserIDMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcGetByUserID != nil && afterGetByUserIDCounter < 1 { + m.t.Errorf("Expected call to RequestRepositoryMock.GetByUserID at\n%s", m.funcGetByUserIDOrigin) + } + + if !m.GetByUserIDMock.invocationsDone() && afterGetByUserIDCounter > 0 { + m.t.Errorf("Expected %d calls to RequestRepositoryMock.GetByUserID at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.GetByUserIDMock.expectedInvocations), m.GetByUserIDMock.expectedInvocationsOrigin, afterGetByUserIDCounter) + } +} + +type mRequestRepositoryMockGetDetailByID struct { + optional bool + mock *RequestRepositoryMock + defaultExpectation *RequestRepositoryMockGetDetailByIDExpectation + expectations []*RequestRepositoryMockGetDetailByIDExpectation + + callArgs []*RequestRepositoryMockGetDetailByIDParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// RequestRepositoryMockGetDetailByIDExpectation specifies expectation struct of the RequestRepository.GetDetailByID +type RequestRepositoryMockGetDetailByIDExpectation struct { + mock *RequestRepositoryMock + params *RequestRepositoryMockGetDetailByIDParams + paramPtrs *RequestRepositoryMockGetDetailByIDParamPtrs + expectationOrigins RequestRepositoryMockGetDetailByIDExpectationOrigins + results *RequestRepositoryMockGetDetailByIDResults + returnOrigin string + Counter uint64 +} + +// RequestRepositoryMockGetDetailByIDParams contains parameters of the RequestRepository.GetDetailByID +type RequestRepositoryMockGetDetailByIDParams struct { + ctx context.Context + id uuid.UUID +} + +// RequestRepositoryMockGetDetailByIDParamPtrs contains pointers to parameters of the RequestRepository.GetDetailByID +type RequestRepositoryMockGetDetailByIDParamPtrs struct { + ctx *context.Context + id *uuid.UUID +} + +// RequestRepositoryMockGetDetailByIDResults contains results of the RequestRepository.GetDetailByID +type RequestRepositoryMockGetDetailByIDResults struct { + rp1 *model.RequestDetail + err error +} + +// RequestRepositoryMockGetDetailByIDOrigins contains origins of expectations of the RequestRepository.GetDetailByID +type RequestRepositoryMockGetDetailByIDExpectationOrigins struct { + origin string + originCtx string + originId string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmGetDetailByID *mRequestRepositoryMockGetDetailByID) Optional() *mRequestRepositoryMockGetDetailByID { + mmGetDetailByID.optional = true + return mmGetDetailByID +} + +// Expect sets up expected params for RequestRepository.GetDetailByID +func (mmGetDetailByID *mRequestRepositoryMockGetDetailByID) Expect(ctx context.Context, id uuid.UUID) *mRequestRepositoryMockGetDetailByID { + if mmGetDetailByID.mock.funcGetDetailByID != nil { + mmGetDetailByID.mock.t.Fatalf("RequestRepositoryMock.GetDetailByID mock is already set by Set") + } + + if mmGetDetailByID.defaultExpectation == nil { + mmGetDetailByID.defaultExpectation = &RequestRepositoryMockGetDetailByIDExpectation{} + } + + if mmGetDetailByID.defaultExpectation.paramPtrs != nil { + mmGetDetailByID.mock.t.Fatalf("RequestRepositoryMock.GetDetailByID mock is already set by ExpectParams functions") + } + + mmGetDetailByID.defaultExpectation.params = &RequestRepositoryMockGetDetailByIDParams{ctx, id} + mmGetDetailByID.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmGetDetailByID.expectations { + if minimock.Equal(e.params, mmGetDetailByID.defaultExpectation.params) { + mmGetDetailByID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetDetailByID.defaultExpectation.params) + } + } + + return mmGetDetailByID +} + +// ExpectCtxParam1 sets up expected param ctx for RequestRepository.GetDetailByID +func (mmGetDetailByID *mRequestRepositoryMockGetDetailByID) ExpectCtxParam1(ctx context.Context) *mRequestRepositoryMockGetDetailByID { + if mmGetDetailByID.mock.funcGetDetailByID != nil { + mmGetDetailByID.mock.t.Fatalf("RequestRepositoryMock.GetDetailByID mock is already set by Set") + } + + if mmGetDetailByID.defaultExpectation == nil { + mmGetDetailByID.defaultExpectation = &RequestRepositoryMockGetDetailByIDExpectation{} + } + + if mmGetDetailByID.defaultExpectation.params != nil { + mmGetDetailByID.mock.t.Fatalf("RequestRepositoryMock.GetDetailByID mock is already set by Expect") + } + + if mmGetDetailByID.defaultExpectation.paramPtrs == nil { + mmGetDetailByID.defaultExpectation.paramPtrs = &RequestRepositoryMockGetDetailByIDParamPtrs{} + } + mmGetDetailByID.defaultExpectation.paramPtrs.ctx = &ctx + mmGetDetailByID.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmGetDetailByID +} + +// ExpectIdParam2 sets up expected param id for RequestRepository.GetDetailByID +func (mmGetDetailByID *mRequestRepositoryMockGetDetailByID) ExpectIdParam2(id uuid.UUID) *mRequestRepositoryMockGetDetailByID { + if mmGetDetailByID.mock.funcGetDetailByID != nil { + mmGetDetailByID.mock.t.Fatalf("RequestRepositoryMock.GetDetailByID mock is already set by Set") + } + + if mmGetDetailByID.defaultExpectation == nil { + mmGetDetailByID.defaultExpectation = &RequestRepositoryMockGetDetailByIDExpectation{} + } + + if mmGetDetailByID.defaultExpectation.params != nil { + mmGetDetailByID.mock.t.Fatalf("RequestRepositoryMock.GetDetailByID mock is already set by Expect") + } + + if mmGetDetailByID.defaultExpectation.paramPtrs == nil { + mmGetDetailByID.defaultExpectation.paramPtrs = &RequestRepositoryMockGetDetailByIDParamPtrs{} + } + mmGetDetailByID.defaultExpectation.paramPtrs.id = &id + mmGetDetailByID.defaultExpectation.expectationOrigins.originId = minimock.CallerInfo(1) + + return mmGetDetailByID +} + +// Inspect accepts an inspector function that has same arguments as the RequestRepository.GetDetailByID +func (mmGetDetailByID *mRequestRepositoryMockGetDetailByID) Inspect(f func(ctx context.Context, id uuid.UUID)) *mRequestRepositoryMockGetDetailByID { + if mmGetDetailByID.mock.inspectFuncGetDetailByID != nil { + mmGetDetailByID.mock.t.Fatalf("Inspect function is already set for RequestRepositoryMock.GetDetailByID") + } + + mmGetDetailByID.mock.inspectFuncGetDetailByID = f + + return mmGetDetailByID +} + +// Return sets up results that will be returned by RequestRepository.GetDetailByID +func (mmGetDetailByID *mRequestRepositoryMockGetDetailByID) Return(rp1 *model.RequestDetail, err error) *RequestRepositoryMock { + if mmGetDetailByID.mock.funcGetDetailByID != nil { + mmGetDetailByID.mock.t.Fatalf("RequestRepositoryMock.GetDetailByID mock is already set by Set") + } + + if mmGetDetailByID.defaultExpectation == nil { + mmGetDetailByID.defaultExpectation = &RequestRepositoryMockGetDetailByIDExpectation{mock: mmGetDetailByID.mock} + } + mmGetDetailByID.defaultExpectation.results = &RequestRepositoryMockGetDetailByIDResults{rp1, err} + mmGetDetailByID.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmGetDetailByID.mock +} + +// Set uses given function f to mock the RequestRepository.GetDetailByID method +func (mmGetDetailByID *mRequestRepositoryMockGetDetailByID) Set(f func(ctx context.Context, id uuid.UUID) (rp1 *model.RequestDetail, err error)) *RequestRepositoryMock { + if mmGetDetailByID.defaultExpectation != nil { + mmGetDetailByID.mock.t.Fatalf("Default expectation is already set for the RequestRepository.GetDetailByID method") + } + + if len(mmGetDetailByID.expectations) > 0 { + mmGetDetailByID.mock.t.Fatalf("Some expectations are already set for the RequestRepository.GetDetailByID method") + } + + mmGetDetailByID.mock.funcGetDetailByID = f + mmGetDetailByID.mock.funcGetDetailByIDOrigin = minimock.CallerInfo(1) + return mmGetDetailByID.mock +} + +// When sets expectation for the RequestRepository.GetDetailByID which will trigger the result defined by the following +// Then helper +func (mmGetDetailByID *mRequestRepositoryMockGetDetailByID) When(ctx context.Context, id uuid.UUID) *RequestRepositoryMockGetDetailByIDExpectation { + if mmGetDetailByID.mock.funcGetDetailByID != nil { + mmGetDetailByID.mock.t.Fatalf("RequestRepositoryMock.GetDetailByID mock is already set by Set") + } + + expectation := &RequestRepositoryMockGetDetailByIDExpectation{ + mock: mmGetDetailByID.mock, + params: &RequestRepositoryMockGetDetailByIDParams{ctx, id}, + expectationOrigins: RequestRepositoryMockGetDetailByIDExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmGetDetailByID.expectations = append(mmGetDetailByID.expectations, expectation) + return expectation +} + +// Then sets up RequestRepository.GetDetailByID return parameters for the expectation previously defined by the When method +func (e *RequestRepositoryMockGetDetailByIDExpectation) Then(rp1 *model.RequestDetail, err error) *RequestRepositoryMock { + e.results = &RequestRepositoryMockGetDetailByIDResults{rp1, err} + return e.mock +} + +// Times sets number of times RequestRepository.GetDetailByID should be invoked +func (mmGetDetailByID *mRequestRepositoryMockGetDetailByID) Times(n uint64) *mRequestRepositoryMockGetDetailByID { + if n == 0 { + mmGetDetailByID.mock.t.Fatalf("Times of RequestRepositoryMock.GetDetailByID mock can not be zero") + } + mm_atomic.StoreUint64(&mmGetDetailByID.expectedInvocations, n) + mmGetDetailByID.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmGetDetailByID +} + +func (mmGetDetailByID *mRequestRepositoryMockGetDetailByID) invocationsDone() bool { + if len(mmGetDetailByID.expectations) == 0 && mmGetDetailByID.defaultExpectation == nil && mmGetDetailByID.mock.funcGetDetailByID == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmGetDetailByID.mock.afterGetDetailByIDCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmGetDetailByID.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// GetDetailByID implements mm_repository.RequestRepository +func (mmGetDetailByID *RequestRepositoryMock) GetDetailByID(ctx context.Context, id uuid.UUID) (rp1 *model.RequestDetail, err error) { + mm_atomic.AddUint64(&mmGetDetailByID.beforeGetDetailByIDCounter, 1) + defer mm_atomic.AddUint64(&mmGetDetailByID.afterGetDetailByIDCounter, 1) + + mmGetDetailByID.t.Helper() + + if mmGetDetailByID.inspectFuncGetDetailByID != nil { + mmGetDetailByID.inspectFuncGetDetailByID(ctx, id) + } + + mm_params := RequestRepositoryMockGetDetailByIDParams{ctx, id} + + // Record call args + mmGetDetailByID.GetDetailByIDMock.mutex.Lock() + mmGetDetailByID.GetDetailByIDMock.callArgs = append(mmGetDetailByID.GetDetailByIDMock.callArgs, &mm_params) + mmGetDetailByID.GetDetailByIDMock.mutex.Unlock() + + for _, e := range mmGetDetailByID.GetDetailByIDMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.rp1, e.results.err + } + } + + if mmGetDetailByID.GetDetailByIDMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmGetDetailByID.GetDetailByIDMock.defaultExpectation.Counter, 1) + mm_want := mmGetDetailByID.GetDetailByIDMock.defaultExpectation.params + mm_want_ptrs := mmGetDetailByID.GetDetailByIDMock.defaultExpectation.paramPtrs + + mm_got := RequestRepositoryMockGetDetailByIDParams{ctx, id} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmGetDetailByID.t.Errorf("RequestRepositoryMock.GetDetailByID got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetDetailByID.GetDetailByIDMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) { + mmGetDetailByID.t.Errorf("RequestRepositoryMock.GetDetailByID got unexpected parameter id, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetDetailByID.GetDetailByIDMock.defaultExpectation.expectationOrigins.originId, *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmGetDetailByID.t.Errorf("RequestRepositoryMock.GetDetailByID got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetDetailByID.GetDetailByIDMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmGetDetailByID.GetDetailByIDMock.defaultExpectation.results + if mm_results == nil { + mmGetDetailByID.t.Fatal("No results are set for the RequestRepositoryMock.GetDetailByID") + } + return (*mm_results).rp1, (*mm_results).err + } + if mmGetDetailByID.funcGetDetailByID != nil { + return mmGetDetailByID.funcGetDetailByID(ctx, id) + } + mmGetDetailByID.t.Fatalf("Unexpected call to RequestRepositoryMock.GetDetailByID. %v %v", ctx, id) + return +} + +// GetDetailByIDAfterCounter returns a count of finished RequestRepositoryMock.GetDetailByID invocations +func (mmGetDetailByID *RequestRepositoryMock) GetDetailByIDAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetDetailByID.afterGetDetailByIDCounter) +} + +// GetDetailByIDBeforeCounter returns a count of RequestRepositoryMock.GetDetailByID invocations +func (mmGetDetailByID *RequestRepositoryMock) GetDetailByIDBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetDetailByID.beforeGetDetailByIDCounter) +} + +// Calls returns a list of arguments used in each call to RequestRepositoryMock.GetDetailByID. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmGetDetailByID *mRequestRepositoryMockGetDetailByID) Calls() []*RequestRepositoryMockGetDetailByIDParams { + mmGetDetailByID.mutex.RLock() + + argCopy := make([]*RequestRepositoryMockGetDetailByIDParams, len(mmGetDetailByID.callArgs)) + copy(argCopy, mmGetDetailByID.callArgs) + + mmGetDetailByID.mutex.RUnlock() + + return argCopy +} + +// MinimockGetDetailByIDDone returns true if the count of the GetDetailByID invocations corresponds +// the number of defined expectations +func (m *RequestRepositoryMock) MinimockGetDetailByIDDone() bool { + if m.GetDetailByIDMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.GetDetailByIDMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.GetDetailByIDMock.invocationsDone() +} + +// MinimockGetDetailByIDInspect logs each unmet expectation +func (m *RequestRepositoryMock) MinimockGetDetailByIDInspect() { + for _, e := range m.GetDetailByIDMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to RequestRepositoryMock.GetDetailByID at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterGetDetailByIDCounter := mm_atomic.LoadUint64(&m.afterGetDetailByIDCounter) + // if default expectation was set then invocations count should be greater than zero + if m.GetDetailByIDMock.defaultExpectation != nil && afterGetDetailByIDCounter < 1 { + if m.GetDetailByIDMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to RequestRepositoryMock.GetDetailByID at\n%s", m.GetDetailByIDMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to RequestRepositoryMock.GetDetailByID at\n%s with params: %#v", m.GetDetailByIDMock.defaultExpectation.expectationOrigins.origin, *m.GetDetailByIDMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcGetDetailByID != nil && afterGetDetailByIDCounter < 1 { + m.t.Errorf("Expected call to RequestRepositoryMock.GetDetailByID at\n%s", m.funcGetDetailByIDOrigin) + } + + if !m.GetDetailByIDMock.invocationsDone() && afterGetDetailByIDCounter > 0 { + m.t.Errorf("Expected %d calls to RequestRepositoryMock.GetDetailByID at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.GetDetailByIDMock.expectedInvocations), m.GetDetailByIDMock.expectedInvocationsOrigin, afterGetDetailByIDCounter) + } +} + +type mRequestRepositoryMockGetUserStatistics struct { + optional bool + mock *RequestRepositoryMock + defaultExpectation *RequestRepositoryMockGetUserStatisticsExpectation + expectations []*RequestRepositoryMockGetUserStatisticsExpectation + + callArgs []*RequestRepositoryMockGetUserStatisticsParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// RequestRepositoryMockGetUserStatisticsExpectation specifies expectation struct of the RequestRepository.GetUserStatistics +type RequestRepositoryMockGetUserStatisticsExpectation struct { + mock *RequestRepositoryMock + params *RequestRepositoryMockGetUserStatisticsParams + paramPtrs *RequestRepositoryMockGetUserStatisticsParamPtrs + expectationOrigins RequestRepositoryMockGetUserStatisticsExpectationOrigins + results *RequestRepositoryMockGetUserStatisticsResults + returnOrigin string + Counter uint64 +} + +// RequestRepositoryMockGetUserStatisticsParams contains parameters of the RequestRepository.GetUserStatistics +type RequestRepositoryMockGetUserStatisticsParams struct { + ctx context.Context + userID int +} + +// RequestRepositoryMockGetUserStatisticsParamPtrs contains pointers to parameters of the RequestRepository.GetUserStatistics +type RequestRepositoryMockGetUserStatisticsParamPtrs struct { + ctx *context.Context + userID *int +} + +// RequestRepositoryMockGetUserStatisticsResults contains results of the RequestRepository.GetUserStatistics +type RequestRepositoryMockGetUserStatisticsResults struct { + requestsCount int + suppliersCount int + createdTZ int + err error +} + +// RequestRepositoryMockGetUserStatisticsOrigins contains origins of expectations of the RequestRepository.GetUserStatistics +type RequestRepositoryMockGetUserStatisticsExpectationOrigins struct { + origin string + originCtx string + originUserID string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmGetUserStatistics *mRequestRepositoryMockGetUserStatistics) Optional() *mRequestRepositoryMockGetUserStatistics { + mmGetUserStatistics.optional = true + return mmGetUserStatistics +} + +// Expect sets up expected params for RequestRepository.GetUserStatistics +func (mmGetUserStatistics *mRequestRepositoryMockGetUserStatistics) Expect(ctx context.Context, userID int) *mRequestRepositoryMockGetUserStatistics { + if mmGetUserStatistics.mock.funcGetUserStatistics != nil { + mmGetUserStatistics.mock.t.Fatalf("RequestRepositoryMock.GetUserStatistics mock is already set by Set") + } + + if mmGetUserStatistics.defaultExpectation == nil { + mmGetUserStatistics.defaultExpectation = &RequestRepositoryMockGetUserStatisticsExpectation{} + } + + if mmGetUserStatistics.defaultExpectation.paramPtrs != nil { + mmGetUserStatistics.mock.t.Fatalf("RequestRepositoryMock.GetUserStatistics mock is already set by ExpectParams functions") + } + + mmGetUserStatistics.defaultExpectation.params = &RequestRepositoryMockGetUserStatisticsParams{ctx, userID} + mmGetUserStatistics.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmGetUserStatistics.expectations { + if minimock.Equal(e.params, mmGetUserStatistics.defaultExpectation.params) { + mmGetUserStatistics.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetUserStatistics.defaultExpectation.params) + } + } + + return mmGetUserStatistics +} + +// ExpectCtxParam1 sets up expected param ctx for RequestRepository.GetUserStatistics +func (mmGetUserStatistics *mRequestRepositoryMockGetUserStatistics) ExpectCtxParam1(ctx context.Context) *mRequestRepositoryMockGetUserStatistics { + if mmGetUserStatistics.mock.funcGetUserStatistics != nil { + mmGetUserStatistics.mock.t.Fatalf("RequestRepositoryMock.GetUserStatistics mock is already set by Set") + } + + if mmGetUserStatistics.defaultExpectation == nil { + mmGetUserStatistics.defaultExpectation = &RequestRepositoryMockGetUserStatisticsExpectation{} + } + + if mmGetUserStatistics.defaultExpectation.params != nil { + mmGetUserStatistics.mock.t.Fatalf("RequestRepositoryMock.GetUserStatistics mock is already set by Expect") + } + + if mmGetUserStatistics.defaultExpectation.paramPtrs == nil { + mmGetUserStatistics.defaultExpectation.paramPtrs = &RequestRepositoryMockGetUserStatisticsParamPtrs{} + } + mmGetUserStatistics.defaultExpectation.paramPtrs.ctx = &ctx + mmGetUserStatistics.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmGetUserStatistics +} + +// ExpectUserIDParam2 sets up expected param userID for RequestRepository.GetUserStatistics +func (mmGetUserStatistics *mRequestRepositoryMockGetUserStatistics) ExpectUserIDParam2(userID int) *mRequestRepositoryMockGetUserStatistics { + if mmGetUserStatistics.mock.funcGetUserStatistics != nil { + mmGetUserStatistics.mock.t.Fatalf("RequestRepositoryMock.GetUserStatistics mock is already set by Set") + } + + if mmGetUserStatistics.defaultExpectation == nil { + mmGetUserStatistics.defaultExpectation = &RequestRepositoryMockGetUserStatisticsExpectation{} + } + + if mmGetUserStatistics.defaultExpectation.params != nil { + mmGetUserStatistics.mock.t.Fatalf("RequestRepositoryMock.GetUserStatistics mock is already set by Expect") + } + + if mmGetUserStatistics.defaultExpectation.paramPtrs == nil { + mmGetUserStatistics.defaultExpectation.paramPtrs = &RequestRepositoryMockGetUserStatisticsParamPtrs{} + } + mmGetUserStatistics.defaultExpectation.paramPtrs.userID = &userID + mmGetUserStatistics.defaultExpectation.expectationOrigins.originUserID = minimock.CallerInfo(1) + + return mmGetUserStatistics +} + +// Inspect accepts an inspector function that has same arguments as the RequestRepository.GetUserStatistics +func (mmGetUserStatistics *mRequestRepositoryMockGetUserStatistics) Inspect(f func(ctx context.Context, userID int)) *mRequestRepositoryMockGetUserStatistics { + if mmGetUserStatistics.mock.inspectFuncGetUserStatistics != nil { + mmGetUserStatistics.mock.t.Fatalf("Inspect function is already set for RequestRepositoryMock.GetUserStatistics") + } + + mmGetUserStatistics.mock.inspectFuncGetUserStatistics = f + + return mmGetUserStatistics +} + +// Return sets up results that will be returned by RequestRepository.GetUserStatistics +func (mmGetUserStatistics *mRequestRepositoryMockGetUserStatistics) Return(requestsCount int, suppliersCount int, createdTZ int, err error) *RequestRepositoryMock { + if mmGetUserStatistics.mock.funcGetUserStatistics != nil { + mmGetUserStatistics.mock.t.Fatalf("RequestRepositoryMock.GetUserStatistics mock is already set by Set") + } + + if mmGetUserStatistics.defaultExpectation == nil { + mmGetUserStatistics.defaultExpectation = &RequestRepositoryMockGetUserStatisticsExpectation{mock: mmGetUserStatistics.mock} + } + mmGetUserStatistics.defaultExpectation.results = &RequestRepositoryMockGetUserStatisticsResults{requestsCount, suppliersCount, createdTZ, err} + mmGetUserStatistics.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmGetUserStatistics.mock +} + +// Set uses given function f to mock the RequestRepository.GetUserStatistics method +func (mmGetUserStatistics *mRequestRepositoryMockGetUserStatistics) Set(f func(ctx context.Context, userID int) (requestsCount int, suppliersCount int, createdTZ int, err error)) *RequestRepositoryMock { + if mmGetUserStatistics.defaultExpectation != nil { + mmGetUserStatistics.mock.t.Fatalf("Default expectation is already set for the RequestRepository.GetUserStatistics method") + } + + if len(mmGetUserStatistics.expectations) > 0 { + mmGetUserStatistics.mock.t.Fatalf("Some expectations are already set for the RequestRepository.GetUserStatistics method") + } + + mmGetUserStatistics.mock.funcGetUserStatistics = f + mmGetUserStatistics.mock.funcGetUserStatisticsOrigin = minimock.CallerInfo(1) + return mmGetUserStatistics.mock +} + +// When sets expectation for the RequestRepository.GetUserStatistics which will trigger the result defined by the following +// Then helper +func (mmGetUserStatistics *mRequestRepositoryMockGetUserStatistics) When(ctx context.Context, userID int) *RequestRepositoryMockGetUserStatisticsExpectation { + if mmGetUserStatistics.mock.funcGetUserStatistics != nil { + mmGetUserStatistics.mock.t.Fatalf("RequestRepositoryMock.GetUserStatistics mock is already set by Set") + } + + expectation := &RequestRepositoryMockGetUserStatisticsExpectation{ + mock: mmGetUserStatistics.mock, + params: &RequestRepositoryMockGetUserStatisticsParams{ctx, userID}, + expectationOrigins: RequestRepositoryMockGetUserStatisticsExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmGetUserStatistics.expectations = append(mmGetUserStatistics.expectations, expectation) + return expectation +} + +// Then sets up RequestRepository.GetUserStatistics return parameters for the expectation previously defined by the When method +func (e *RequestRepositoryMockGetUserStatisticsExpectation) Then(requestsCount int, suppliersCount int, createdTZ int, err error) *RequestRepositoryMock { + e.results = &RequestRepositoryMockGetUserStatisticsResults{requestsCount, suppliersCount, createdTZ, err} + return e.mock +} + +// Times sets number of times RequestRepository.GetUserStatistics should be invoked +func (mmGetUserStatistics *mRequestRepositoryMockGetUserStatistics) Times(n uint64) *mRequestRepositoryMockGetUserStatistics { + if n == 0 { + mmGetUserStatistics.mock.t.Fatalf("Times of RequestRepositoryMock.GetUserStatistics mock can not be zero") + } + mm_atomic.StoreUint64(&mmGetUserStatistics.expectedInvocations, n) + mmGetUserStatistics.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmGetUserStatistics +} + +func (mmGetUserStatistics *mRequestRepositoryMockGetUserStatistics) invocationsDone() bool { + if len(mmGetUserStatistics.expectations) == 0 && mmGetUserStatistics.defaultExpectation == nil && mmGetUserStatistics.mock.funcGetUserStatistics == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmGetUserStatistics.mock.afterGetUserStatisticsCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmGetUserStatistics.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// GetUserStatistics implements mm_repository.RequestRepository +func (mmGetUserStatistics *RequestRepositoryMock) GetUserStatistics(ctx context.Context, userID int) (requestsCount int, suppliersCount int, createdTZ int, err error) { + mm_atomic.AddUint64(&mmGetUserStatistics.beforeGetUserStatisticsCounter, 1) + defer mm_atomic.AddUint64(&mmGetUserStatistics.afterGetUserStatisticsCounter, 1) + + mmGetUserStatistics.t.Helper() + + if mmGetUserStatistics.inspectFuncGetUserStatistics != nil { + mmGetUserStatistics.inspectFuncGetUserStatistics(ctx, userID) + } + + mm_params := RequestRepositoryMockGetUserStatisticsParams{ctx, userID} + + // Record call args + mmGetUserStatistics.GetUserStatisticsMock.mutex.Lock() + mmGetUserStatistics.GetUserStatisticsMock.callArgs = append(mmGetUserStatistics.GetUserStatisticsMock.callArgs, &mm_params) + mmGetUserStatistics.GetUserStatisticsMock.mutex.Unlock() + + for _, e := range mmGetUserStatistics.GetUserStatisticsMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.requestsCount, e.results.suppliersCount, e.results.createdTZ, e.results.err + } + } + + if mmGetUserStatistics.GetUserStatisticsMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmGetUserStatistics.GetUserStatisticsMock.defaultExpectation.Counter, 1) + mm_want := mmGetUserStatistics.GetUserStatisticsMock.defaultExpectation.params + mm_want_ptrs := mmGetUserStatistics.GetUserStatisticsMock.defaultExpectation.paramPtrs + + mm_got := RequestRepositoryMockGetUserStatisticsParams{ctx, userID} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmGetUserStatistics.t.Errorf("RequestRepositoryMock.GetUserStatistics got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetUserStatistics.GetUserStatisticsMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.userID != nil && !minimock.Equal(*mm_want_ptrs.userID, mm_got.userID) { + mmGetUserStatistics.t.Errorf("RequestRepositoryMock.GetUserStatistics got unexpected parameter userID, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetUserStatistics.GetUserStatisticsMock.defaultExpectation.expectationOrigins.originUserID, *mm_want_ptrs.userID, mm_got.userID, minimock.Diff(*mm_want_ptrs.userID, mm_got.userID)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmGetUserStatistics.t.Errorf("RequestRepositoryMock.GetUserStatistics got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetUserStatistics.GetUserStatisticsMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmGetUserStatistics.GetUserStatisticsMock.defaultExpectation.results + if mm_results == nil { + mmGetUserStatistics.t.Fatal("No results are set for the RequestRepositoryMock.GetUserStatistics") + } + return (*mm_results).requestsCount, (*mm_results).suppliersCount, (*mm_results).createdTZ, (*mm_results).err + } + if mmGetUserStatistics.funcGetUserStatistics != nil { + return mmGetUserStatistics.funcGetUserStatistics(ctx, userID) + } + mmGetUserStatistics.t.Fatalf("Unexpected call to RequestRepositoryMock.GetUserStatistics. %v %v", ctx, userID) + return +} + +// GetUserStatisticsAfterCounter returns a count of finished RequestRepositoryMock.GetUserStatistics invocations +func (mmGetUserStatistics *RequestRepositoryMock) GetUserStatisticsAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetUserStatistics.afterGetUserStatisticsCounter) +} + +// GetUserStatisticsBeforeCounter returns a count of RequestRepositoryMock.GetUserStatistics invocations +func (mmGetUserStatistics *RequestRepositoryMock) GetUserStatisticsBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetUserStatistics.beforeGetUserStatisticsCounter) +} + +// Calls returns a list of arguments used in each call to RequestRepositoryMock.GetUserStatistics. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmGetUserStatistics *mRequestRepositoryMockGetUserStatistics) Calls() []*RequestRepositoryMockGetUserStatisticsParams { + mmGetUserStatistics.mutex.RLock() + + argCopy := make([]*RequestRepositoryMockGetUserStatisticsParams, len(mmGetUserStatistics.callArgs)) + copy(argCopy, mmGetUserStatistics.callArgs) + + mmGetUserStatistics.mutex.RUnlock() + + return argCopy +} + +// MinimockGetUserStatisticsDone returns true if the count of the GetUserStatistics invocations corresponds +// the number of defined expectations +func (m *RequestRepositoryMock) MinimockGetUserStatisticsDone() bool { + if m.GetUserStatisticsMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.GetUserStatisticsMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.GetUserStatisticsMock.invocationsDone() +} + +// MinimockGetUserStatisticsInspect logs each unmet expectation +func (m *RequestRepositoryMock) MinimockGetUserStatisticsInspect() { + for _, e := range m.GetUserStatisticsMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to RequestRepositoryMock.GetUserStatistics at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterGetUserStatisticsCounter := mm_atomic.LoadUint64(&m.afterGetUserStatisticsCounter) + // if default expectation was set then invocations count should be greater than zero + if m.GetUserStatisticsMock.defaultExpectation != nil && afterGetUserStatisticsCounter < 1 { + if m.GetUserStatisticsMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to RequestRepositoryMock.GetUserStatistics at\n%s", m.GetUserStatisticsMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to RequestRepositoryMock.GetUserStatistics at\n%s with params: %#v", m.GetUserStatisticsMock.defaultExpectation.expectationOrigins.origin, *m.GetUserStatisticsMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcGetUserStatistics != nil && afterGetUserStatisticsCounter < 1 { + m.t.Errorf("Expected call to RequestRepositoryMock.GetUserStatistics at\n%s", m.funcGetUserStatisticsOrigin) + } + + if !m.GetUserStatisticsMock.invocationsDone() && afterGetUserStatisticsCounter > 0 { + m.t.Errorf("Expected %d calls to RequestRepositoryMock.GetUserStatistics at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.GetUserStatisticsMock.expectedInvocations), m.GetUserStatisticsMock.expectedInvocationsOrigin, afterGetUserStatisticsCounter) + } +} + +type mRequestRepositoryMockUpdateFinalTZ struct { + optional bool + mock *RequestRepositoryMock + defaultExpectation *RequestRepositoryMockUpdateFinalTZExpectation + expectations []*RequestRepositoryMockUpdateFinalTZExpectation + + callArgs []*RequestRepositoryMockUpdateFinalTZParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// RequestRepositoryMockUpdateFinalTZExpectation specifies expectation struct of the RequestRepository.UpdateFinalTZ +type RequestRepositoryMockUpdateFinalTZExpectation struct { + mock *RequestRepositoryMock + params *RequestRepositoryMockUpdateFinalTZParams + paramPtrs *RequestRepositoryMockUpdateFinalTZParamPtrs + expectationOrigins RequestRepositoryMockUpdateFinalTZExpectationOrigins + results *RequestRepositoryMockUpdateFinalTZResults + returnOrigin string + Counter uint64 +} + +// RequestRepositoryMockUpdateFinalTZParams contains parameters of the RequestRepository.UpdateFinalTZ +type RequestRepositoryMockUpdateFinalTZParams struct { + ctx context.Context + id uuid.UUID + finalTZ string +} + +// RequestRepositoryMockUpdateFinalTZParamPtrs contains pointers to parameters of the RequestRepository.UpdateFinalTZ +type RequestRepositoryMockUpdateFinalTZParamPtrs struct { + ctx *context.Context + id *uuid.UUID + finalTZ *string +} + +// RequestRepositoryMockUpdateFinalTZResults contains results of the RequestRepository.UpdateFinalTZ +type RequestRepositoryMockUpdateFinalTZResults struct { + err error +} + +// RequestRepositoryMockUpdateFinalTZOrigins contains origins of expectations of the RequestRepository.UpdateFinalTZ +type RequestRepositoryMockUpdateFinalTZExpectationOrigins struct { + origin string + originCtx string + originId string + originFinalTZ string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmUpdateFinalTZ *mRequestRepositoryMockUpdateFinalTZ) Optional() *mRequestRepositoryMockUpdateFinalTZ { + mmUpdateFinalTZ.optional = true + return mmUpdateFinalTZ +} + +// Expect sets up expected params for RequestRepository.UpdateFinalTZ +func (mmUpdateFinalTZ *mRequestRepositoryMockUpdateFinalTZ) Expect(ctx context.Context, id uuid.UUID, finalTZ string) *mRequestRepositoryMockUpdateFinalTZ { + if mmUpdateFinalTZ.mock.funcUpdateFinalTZ != nil { + mmUpdateFinalTZ.mock.t.Fatalf("RequestRepositoryMock.UpdateFinalTZ mock is already set by Set") + } + + if mmUpdateFinalTZ.defaultExpectation == nil { + mmUpdateFinalTZ.defaultExpectation = &RequestRepositoryMockUpdateFinalTZExpectation{} + } + + if mmUpdateFinalTZ.defaultExpectation.paramPtrs != nil { + mmUpdateFinalTZ.mock.t.Fatalf("RequestRepositoryMock.UpdateFinalTZ mock is already set by ExpectParams functions") + } + + mmUpdateFinalTZ.defaultExpectation.params = &RequestRepositoryMockUpdateFinalTZParams{ctx, id, finalTZ} + mmUpdateFinalTZ.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmUpdateFinalTZ.expectations { + if minimock.Equal(e.params, mmUpdateFinalTZ.defaultExpectation.params) { + mmUpdateFinalTZ.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmUpdateFinalTZ.defaultExpectation.params) + } + } + + return mmUpdateFinalTZ +} + +// ExpectCtxParam1 sets up expected param ctx for RequestRepository.UpdateFinalTZ +func (mmUpdateFinalTZ *mRequestRepositoryMockUpdateFinalTZ) ExpectCtxParam1(ctx context.Context) *mRequestRepositoryMockUpdateFinalTZ { + if mmUpdateFinalTZ.mock.funcUpdateFinalTZ != nil { + mmUpdateFinalTZ.mock.t.Fatalf("RequestRepositoryMock.UpdateFinalTZ mock is already set by Set") + } + + if mmUpdateFinalTZ.defaultExpectation == nil { + mmUpdateFinalTZ.defaultExpectation = &RequestRepositoryMockUpdateFinalTZExpectation{} + } + + if mmUpdateFinalTZ.defaultExpectation.params != nil { + mmUpdateFinalTZ.mock.t.Fatalf("RequestRepositoryMock.UpdateFinalTZ mock is already set by Expect") + } + + if mmUpdateFinalTZ.defaultExpectation.paramPtrs == nil { + mmUpdateFinalTZ.defaultExpectation.paramPtrs = &RequestRepositoryMockUpdateFinalTZParamPtrs{} + } + mmUpdateFinalTZ.defaultExpectation.paramPtrs.ctx = &ctx + mmUpdateFinalTZ.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmUpdateFinalTZ +} + +// ExpectIdParam2 sets up expected param id for RequestRepository.UpdateFinalTZ +func (mmUpdateFinalTZ *mRequestRepositoryMockUpdateFinalTZ) ExpectIdParam2(id uuid.UUID) *mRequestRepositoryMockUpdateFinalTZ { + if mmUpdateFinalTZ.mock.funcUpdateFinalTZ != nil { + mmUpdateFinalTZ.mock.t.Fatalf("RequestRepositoryMock.UpdateFinalTZ mock is already set by Set") + } + + if mmUpdateFinalTZ.defaultExpectation == nil { + mmUpdateFinalTZ.defaultExpectation = &RequestRepositoryMockUpdateFinalTZExpectation{} + } + + if mmUpdateFinalTZ.defaultExpectation.params != nil { + mmUpdateFinalTZ.mock.t.Fatalf("RequestRepositoryMock.UpdateFinalTZ mock is already set by Expect") + } + + if mmUpdateFinalTZ.defaultExpectation.paramPtrs == nil { + mmUpdateFinalTZ.defaultExpectation.paramPtrs = &RequestRepositoryMockUpdateFinalTZParamPtrs{} + } + mmUpdateFinalTZ.defaultExpectation.paramPtrs.id = &id + mmUpdateFinalTZ.defaultExpectation.expectationOrigins.originId = minimock.CallerInfo(1) + + return mmUpdateFinalTZ +} + +// ExpectFinalTZParam3 sets up expected param finalTZ for RequestRepository.UpdateFinalTZ +func (mmUpdateFinalTZ *mRequestRepositoryMockUpdateFinalTZ) ExpectFinalTZParam3(finalTZ string) *mRequestRepositoryMockUpdateFinalTZ { + if mmUpdateFinalTZ.mock.funcUpdateFinalTZ != nil { + mmUpdateFinalTZ.mock.t.Fatalf("RequestRepositoryMock.UpdateFinalTZ mock is already set by Set") + } + + if mmUpdateFinalTZ.defaultExpectation == nil { + mmUpdateFinalTZ.defaultExpectation = &RequestRepositoryMockUpdateFinalTZExpectation{} + } + + if mmUpdateFinalTZ.defaultExpectation.params != nil { + mmUpdateFinalTZ.mock.t.Fatalf("RequestRepositoryMock.UpdateFinalTZ mock is already set by Expect") + } + + if mmUpdateFinalTZ.defaultExpectation.paramPtrs == nil { + mmUpdateFinalTZ.defaultExpectation.paramPtrs = &RequestRepositoryMockUpdateFinalTZParamPtrs{} + } + mmUpdateFinalTZ.defaultExpectation.paramPtrs.finalTZ = &finalTZ + mmUpdateFinalTZ.defaultExpectation.expectationOrigins.originFinalTZ = minimock.CallerInfo(1) + + return mmUpdateFinalTZ +} + +// Inspect accepts an inspector function that has same arguments as the RequestRepository.UpdateFinalTZ +func (mmUpdateFinalTZ *mRequestRepositoryMockUpdateFinalTZ) Inspect(f func(ctx context.Context, id uuid.UUID, finalTZ string)) *mRequestRepositoryMockUpdateFinalTZ { + if mmUpdateFinalTZ.mock.inspectFuncUpdateFinalTZ != nil { + mmUpdateFinalTZ.mock.t.Fatalf("Inspect function is already set for RequestRepositoryMock.UpdateFinalTZ") + } + + mmUpdateFinalTZ.mock.inspectFuncUpdateFinalTZ = f + + return mmUpdateFinalTZ +} + +// Return sets up results that will be returned by RequestRepository.UpdateFinalTZ +func (mmUpdateFinalTZ *mRequestRepositoryMockUpdateFinalTZ) Return(err error) *RequestRepositoryMock { + if mmUpdateFinalTZ.mock.funcUpdateFinalTZ != nil { + mmUpdateFinalTZ.mock.t.Fatalf("RequestRepositoryMock.UpdateFinalTZ mock is already set by Set") + } + + if mmUpdateFinalTZ.defaultExpectation == nil { + mmUpdateFinalTZ.defaultExpectation = &RequestRepositoryMockUpdateFinalTZExpectation{mock: mmUpdateFinalTZ.mock} + } + mmUpdateFinalTZ.defaultExpectation.results = &RequestRepositoryMockUpdateFinalTZResults{err} + mmUpdateFinalTZ.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmUpdateFinalTZ.mock +} + +// Set uses given function f to mock the RequestRepository.UpdateFinalTZ method +func (mmUpdateFinalTZ *mRequestRepositoryMockUpdateFinalTZ) Set(f func(ctx context.Context, id uuid.UUID, finalTZ string) (err error)) *RequestRepositoryMock { + if mmUpdateFinalTZ.defaultExpectation != nil { + mmUpdateFinalTZ.mock.t.Fatalf("Default expectation is already set for the RequestRepository.UpdateFinalTZ method") + } + + if len(mmUpdateFinalTZ.expectations) > 0 { + mmUpdateFinalTZ.mock.t.Fatalf("Some expectations are already set for the RequestRepository.UpdateFinalTZ method") + } + + mmUpdateFinalTZ.mock.funcUpdateFinalTZ = f + mmUpdateFinalTZ.mock.funcUpdateFinalTZOrigin = minimock.CallerInfo(1) + return mmUpdateFinalTZ.mock +} + +// When sets expectation for the RequestRepository.UpdateFinalTZ which will trigger the result defined by the following +// Then helper +func (mmUpdateFinalTZ *mRequestRepositoryMockUpdateFinalTZ) When(ctx context.Context, id uuid.UUID, finalTZ string) *RequestRepositoryMockUpdateFinalTZExpectation { + if mmUpdateFinalTZ.mock.funcUpdateFinalTZ != nil { + mmUpdateFinalTZ.mock.t.Fatalf("RequestRepositoryMock.UpdateFinalTZ mock is already set by Set") + } + + expectation := &RequestRepositoryMockUpdateFinalTZExpectation{ + mock: mmUpdateFinalTZ.mock, + params: &RequestRepositoryMockUpdateFinalTZParams{ctx, id, finalTZ}, + expectationOrigins: RequestRepositoryMockUpdateFinalTZExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmUpdateFinalTZ.expectations = append(mmUpdateFinalTZ.expectations, expectation) + return expectation +} + +// Then sets up RequestRepository.UpdateFinalTZ return parameters for the expectation previously defined by the When method +func (e *RequestRepositoryMockUpdateFinalTZExpectation) Then(err error) *RequestRepositoryMock { + e.results = &RequestRepositoryMockUpdateFinalTZResults{err} + return e.mock +} + +// Times sets number of times RequestRepository.UpdateFinalTZ should be invoked +func (mmUpdateFinalTZ *mRequestRepositoryMockUpdateFinalTZ) Times(n uint64) *mRequestRepositoryMockUpdateFinalTZ { + if n == 0 { + mmUpdateFinalTZ.mock.t.Fatalf("Times of RequestRepositoryMock.UpdateFinalTZ mock can not be zero") + } + mm_atomic.StoreUint64(&mmUpdateFinalTZ.expectedInvocations, n) + mmUpdateFinalTZ.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmUpdateFinalTZ +} + +func (mmUpdateFinalTZ *mRequestRepositoryMockUpdateFinalTZ) invocationsDone() bool { + if len(mmUpdateFinalTZ.expectations) == 0 && mmUpdateFinalTZ.defaultExpectation == nil && mmUpdateFinalTZ.mock.funcUpdateFinalTZ == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmUpdateFinalTZ.mock.afterUpdateFinalTZCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmUpdateFinalTZ.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// UpdateFinalTZ implements mm_repository.RequestRepository +func (mmUpdateFinalTZ *RequestRepositoryMock) UpdateFinalTZ(ctx context.Context, id uuid.UUID, finalTZ string) (err error) { + mm_atomic.AddUint64(&mmUpdateFinalTZ.beforeUpdateFinalTZCounter, 1) + defer mm_atomic.AddUint64(&mmUpdateFinalTZ.afterUpdateFinalTZCounter, 1) + + mmUpdateFinalTZ.t.Helper() + + if mmUpdateFinalTZ.inspectFuncUpdateFinalTZ != nil { + mmUpdateFinalTZ.inspectFuncUpdateFinalTZ(ctx, id, finalTZ) + } + + mm_params := RequestRepositoryMockUpdateFinalTZParams{ctx, id, finalTZ} + + // Record call args + mmUpdateFinalTZ.UpdateFinalTZMock.mutex.Lock() + mmUpdateFinalTZ.UpdateFinalTZMock.callArgs = append(mmUpdateFinalTZ.UpdateFinalTZMock.callArgs, &mm_params) + mmUpdateFinalTZ.UpdateFinalTZMock.mutex.Unlock() + + for _, e := range mmUpdateFinalTZ.UpdateFinalTZMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.err + } + } + + if mmUpdateFinalTZ.UpdateFinalTZMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmUpdateFinalTZ.UpdateFinalTZMock.defaultExpectation.Counter, 1) + mm_want := mmUpdateFinalTZ.UpdateFinalTZMock.defaultExpectation.params + mm_want_ptrs := mmUpdateFinalTZ.UpdateFinalTZMock.defaultExpectation.paramPtrs + + mm_got := RequestRepositoryMockUpdateFinalTZParams{ctx, id, finalTZ} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmUpdateFinalTZ.t.Errorf("RequestRepositoryMock.UpdateFinalTZ got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmUpdateFinalTZ.UpdateFinalTZMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) { + mmUpdateFinalTZ.t.Errorf("RequestRepositoryMock.UpdateFinalTZ got unexpected parameter id, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmUpdateFinalTZ.UpdateFinalTZMock.defaultExpectation.expectationOrigins.originId, *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id)) + } + + if mm_want_ptrs.finalTZ != nil && !minimock.Equal(*mm_want_ptrs.finalTZ, mm_got.finalTZ) { + mmUpdateFinalTZ.t.Errorf("RequestRepositoryMock.UpdateFinalTZ got unexpected parameter finalTZ, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmUpdateFinalTZ.UpdateFinalTZMock.defaultExpectation.expectationOrigins.originFinalTZ, *mm_want_ptrs.finalTZ, mm_got.finalTZ, minimock.Diff(*mm_want_ptrs.finalTZ, mm_got.finalTZ)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmUpdateFinalTZ.t.Errorf("RequestRepositoryMock.UpdateFinalTZ got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmUpdateFinalTZ.UpdateFinalTZMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmUpdateFinalTZ.UpdateFinalTZMock.defaultExpectation.results + if mm_results == nil { + mmUpdateFinalTZ.t.Fatal("No results are set for the RequestRepositoryMock.UpdateFinalTZ") + } + return (*mm_results).err + } + if mmUpdateFinalTZ.funcUpdateFinalTZ != nil { + return mmUpdateFinalTZ.funcUpdateFinalTZ(ctx, id, finalTZ) + } + mmUpdateFinalTZ.t.Fatalf("Unexpected call to RequestRepositoryMock.UpdateFinalTZ. %v %v %v", ctx, id, finalTZ) + return +} + +// UpdateFinalTZAfterCounter returns a count of finished RequestRepositoryMock.UpdateFinalTZ invocations +func (mmUpdateFinalTZ *RequestRepositoryMock) UpdateFinalTZAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmUpdateFinalTZ.afterUpdateFinalTZCounter) +} + +// UpdateFinalTZBeforeCounter returns a count of RequestRepositoryMock.UpdateFinalTZ invocations +func (mmUpdateFinalTZ *RequestRepositoryMock) UpdateFinalTZBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmUpdateFinalTZ.beforeUpdateFinalTZCounter) +} + +// Calls returns a list of arguments used in each call to RequestRepositoryMock.UpdateFinalTZ. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmUpdateFinalTZ *mRequestRepositoryMockUpdateFinalTZ) Calls() []*RequestRepositoryMockUpdateFinalTZParams { + mmUpdateFinalTZ.mutex.RLock() + + argCopy := make([]*RequestRepositoryMockUpdateFinalTZParams, len(mmUpdateFinalTZ.callArgs)) + copy(argCopy, mmUpdateFinalTZ.callArgs) + + mmUpdateFinalTZ.mutex.RUnlock() + + return argCopy +} + +// MinimockUpdateFinalTZDone returns true if the count of the UpdateFinalTZ invocations corresponds +// the number of defined expectations +func (m *RequestRepositoryMock) MinimockUpdateFinalTZDone() bool { + if m.UpdateFinalTZMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.UpdateFinalTZMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.UpdateFinalTZMock.invocationsDone() +} + +// MinimockUpdateFinalTZInspect logs each unmet expectation +func (m *RequestRepositoryMock) MinimockUpdateFinalTZInspect() { + for _, e := range m.UpdateFinalTZMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to RequestRepositoryMock.UpdateFinalTZ at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterUpdateFinalTZCounter := mm_atomic.LoadUint64(&m.afterUpdateFinalTZCounter) + // if default expectation was set then invocations count should be greater than zero + if m.UpdateFinalTZMock.defaultExpectation != nil && afterUpdateFinalTZCounter < 1 { + if m.UpdateFinalTZMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to RequestRepositoryMock.UpdateFinalTZ at\n%s", m.UpdateFinalTZMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to RequestRepositoryMock.UpdateFinalTZ at\n%s with params: %#v", m.UpdateFinalTZMock.defaultExpectation.expectationOrigins.origin, *m.UpdateFinalTZMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcUpdateFinalTZ != nil && afterUpdateFinalTZCounter < 1 { + m.t.Errorf("Expected call to RequestRepositoryMock.UpdateFinalTZ at\n%s", m.funcUpdateFinalTZOrigin) + } + + if !m.UpdateFinalTZMock.invocationsDone() && afterUpdateFinalTZCounter > 0 { + m.t.Errorf("Expected %d calls to RequestRepositoryMock.UpdateFinalTZ at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.UpdateFinalTZMock.expectedInvocations), m.UpdateFinalTZMock.expectedInvocationsOrigin, afterUpdateFinalTZCounter) + } +} + +type mRequestRepositoryMockUpdateWithTZ struct { + optional bool + mock *RequestRepositoryMock + defaultExpectation *RequestRepositoryMockUpdateWithTZExpectation + expectations []*RequestRepositoryMockUpdateWithTZExpectation + + callArgs []*RequestRepositoryMockUpdateWithTZParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// RequestRepositoryMockUpdateWithTZExpectation specifies expectation struct of the RequestRepository.UpdateWithTZ +type RequestRepositoryMockUpdateWithTZExpectation struct { + mock *RequestRepositoryMock + params *RequestRepositoryMockUpdateWithTZParams + paramPtrs *RequestRepositoryMockUpdateWithTZParamPtrs + expectationOrigins RequestRepositoryMockUpdateWithTZExpectationOrigins + results *RequestRepositoryMockUpdateWithTZResults + returnOrigin string + Counter uint64 +} + +// RequestRepositoryMockUpdateWithTZParams contains parameters of the RequestRepository.UpdateWithTZ +type RequestRepositoryMockUpdateWithTZParams struct { + ctx context.Context + id uuid.UUID + tz string + generated bool +} + +// RequestRepositoryMockUpdateWithTZParamPtrs contains pointers to parameters of the RequestRepository.UpdateWithTZ +type RequestRepositoryMockUpdateWithTZParamPtrs struct { + ctx *context.Context + id *uuid.UUID + tz *string + generated *bool +} + +// RequestRepositoryMockUpdateWithTZResults contains results of the RequestRepository.UpdateWithTZ +type RequestRepositoryMockUpdateWithTZResults struct { + err error +} + +// RequestRepositoryMockUpdateWithTZOrigins contains origins of expectations of the RequestRepository.UpdateWithTZ +type RequestRepositoryMockUpdateWithTZExpectationOrigins struct { + origin string + originCtx string + originId string + originTz string + originGenerated string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmUpdateWithTZ *mRequestRepositoryMockUpdateWithTZ) Optional() *mRequestRepositoryMockUpdateWithTZ { + mmUpdateWithTZ.optional = true + return mmUpdateWithTZ +} + +// Expect sets up expected params for RequestRepository.UpdateWithTZ +func (mmUpdateWithTZ *mRequestRepositoryMockUpdateWithTZ) Expect(ctx context.Context, id uuid.UUID, tz string, generated bool) *mRequestRepositoryMockUpdateWithTZ { + if mmUpdateWithTZ.mock.funcUpdateWithTZ != nil { + mmUpdateWithTZ.mock.t.Fatalf("RequestRepositoryMock.UpdateWithTZ mock is already set by Set") + } + + if mmUpdateWithTZ.defaultExpectation == nil { + mmUpdateWithTZ.defaultExpectation = &RequestRepositoryMockUpdateWithTZExpectation{} + } + + if mmUpdateWithTZ.defaultExpectation.paramPtrs != nil { + mmUpdateWithTZ.mock.t.Fatalf("RequestRepositoryMock.UpdateWithTZ mock is already set by ExpectParams functions") + } + + mmUpdateWithTZ.defaultExpectation.params = &RequestRepositoryMockUpdateWithTZParams{ctx, id, tz, generated} + mmUpdateWithTZ.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmUpdateWithTZ.expectations { + if minimock.Equal(e.params, mmUpdateWithTZ.defaultExpectation.params) { + mmUpdateWithTZ.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmUpdateWithTZ.defaultExpectation.params) + } + } + + return mmUpdateWithTZ +} + +// ExpectCtxParam1 sets up expected param ctx for RequestRepository.UpdateWithTZ +func (mmUpdateWithTZ *mRequestRepositoryMockUpdateWithTZ) ExpectCtxParam1(ctx context.Context) *mRequestRepositoryMockUpdateWithTZ { + if mmUpdateWithTZ.mock.funcUpdateWithTZ != nil { + mmUpdateWithTZ.mock.t.Fatalf("RequestRepositoryMock.UpdateWithTZ mock is already set by Set") + } + + if mmUpdateWithTZ.defaultExpectation == nil { + mmUpdateWithTZ.defaultExpectation = &RequestRepositoryMockUpdateWithTZExpectation{} + } + + if mmUpdateWithTZ.defaultExpectation.params != nil { + mmUpdateWithTZ.mock.t.Fatalf("RequestRepositoryMock.UpdateWithTZ mock is already set by Expect") + } + + if mmUpdateWithTZ.defaultExpectation.paramPtrs == nil { + mmUpdateWithTZ.defaultExpectation.paramPtrs = &RequestRepositoryMockUpdateWithTZParamPtrs{} + } + mmUpdateWithTZ.defaultExpectation.paramPtrs.ctx = &ctx + mmUpdateWithTZ.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmUpdateWithTZ +} + +// ExpectIdParam2 sets up expected param id for RequestRepository.UpdateWithTZ +func (mmUpdateWithTZ *mRequestRepositoryMockUpdateWithTZ) ExpectIdParam2(id uuid.UUID) *mRequestRepositoryMockUpdateWithTZ { + if mmUpdateWithTZ.mock.funcUpdateWithTZ != nil { + mmUpdateWithTZ.mock.t.Fatalf("RequestRepositoryMock.UpdateWithTZ mock is already set by Set") + } + + if mmUpdateWithTZ.defaultExpectation == nil { + mmUpdateWithTZ.defaultExpectation = &RequestRepositoryMockUpdateWithTZExpectation{} + } + + if mmUpdateWithTZ.defaultExpectation.params != nil { + mmUpdateWithTZ.mock.t.Fatalf("RequestRepositoryMock.UpdateWithTZ mock is already set by Expect") + } + + if mmUpdateWithTZ.defaultExpectation.paramPtrs == nil { + mmUpdateWithTZ.defaultExpectation.paramPtrs = &RequestRepositoryMockUpdateWithTZParamPtrs{} + } + mmUpdateWithTZ.defaultExpectation.paramPtrs.id = &id + mmUpdateWithTZ.defaultExpectation.expectationOrigins.originId = minimock.CallerInfo(1) + + return mmUpdateWithTZ +} + +// ExpectTzParam3 sets up expected param tz for RequestRepository.UpdateWithTZ +func (mmUpdateWithTZ *mRequestRepositoryMockUpdateWithTZ) ExpectTzParam3(tz string) *mRequestRepositoryMockUpdateWithTZ { + if mmUpdateWithTZ.mock.funcUpdateWithTZ != nil { + mmUpdateWithTZ.mock.t.Fatalf("RequestRepositoryMock.UpdateWithTZ mock is already set by Set") + } + + if mmUpdateWithTZ.defaultExpectation == nil { + mmUpdateWithTZ.defaultExpectation = &RequestRepositoryMockUpdateWithTZExpectation{} + } + + if mmUpdateWithTZ.defaultExpectation.params != nil { + mmUpdateWithTZ.mock.t.Fatalf("RequestRepositoryMock.UpdateWithTZ mock is already set by Expect") + } + + if mmUpdateWithTZ.defaultExpectation.paramPtrs == nil { + mmUpdateWithTZ.defaultExpectation.paramPtrs = &RequestRepositoryMockUpdateWithTZParamPtrs{} + } + mmUpdateWithTZ.defaultExpectation.paramPtrs.tz = &tz + mmUpdateWithTZ.defaultExpectation.expectationOrigins.originTz = minimock.CallerInfo(1) + + return mmUpdateWithTZ +} + +// ExpectGeneratedParam4 sets up expected param generated for RequestRepository.UpdateWithTZ +func (mmUpdateWithTZ *mRequestRepositoryMockUpdateWithTZ) ExpectGeneratedParam4(generated bool) *mRequestRepositoryMockUpdateWithTZ { + if mmUpdateWithTZ.mock.funcUpdateWithTZ != nil { + mmUpdateWithTZ.mock.t.Fatalf("RequestRepositoryMock.UpdateWithTZ mock is already set by Set") + } + + if mmUpdateWithTZ.defaultExpectation == nil { + mmUpdateWithTZ.defaultExpectation = &RequestRepositoryMockUpdateWithTZExpectation{} + } + + if mmUpdateWithTZ.defaultExpectation.params != nil { + mmUpdateWithTZ.mock.t.Fatalf("RequestRepositoryMock.UpdateWithTZ mock is already set by Expect") + } + + if mmUpdateWithTZ.defaultExpectation.paramPtrs == nil { + mmUpdateWithTZ.defaultExpectation.paramPtrs = &RequestRepositoryMockUpdateWithTZParamPtrs{} + } + mmUpdateWithTZ.defaultExpectation.paramPtrs.generated = &generated + mmUpdateWithTZ.defaultExpectation.expectationOrigins.originGenerated = minimock.CallerInfo(1) + + return mmUpdateWithTZ +} + +// Inspect accepts an inspector function that has same arguments as the RequestRepository.UpdateWithTZ +func (mmUpdateWithTZ *mRequestRepositoryMockUpdateWithTZ) Inspect(f func(ctx context.Context, id uuid.UUID, tz string, generated bool)) *mRequestRepositoryMockUpdateWithTZ { + if mmUpdateWithTZ.mock.inspectFuncUpdateWithTZ != nil { + mmUpdateWithTZ.mock.t.Fatalf("Inspect function is already set for RequestRepositoryMock.UpdateWithTZ") + } + + mmUpdateWithTZ.mock.inspectFuncUpdateWithTZ = f + + return mmUpdateWithTZ +} + +// Return sets up results that will be returned by RequestRepository.UpdateWithTZ +func (mmUpdateWithTZ *mRequestRepositoryMockUpdateWithTZ) Return(err error) *RequestRepositoryMock { + if mmUpdateWithTZ.mock.funcUpdateWithTZ != nil { + mmUpdateWithTZ.mock.t.Fatalf("RequestRepositoryMock.UpdateWithTZ mock is already set by Set") + } + + if mmUpdateWithTZ.defaultExpectation == nil { + mmUpdateWithTZ.defaultExpectation = &RequestRepositoryMockUpdateWithTZExpectation{mock: mmUpdateWithTZ.mock} + } + mmUpdateWithTZ.defaultExpectation.results = &RequestRepositoryMockUpdateWithTZResults{err} + mmUpdateWithTZ.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmUpdateWithTZ.mock +} + +// Set uses given function f to mock the RequestRepository.UpdateWithTZ method +func (mmUpdateWithTZ *mRequestRepositoryMockUpdateWithTZ) Set(f func(ctx context.Context, id uuid.UUID, tz string, generated bool) (err error)) *RequestRepositoryMock { + if mmUpdateWithTZ.defaultExpectation != nil { + mmUpdateWithTZ.mock.t.Fatalf("Default expectation is already set for the RequestRepository.UpdateWithTZ method") + } + + if len(mmUpdateWithTZ.expectations) > 0 { + mmUpdateWithTZ.mock.t.Fatalf("Some expectations are already set for the RequestRepository.UpdateWithTZ method") + } + + mmUpdateWithTZ.mock.funcUpdateWithTZ = f + mmUpdateWithTZ.mock.funcUpdateWithTZOrigin = minimock.CallerInfo(1) + return mmUpdateWithTZ.mock +} + +// When sets expectation for the RequestRepository.UpdateWithTZ which will trigger the result defined by the following +// Then helper +func (mmUpdateWithTZ *mRequestRepositoryMockUpdateWithTZ) When(ctx context.Context, id uuid.UUID, tz string, generated bool) *RequestRepositoryMockUpdateWithTZExpectation { + if mmUpdateWithTZ.mock.funcUpdateWithTZ != nil { + mmUpdateWithTZ.mock.t.Fatalf("RequestRepositoryMock.UpdateWithTZ mock is already set by Set") + } + + expectation := &RequestRepositoryMockUpdateWithTZExpectation{ + mock: mmUpdateWithTZ.mock, + params: &RequestRepositoryMockUpdateWithTZParams{ctx, id, tz, generated}, + expectationOrigins: RequestRepositoryMockUpdateWithTZExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmUpdateWithTZ.expectations = append(mmUpdateWithTZ.expectations, expectation) + return expectation +} + +// Then sets up RequestRepository.UpdateWithTZ return parameters for the expectation previously defined by the When method +func (e *RequestRepositoryMockUpdateWithTZExpectation) Then(err error) *RequestRepositoryMock { + e.results = &RequestRepositoryMockUpdateWithTZResults{err} + return e.mock +} + +// Times sets number of times RequestRepository.UpdateWithTZ should be invoked +func (mmUpdateWithTZ *mRequestRepositoryMockUpdateWithTZ) Times(n uint64) *mRequestRepositoryMockUpdateWithTZ { + if n == 0 { + mmUpdateWithTZ.mock.t.Fatalf("Times of RequestRepositoryMock.UpdateWithTZ mock can not be zero") + } + mm_atomic.StoreUint64(&mmUpdateWithTZ.expectedInvocations, n) + mmUpdateWithTZ.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmUpdateWithTZ +} + +func (mmUpdateWithTZ *mRequestRepositoryMockUpdateWithTZ) invocationsDone() bool { + if len(mmUpdateWithTZ.expectations) == 0 && mmUpdateWithTZ.defaultExpectation == nil && mmUpdateWithTZ.mock.funcUpdateWithTZ == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmUpdateWithTZ.mock.afterUpdateWithTZCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmUpdateWithTZ.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// UpdateWithTZ implements mm_repository.RequestRepository +func (mmUpdateWithTZ *RequestRepositoryMock) UpdateWithTZ(ctx context.Context, id uuid.UUID, tz string, generated bool) (err error) { + mm_atomic.AddUint64(&mmUpdateWithTZ.beforeUpdateWithTZCounter, 1) + defer mm_atomic.AddUint64(&mmUpdateWithTZ.afterUpdateWithTZCounter, 1) + + mmUpdateWithTZ.t.Helper() + + if mmUpdateWithTZ.inspectFuncUpdateWithTZ != nil { + mmUpdateWithTZ.inspectFuncUpdateWithTZ(ctx, id, tz, generated) + } + + mm_params := RequestRepositoryMockUpdateWithTZParams{ctx, id, tz, generated} + + // Record call args + mmUpdateWithTZ.UpdateWithTZMock.mutex.Lock() + mmUpdateWithTZ.UpdateWithTZMock.callArgs = append(mmUpdateWithTZ.UpdateWithTZMock.callArgs, &mm_params) + mmUpdateWithTZ.UpdateWithTZMock.mutex.Unlock() + + for _, e := range mmUpdateWithTZ.UpdateWithTZMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.err + } + } + + if mmUpdateWithTZ.UpdateWithTZMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmUpdateWithTZ.UpdateWithTZMock.defaultExpectation.Counter, 1) + mm_want := mmUpdateWithTZ.UpdateWithTZMock.defaultExpectation.params + mm_want_ptrs := mmUpdateWithTZ.UpdateWithTZMock.defaultExpectation.paramPtrs + + mm_got := RequestRepositoryMockUpdateWithTZParams{ctx, id, tz, generated} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmUpdateWithTZ.t.Errorf("RequestRepositoryMock.UpdateWithTZ got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmUpdateWithTZ.UpdateWithTZMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) { + mmUpdateWithTZ.t.Errorf("RequestRepositoryMock.UpdateWithTZ got unexpected parameter id, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmUpdateWithTZ.UpdateWithTZMock.defaultExpectation.expectationOrigins.originId, *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id)) + } + + if mm_want_ptrs.tz != nil && !minimock.Equal(*mm_want_ptrs.tz, mm_got.tz) { + mmUpdateWithTZ.t.Errorf("RequestRepositoryMock.UpdateWithTZ got unexpected parameter tz, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmUpdateWithTZ.UpdateWithTZMock.defaultExpectation.expectationOrigins.originTz, *mm_want_ptrs.tz, mm_got.tz, minimock.Diff(*mm_want_ptrs.tz, mm_got.tz)) + } + + if mm_want_ptrs.generated != nil && !minimock.Equal(*mm_want_ptrs.generated, mm_got.generated) { + mmUpdateWithTZ.t.Errorf("RequestRepositoryMock.UpdateWithTZ got unexpected parameter generated, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmUpdateWithTZ.UpdateWithTZMock.defaultExpectation.expectationOrigins.originGenerated, *mm_want_ptrs.generated, mm_got.generated, minimock.Diff(*mm_want_ptrs.generated, mm_got.generated)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmUpdateWithTZ.t.Errorf("RequestRepositoryMock.UpdateWithTZ got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmUpdateWithTZ.UpdateWithTZMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmUpdateWithTZ.UpdateWithTZMock.defaultExpectation.results + if mm_results == nil { + mmUpdateWithTZ.t.Fatal("No results are set for the RequestRepositoryMock.UpdateWithTZ") + } + return (*mm_results).err + } + if mmUpdateWithTZ.funcUpdateWithTZ != nil { + return mmUpdateWithTZ.funcUpdateWithTZ(ctx, id, tz, generated) + } + mmUpdateWithTZ.t.Fatalf("Unexpected call to RequestRepositoryMock.UpdateWithTZ. %v %v %v %v", ctx, id, tz, generated) + return +} + +// UpdateWithTZAfterCounter returns a count of finished RequestRepositoryMock.UpdateWithTZ invocations +func (mmUpdateWithTZ *RequestRepositoryMock) UpdateWithTZAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmUpdateWithTZ.afterUpdateWithTZCounter) +} + +// UpdateWithTZBeforeCounter returns a count of RequestRepositoryMock.UpdateWithTZ invocations +func (mmUpdateWithTZ *RequestRepositoryMock) UpdateWithTZBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmUpdateWithTZ.beforeUpdateWithTZCounter) +} + +// Calls returns a list of arguments used in each call to RequestRepositoryMock.UpdateWithTZ. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmUpdateWithTZ *mRequestRepositoryMockUpdateWithTZ) Calls() []*RequestRepositoryMockUpdateWithTZParams { + mmUpdateWithTZ.mutex.RLock() + + argCopy := make([]*RequestRepositoryMockUpdateWithTZParams, len(mmUpdateWithTZ.callArgs)) + copy(argCopy, mmUpdateWithTZ.callArgs) + + mmUpdateWithTZ.mutex.RUnlock() + + return argCopy +} + +// MinimockUpdateWithTZDone returns true if the count of the UpdateWithTZ invocations corresponds +// the number of defined expectations +func (m *RequestRepositoryMock) MinimockUpdateWithTZDone() bool { + if m.UpdateWithTZMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.UpdateWithTZMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.UpdateWithTZMock.invocationsDone() +} + +// MinimockUpdateWithTZInspect logs each unmet expectation +func (m *RequestRepositoryMock) MinimockUpdateWithTZInspect() { + for _, e := range m.UpdateWithTZMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to RequestRepositoryMock.UpdateWithTZ at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterUpdateWithTZCounter := mm_atomic.LoadUint64(&m.afterUpdateWithTZCounter) + // if default expectation was set then invocations count should be greater than zero + if m.UpdateWithTZMock.defaultExpectation != nil && afterUpdateWithTZCounter < 1 { + if m.UpdateWithTZMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to RequestRepositoryMock.UpdateWithTZ at\n%s", m.UpdateWithTZMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to RequestRepositoryMock.UpdateWithTZ at\n%s with params: %#v", m.UpdateWithTZMock.defaultExpectation.expectationOrigins.origin, *m.UpdateWithTZMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcUpdateWithTZ != nil && afterUpdateWithTZCounter < 1 { + m.t.Errorf("Expected call to RequestRepositoryMock.UpdateWithTZ at\n%s", m.funcUpdateWithTZOrigin) + } + + if !m.UpdateWithTZMock.invocationsDone() && afterUpdateWithTZCounter > 0 { + m.t.Errorf("Expected %d calls to RequestRepositoryMock.UpdateWithTZ at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.UpdateWithTZMock.expectedInvocations), m.UpdateWithTZMock.expectedInvocationsOrigin, afterUpdateWithTZCounter) + } +} + +// MinimockFinish checks that all mocked methods have been called the expected number of times +func (m *RequestRepositoryMock) MinimockFinish() { + m.finishOnce.Do(func() { + if !m.minimockDone() { + m.MinimockCreateInspect() + + m.MinimockGetByIDInspect() + + m.MinimockGetByUserIDInspect() + + m.MinimockGetDetailByIDInspect() + + m.MinimockGetUserStatisticsInspect() + + m.MinimockUpdateFinalTZInspect() + + m.MinimockUpdateWithTZInspect() + } + }) +} + +// MinimockWait waits for all mocked methods to be called the expected number of times +func (m *RequestRepositoryMock) MinimockWait(timeout mm_time.Duration) { + timeoutCh := mm_time.After(timeout) + for { + if m.minimockDone() { + return + } + select { + case <-timeoutCh: + m.MinimockFinish() + return + case <-mm_time.After(10 * mm_time.Millisecond): + } + } +} + +func (m *RequestRepositoryMock) minimockDone() bool { + done := true + return done && + m.MinimockCreateDone() && + m.MinimockGetByIDDone() && + m.MinimockGetByUserIDDone() && + m.MinimockGetDetailByIDDone() && + m.MinimockGetUserStatisticsDone() && + m.MinimockUpdateFinalTZDone() && + m.MinimockUpdateWithTZDone() +} diff --git a/internal/mocks/request_service_mock.go b/internal/mocks/request_service_mock.go new file mode 100644 index 0000000..6b71671 --- /dev/null +++ b/internal/mocks/request_service_mock.go @@ -0,0 +1,1581 @@ +// Code generated by http://github.com/gojuno/minimock (v3.4.7). DO NOT EDIT. + +package mocks + +//go:generate minimock -i smart-search-back/internal/service.RequestService -o request_service_mock.go -n RequestServiceMock -p mocks + +import ( + "context" + "smart-search-back/internal/model" + "sync" + mm_atomic "sync/atomic" + mm_time "time" + + "github.com/gojuno/minimock/v3" + "github.com/google/uuid" +) + +// RequestServiceMock implements mm_service.RequestService +type RequestServiceMock struct { + t minimock.Tester + finishOnce sync.Once + + funcApproveTZ func(ctx context.Context, requestID uuid.UUID, tzText string, userID int) (spa1 []*model.Supplier, err error) + funcApproveTZOrigin string + inspectFuncApproveTZ func(ctx context.Context, requestID uuid.UUID, tzText string, userID int) + afterApproveTZCounter uint64 + beforeApproveTZCounter uint64 + ApproveTZMock mRequestServiceMockApproveTZ + + funcCreateTZ func(ctx context.Context, userID int, requestTxt string) (u1 uuid.UUID, s1 string, err error) + funcCreateTZOrigin string + inspectFuncCreateTZ func(ctx context.Context, userID int, requestTxt string) + afterCreateTZCounter uint64 + beforeCreateTZCounter uint64 + CreateTZMock mRequestServiceMockCreateTZ + + funcGetMailingList func(ctx context.Context, userID int) (rpa1 []*model.Request, err error) + funcGetMailingListOrigin string + inspectFuncGetMailingList func(ctx context.Context, userID int) + afterGetMailingListCounter uint64 + beforeGetMailingListCounter uint64 + GetMailingListMock mRequestServiceMockGetMailingList + + funcGetMailingListByID func(ctx context.Context, requestID uuid.UUID) (rp1 *model.RequestDetail, err error) + funcGetMailingListByIDOrigin string + inspectFuncGetMailingListByID func(ctx context.Context, requestID uuid.UUID) + afterGetMailingListByIDCounter uint64 + beforeGetMailingListByIDCounter uint64 + GetMailingListByIDMock mRequestServiceMockGetMailingListByID +} + +// NewRequestServiceMock returns a mock for mm_service.RequestService +func NewRequestServiceMock(t minimock.Tester) *RequestServiceMock { + m := &RequestServiceMock{t: t} + + if controller, ok := t.(minimock.MockController); ok { + controller.RegisterMocker(m) + } + + m.ApproveTZMock = mRequestServiceMockApproveTZ{mock: m} + m.ApproveTZMock.callArgs = []*RequestServiceMockApproveTZParams{} + + m.CreateTZMock = mRequestServiceMockCreateTZ{mock: m} + m.CreateTZMock.callArgs = []*RequestServiceMockCreateTZParams{} + + m.GetMailingListMock = mRequestServiceMockGetMailingList{mock: m} + m.GetMailingListMock.callArgs = []*RequestServiceMockGetMailingListParams{} + + m.GetMailingListByIDMock = mRequestServiceMockGetMailingListByID{mock: m} + m.GetMailingListByIDMock.callArgs = []*RequestServiceMockGetMailingListByIDParams{} + + t.Cleanup(m.MinimockFinish) + + return m +} + +type mRequestServiceMockApproveTZ struct { + optional bool + mock *RequestServiceMock + defaultExpectation *RequestServiceMockApproveTZExpectation + expectations []*RequestServiceMockApproveTZExpectation + + callArgs []*RequestServiceMockApproveTZParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// RequestServiceMockApproveTZExpectation specifies expectation struct of the RequestService.ApproveTZ +type RequestServiceMockApproveTZExpectation struct { + mock *RequestServiceMock + params *RequestServiceMockApproveTZParams + paramPtrs *RequestServiceMockApproveTZParamPtrs + expectationOrigins RequestServiceMockApproveTZExpectationOrigins + results *RequestServiceMockApproveTZResults + returnOrigin string + Counter uint64 +} + +// RequestServiceMockApproveTZParams contains parameters of the RequestService.ApproveTZ +type RequestServiceMockApproveTZParams struct { + ctx context.Context + requestID uuid.UUID + tzText string + userID int +} + +// RequestServiceMockApproveTZParamPtrs contains pointers to parameters of the RequestService.ApproveTZ +type RequestServiceMockApproveTZParamPtrs struct { + ctx *context.Context + requestID *uuid.UUID + tzText *string + userID *int +} + +// RequestServiceMockApproveTZResults contains results of the RequestService.ApproveTZ +type RequestServiceMockApproveTZResults struct { + spa1 []*model.Supplier + err error +} + +// RequestServiceMockApproveTZOrigins contains origins of expectations of the RequestService.ApproveTZ +type RequestServiceMockApproveTZExpectationOrigins struct { + origin string + originCtx string + originRequestID string + originTzText string + originUserID string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmApproveTZ *mRequestServiceMockApproveTZ) Optional() *mRequestServiceMockApproveTZ { + mmApproveTZ.optional = true + return mmApproveTZ +} + +// Expect sets up expected params for RequestService.ApproveTZ +func (mmApproveTZ *mRequestServiceMockApproveTZ) Expect(ctx context.Context, requestID uuid.UUID, tzText string, userID int) *mRequestServiceMockApproveTZ { + if mmApproveTZ.mock.funcApproveTZ != nil { + mmApproveTZ.mock.t.Fatalf("RequestServiceMock.ApproveTZ mock is already set by Set") + } + + if mmApproveTZ.defaultExpectation == nil { + mmApproveTZ.defaultExpectation = &RequestServiceMockApproveTZExpectation{} + } + + if mmApproveTZ.defaultExpectation.paramPtrs != nil { + mmApproveTZ.mock.t.Fatalf("RequestServiceMock.ApproveTZ mock is already set by ExpectParams functions") + } + + mmApproveTZ.defaultExpectation.params = &RequestServiceMockApproveTZParams{ctx, requestID, tzText, userID} + mmApproveTZ.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmApproveTZ.expectations { + if minimock.Equal(e.params, mmApproveTZ.defaultExpectation.params) { + mmApproveTZ.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmApproveTZ.defaultExpectation.params) + } + } + + return mmApproveTZ +} + +// ExpectCtxParam1 sets up expected param ctx for RequestService.ApproveTZ +func (mmApproveTZ *mRequestServiceMockApproveTZ) ExpectCtxParam1(ctx context.Context) *mRequestServiceMockApproveTZ { + if mmApproveTZ.mock.funcApproveTZ != nil { + mmApproveTZ.mock.t.Fatalf("RequestServiceMock.ApproveTZ mock is already set by Set") + } + + if mmApproveTZ.defaultExpectation == nil { + mmApproveTZ.defaultExpectation = &RequestServiceMockApproveTZExpectation{} + } + + if mmApproveTZ.defaultExpectation.params != nil { + mmApproveTZ.mock.t.Fatalf("RequestServiceMock.ApproveTZ mock is already set by Expect") + } + + if mmApproveTZ.defaultExpectation.paramPtrs == nil { + mmApproveTZ.defaultExpectation.paramPtrs = &RequestServiceMockApproveTZParamPtrs{} + } + mmApproveTZ.defaultExpectation.paramPtrs.ctx = &ctx + mmApproveTZ.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmApproveTZ +} + +// ExpectRequestIDParam2 sets up expected param requestID for RequestService.ApproveTZ +func (mmApproveTZ *mRequestServiceMockApproveTZ) ExpectRequestIDParam2(requestID uuid.UUID) *mRequestServiceMockApproveTZ { + if mmApproveTZ.mock.funcApproveTZ != nil { + mmApproveTZ.mock.t.Fatalf("RequestServiceMock.ApproveTZ mock is already set by Set") + } + + if mmApproveTZ.defaultExpectation == nil { + mmApproveTZ.defaultExpectation = &RequestServiceMockApproveTZExpectation{} + } + + if mmApproveTZ.defaultExpectation.params != nil { + mmApproveTZ.mock.t.Fatalf("RequestServiceMock.ApproveTZ mock is already set by Expect") + } + + if mmApproveTZ.defaultExpectation.paramPtrs == nil { + mmApproveTZ.defaultExpectation.paramPtrs = &RequestServiceMockApproveTZParamPtrs{} + } + mmApproveTZ.defaultExpectation.paramPtrs.requestID = &requestID + mmApproveTZ.defaultExpectation.expectationOrigins.originRequestID = minimock.CallerInfo(1) + + return mmApproveTZ +} + +// ExpectTzTextParam3 sets up expected param tzText for RequestService.ApproveTZ +func (mmApproveTZ *mRequestServiceMockApproveTZ) ExpectTzTextParam3(tzText string) *mRequestServiceMockApproveTZ { + if mmApproveTZ.mock.funcApproveTZ != nil { + mmApproveTZ.mock.t.Fatalf("RequestServiceMock.ApproveTZ mock is already set by Set") + } + + if mmApproveTZ.defaultExpectation == nil { + mmApproveTZ.defaultExpectation = &RequestServiceMockApproveTZExpectation{} + } + + if mmApproveTZ.defaultExpectation.params != nil { + mmApproveTZ.mock.t.Fatalf("RequestServiceMock.ApproveTZ mock is already set by Expect") + } + + if mmApproveTZ.defaultExpectation.paramPtrs == nil { + mmApproveTZ.defaultExpectation.paramPtrs = &RequestServiceMockApproveTZParamPtrs{} + } + mmApproveTZ.defaultExpectation.paramPtrs.tzText = &tzText + mmApproveTZ.defaultExpectation.expectationOrigins.originTzText = minimock.CallerInfo(1) + + return mmApproveTZ +} + +// ExpectUserIDParam4 sets up expected param userID for RequestService.ApproveTZ +func (mmApproveTZ *mRequestServiceMockApproveTZ) ExpectUserIDParam4(userID int) *mRequestServiceMockApproveTZ { + if mmApproveTZ.mock.funcApproveTZ != nil { + mmApproveTZ.mock.t.Fatalf("RequestServiceMock.ApproveTZ mock is already set by Set") + } + + if mmApproveTZ.defaultExpectation == nil { + mmApproveTZ.defaultExpectation = &RequestServiceMockApproveTZExpectation{} + } + + if mmApproveTZ.defaultExpectation.params != nil { + mmApproveTZ.mock.t.Fatalf("RequestServiceMock.ApproveTZ mock is already set by Expect") + } + + if mmApproveTZ.defaultExpectation.paramPtrs == nil { + mmApproveTZ.defaultExpectation.paramPtrs = &RequestServiceMockApproveTZParamPtrs{} + } + mmApproveTZ.defaultExpectation.paramPtrs.userID = &userID + mmApproveTZ.defaultExpectation.expectationOrigins.originUserID = minimock.CallerInfo(1) + + return mmApproveTZ +} + +// Inspect accepts an inspector function that has same arguments as the RequestService.ApproveTZ +func (mmApproveTZ *mRequestServiceMockApproveTZ) Inspect(f func(ctx context.Context, requestID uuid.UUID, tzText string, userID int)) *mRequestServiceMockApproveTZ { + if mmApproveTZ.mock.inspectFuncApproveTZ != nil { + mmApproveTZ.mock.t.Fatalf("Inspect function is already set for RequestServiceMock.ApproveTZ") + } + + mmApproveTZ.mock.inspectFuncApproveTZ = f + + return mmApproveTZ +} + +// Return sets up results that will be returned by RequestService.ApproveTZ +func (mmApproveTZ *mRequestServiceMockApproveTZ) Return(spa1 []*model.Supplier, err error) *RequestServiceMock { + if mmApproveTZ.mock.funcApproveTZ != nil { + mmApproveTZ.mock.t.Fatalf("RequestServiceMock.ApproveTZ mock is already set by Set") + } + + if mmApproveTZ.defaultExpectation == nil { + mmApproveTZ.defaultExpectation = &RequestServiceMockApproveTZExpectation{mock: mmApproveTZ.mock} + } + mmApproveTZ.defaultExpectation.results = &RequestServiceMockApproveTZResults{spa1, err} + mmApproveTZ.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmApproveTZ.mock +} + +// Set uses given function f to mock the RequestService.ApproveTZ method +func (mmApproveTZ *mRequestServiceMockApproveTZ) Set(f func(ctx context.Context, requestID uuid.UUID, tzText string, userID int) (spa1 []*model.Supplier, err error)) *RequestServiceMock { + if mmApproveTZ.defaultExpectation != nil { + mmApproveTZ.mock.t.Fatalf("Default expectation is already set for the RequestService.ApproveTZ method") + } + + if len(mmApproveTZ.expectations) > 0 { + mmApproveTZ.mock.t.Fatalf("Some expectations are already set for the RequestService.ApproveTZ method") + } + + mmApproveTZ.mock.funcApproveTZ = f + mmApproveTZ.mock.funcApproveTZOrigin = minimock.CallerInfo(1) + return mmApproveTZ.mock +} + +// When sets expectation for the RequestService.ApproveTZ which will trigger the result defined by the following +// Then helper +func (mmApproveTZ *mRequestServiceMockApproveTZ) When(ctx context.Context, requestID uuid.UUID, tzText string, userID int) *RequestServiceMockApproveTZExpectation { + if mmApproveTZ.mock.funcApproveTZ != nil { + mmApproveTZ.mock.t.Fatalf("RequestServiceMock.ApproveTZ mock is already set by Set") + } + + expectation := &RequestServiceMockApproveTZExpectation{ + mock: mmApproveTZ.mock, + params: &RequestServiceMockApproveTZParams{ctx, requestID, tzText, userID}, + expectationOrigins: RequestServiceMockApproveTZExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmApproveTZ.expectations = append(mmApproveTZ.expectations, expectation) + return expectation +} + +// Then sets up RequestService.ApproveTZ return parameters for the expectation previously defined by the When method +func (e *RequestServiceMockApproveTZExpectation) Then(spa1 []*model.Supplier, err error) *RequestServiceMock { + e.results = &RequestServiceMockApproveTZResults{spa1, err} + return e.mock +} + +// Times sets number of times RequestService.ApproveTZ should be invoked +func (mmApproveTZ *mRequestServiceMockApproveTZ) Times(n uint64) *mRequestServiceMockApproveTZ { + if n == 0 { + mmApproveTZ.mock.t.Fatalf("Times of RequestServiceMock.ApproveTZ mock can not be zero") + } + mm_atomic.StoreUint64(&mmApproveTZ.expectedInvocations, n) + mmApproveTZ.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmApproveTZ +} + +func (mmApproveTZ *mRequestServiceMockApproveTZ) invocationsDone() bool { + if len(mmApproveTZ.expectations) == 0 && mmApproveTZ.defaultExpectation == nil && mmApproveTZ.mock.funcApproveTZ == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmApproveTZ.mock.afterApproveTZCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmApproveTZ.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// ApproveTZ implements mm_service.RequestService +func (mmApproveTZ *RequestServiceMock) ApproveTZ(ctx context.Context, requestID uuid.UUID, tzText string, userID int) (spa1 []*model.Supplier, err error) { + mm_atomic.AddUint64(&mmApproveTZ.beforeApproveTZCounter, 1) + defer mm_atomic.AddUint64(&mmApproveTZ.afterApproveTZCounter, 1) + + mmApproveTZ.t.Helper() + + if mmApproveTZ.inspectFuncApproveTZ != nil { + mmApproveTZ.inspectFuncApproveTZ(ctx, requestID, tzText, userID) + } + + mm_params := RequestServiceMockApproveTZParams{ctx, requestID, tzText, userID} + + // Record call args + mmApproveTZ.ApproveTZMock.mutex.Lock() + mmApproveTZ.ApproveTZMock.callArgs = append(mmApproveTZ.ApproveTZMock.callArgs, &mm_params) + mmApproveTZ.ApproveTZMock.mutex.Unlock() + + for _, e := range mmApproveTZ.ApproveTZMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.spa1, e.results.err + } + } + + if mmApproveTZ.ApproveTZMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmApproveTZ.ApproveTZMock.defaultExpectation.Counter, 1) + mm_want := mmApproveTZ.ApproveTZMock.defaultExpectation.params + mm_want_ptrs := mmApproveTZ.ApproveTZMock.defaultExpectation.paramPtrs + + mm_got := RequestServiceMockApproveTZParams{ctx, requestID, tzText, userID} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmApproveTZ.t.Errorf("RequestServiceMock.ApproveTZ got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmApproveTZ.ApproveTZMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.requestID != nil && !minimock.Equal(*mm_want_ptrs.requestID, mm_got.requestID) { + mmApproveTZ.t.Errorf("RequestServiceMock.ApproveTZ got unexpected parameter requestID, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmApproveTZ.ApproveTZMock.defaultExpectation.expectationOrigins.originRequestID, *mm_want_ptrs.requestID, mm_got.requestID, minimock.Diff(*mm_want_ptrs.requestID, mm_got.requestID)) + } + + if mm_want_ptrs.tzText != nil && !minimock.Equal(*mm_want_ptrs.tzText, mm_got.tzText) { + mmApproveTZ.t.Errorf("RequestServiceMock.ApproveTZ got unexpected parameter tzText, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmApproveTZ.ApproveTZMock.defaultExpectation.expectationOrigins.originTzText, *mm_want_ptrs.tzText, mm_got.tzText, minimock.Diff(*mm_want_ptrs.tzText, mm_got.tzText)) + } + + if mm_want_ptrs.userID != nil && !minimock.Equal(*mm_want_ptrs.userID, mm_got.userID) { + mmApproveTZ.t.Errorf("RequestServiceMock.ApproveTZ got unexpected parameter userID, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmApproveTZ.ApproveTZMock.defaultExpectation.expectationOrigins.originUserID, *mm_want_ptrs.userID, mm_got.userID, minimock.Diff(*mm_want_ptrs.userID, mm_got.userID)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmApproveTZ.t.Errorf("RequestServiceMock.ApproveTZ got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmApproveTZ.ApproveTZMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmApproveTZ.ApproveTZMock.defaultExpectation.results + if mm_results == nil { + mmApproveTZ.t.Fatal("No results are set for the RequestServiceMock.ApproveTZ") + } + return (*mm_results).spa1, (*mm_results).err + } + if mmApproveTZ.funcApproveTZ != nil { + return mmApproveTZ.funcApproveTZ(ctx, requestID, tzText, userID) + } + mmApproveTZ.t.Fatalf("Unexpected call to RequestServiceMock.ApproveTZ. %v %v %v %v", ctx, requestID, tzText, userID) + return +} + +// ApproveTZAfterCounter returns a count of finished RequestServiceMock.ApproveTZ invocations +func (mmApproveTZ *RequestServiceMock) ApproveTZAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmApproveTZ.afterApproveTZCounter) +} + +// ApproveTZBeforeCounter returns a count of RequestServiceMock.ApproveTZ invocations +func (mmApproveTZ *RequestServiceMock) ApproveTZBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmApproveTZ.beforeApproveTZCounter) +} + +// Calls returns a list of arguments used in each call to RequestServiceMock.ApproveTZ. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmApproveTZ *mRequestServiceMockApproveTZ) Calls() []*RequestServiceMockApproveTZParams { + mmApproveTZ.mutex.RLock() + + argCopy := make([]*RequestServiceMockApproveTZParams, len(mmApproveTZ.callArgs)) + copy(argCopy, mmApproveTZ.callArgs) + + mmApproveTZ.mutex.RUnlock() + + return argCopy +} + +// MinimockApproveTZDone returns true if the count of the ApproveTZ invocations corresponds +// the number of defined expectations +func (m *RequestServiceMock) MinimockApproveTZDone() bool { + if m.ApproveTZMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.ApproveTZMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.ApproveTZMock.invocationsDone() +} + +// MinimockApproveTZInspect logs each unmet expectation +func (m *RequestServiceMock) MinimockApproveTZInspect() { + for _, e := range m.ApproveTZMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to RequestServiceMock.ApproveTZ at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterApproveTZCounter := mm_atomic.LoadUint64(&m.afterApproveTZCounter) + // if default expectation was set then invocations count should be greater than zero + if m.ApproveTZMock.defaultExpectation != nil && afterApproveTZCounter < 1 { + if m.ApproveTZMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to RequestServiceMock.ApproveTZ at\n%s", m.ApproveTZMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to RequestServiceMock.ApproveTZ at\n%s with params: %#v", m.ApproveTZMock.defaultExpectation.expectationOrigins.origin, *m.ApproveTZMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcApproveTZ != nil && afterApproveTZCounter < 1 { + m.t.Errorf("Expected call to RequestServiceMock.ApproveTZ at\n%s", m.funcApproveTZOrigin) + } + + if !m.ApproveTZMock.invocationsDone() && afterApproveTZCounter > 0 { + m.t.Errorf("Expected %d calls to RequestServiceMock.ApproveTZ at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.ApproveTZMock.expectedInvocations), m.ApproveTZMock.expectedInvocationsOrigin, afterApproveTZCounter) + } +} + +type mRequestServiceMockCreateTZ struct { + optional bool + mock *RequestServiceMock + defaultExpectation *RequestServiceMockCreateTZExpectation + expectations []*RequestServiceMockCreateTZExpectation + + callArgs []*RequestServiceMockCreateTZParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// RequestServiceMockCreateTZExpectation specifies expectation struct of the RequestService.CreateTZ +type RequestServiceMockCreateTZExpectation struct { + mock *RequestServiceMock + params *RequestServiceMockCreateTZParams + paramPtrs *RequestServiceMockCreateTZParamPtrs + expectationOrigins RequestServiceMockCreateTZExpectationOrigins + results *RequestServiceMockCreateTZResults + returnOrigin string + Counter uint64 +} + +// RequestServiceMockCreateTZParams contains parameters of the RequestService.CreateTZ +type RequestServiceMockCreateTZParams struct { + ctx context.Context + userID int + requestTxt string +} + +// RequestServiceMockCreateTZParamPtrs contains pointers to parameters of the RequestService.CreateTZ +type RequestServiceMockCreateTZParamPtrs struct { + ctx *context.Context + userID *int + requestTxt *string +} + +// RequestServiceMockCreateTZResults contains results of the RequestService.CreateTZ +type RequestServiceMockCreateTZResults struct { + u1 uuid.UUID + s1 string + err error +} + +// RequestServiceMockCreateTZOrigins contains origins of expectations of the RequestService.CreateTZ +type RequestServiceMockCreateTZExpectationOrigins struct { + origin string + originCtx string + originUserID string + originRequestTxt string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmCreateTZ *mRequestServiceMockCreateTZ) Optional() *mRequestServiceMockCreateTZ { + mmCreateTZ.optional = true + return mmCreateTZ +} + +// Expect sets up expected params for RequestService.CreateTZ +func (mmCreateTZ *mRequestServiceMockCreateTZ) Expect(ctx context.Context, userID int, requestTxt string) *mRequestServiceMockCreateTZ { + if mmCreateTZ.mock.funcCreateTZ != nil { + mmCreateTZ.mock.t.Fatalf("RequestServiceMock.CreateTZ mock is already set by Set") + } + + if mmCreateTZ.defaultExpectation == nil { + mmCreateTZ.defaultExpectation = &RequestServiceMockCreateTZExpectation{} + } + + if mmCreateTZ.defaultExpectation.paramPtrs != nil { + mmCreateTZ.mock.t.Fatalf("RequestServiceMock.CreateTZ mock is already set by ExpectParams functions") + } + + mmCreateTZ.defaultExpectation.params = &RequestServiceMockCreateTZParams{ctx, userID, requestTxt} + mmCreateTZ.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmCreateTZ.expectations { + if minimock.Equal(e.params, mmCreateTZ.defaultExpectation.params) { + mmCreateTZ.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmCreateTZ.defaultExpectation.params) + } + } + + return mmCreateTZ +} + +// ExpectCtxParam1 sets up expected param ctx for RequestService.CreateTZ +func (mmCreateTZ *mRequestServiceMockCreateTZ) ExpectCtxParam1(ctx context.Context) *mRequestServiceMockCreateTZ { + if mmCreateTZ.mock.funcCreateTZ != nil { + mmCreateTZ.mock.t.Fatalf("RequestServiceMock.CreateTZ mock is already set by Set") + } + + if mmCreateTZ.defaultExpectation == nil { + mmCreateTZ.defaultExpectation = &RequestServiceMockCreateTZExpectation{} + } + + if mmCreateTZ.defaultExpectation.params != nil { + mmCreateTZ.mock.t.Fatalf("RequestServiceMock.CreateTZ mock is already set by Expect") + } + + if mmCreateTZ.defaultExpectation.paramPtrs == nil { + mmCreateTZ.defaultExpectation.paramPtrs = &RequestServiceMockCreateTZParamPtrs{} + } + mmCreateTZ.defaultExpectation.paramPtrs.ctx = &ctx + mmCreateTZ.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmCreateTZ +} + +// ExpectUserIDParam2 sets up expected param userID for RequestService.CreateTZ +func (mmCreateTZ *mRequestServiceMockCreateTZ) ExpectUserIDParam2(userID int) *mRequestServiceMockCreateTZ { + if mmCreateTZ.mock.funcCreateTZ != nil { + mmCreateTZ.mock.t.Fatalf("RequestServiceMock.CreateTZ mock is already set by Set") + } + + if mmCreateTZ.defaultExpectation == nil { + mmCreateTZ.defaultExpectation = &RequestServiceMockCreateTZExpectation{} + } + + if mmCreateTZ.defaultExpectation.params != nil { + mmCreateTZ.mock.t.Fatalf("RequestServiceMock.CreateTZ mock is already set by Expect") + } + + if mmCreateTZ.defaultExpectation.paramPtrs == nil { + mmCreateTZ.defaultExpectation.paramPtrs = &RequestServiceMockCreateTZParamPtrs{} + } + mmCreateTZ.defaultExpectation.paramPtrs.userID = &userID + mmCreateTZ.defaultExpectation.expectationOrigins.originUserID = minimock.CallerInfo(1) + + return mmCreateTZ +} + +// ExpectRequestTxtParam3 sets up expected param requestTxt for RequestService.CreateTZ +func (mmCreateTZ *mRequestServiceMockCreateTZ) ExpectRequestTxtParam3(requestTxt string) *mRequestServiceMockCreateTZ { + if mmCreateTZ.mock.funcCreateTZ != nil { + mmCreateTZ.mock.t.Fatalf("RequestServiceMock.CreateTZ mock is already set by Set") + } + + if mmCreateTZ.defaultExpectation == nil { + mmCreateTZ.defaultExpectation = &RequestServiceMockCreateTZExpectation{} + } + + if mmCreateTZ.defaultExpectation.params != nil { + mmCreateTZ.mock.t.Fatalf("RequestServiceMock.CreateTZ mock is already set by Expect") + } + + if mmCreateTZ.defaultExpectation.paramPtrs == nil { + mmCreateTZ.defaultExpectation.paramPtrs = &RequestServiceMockCreateTZParamPtrs{} + } + mmCreateTZ.defaultExpectation.paramPtrs.requestTxt = &requestTxt + mmCreateTZ.defaultExpectation.expectationOrigins.originRequestTxt = minimock.CallerInfo(1) + + return mmCreateTZ +} + +// Inspect accepts an inspector function that has same arguments as the RequestService.CreateTZ +func (mmCreateTZ *mRequestServiceMockCreateTZ) Inspect(f func(ctx context.Context, userID int, requestTxt string)) *mRequestServiceMockCreateTZ { + if mmCreateTZ.mock.inspectFuncCreateTZ != nil { + mmCreateTZ.mock.t.Fatalf("Inspect function is already set for RequestServiceMock.CreateTZ") + } + + mmCreateTZ.mock.inspectFuncCreateTZ = f + + return mmCreateTZ +} + +// Return sets up results that will be returned by RequestService.CreateTZ +func (mmCreateTZ *mRequestServiceMockCreateTZ) Return(u1 uuid.UUID, s1 string, err error) *RequestServiceMock { + if mmCreateTZ.mock.funcCreateTZ != nil { + mmCreateTZ.mock.t.Fatalf("RequestServiceMock.CreateTZ mock is already set by Set") + } + + if mmCreateTZ.defaultExpectation == nil { + mmCreateTZ.defaultExpectation = &RequestServiceMockCreateTZExpectation{mock: mmCreateTZ.mock} + } + mmCreateTZ.defaultExpectation.results = &RequestServiceMockCreateTZResults{u1, s1, err} + mmCreateTZ.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmCreateTZ.mock +} + +// Set uses given function f to mock the RequestService.CreateTZ method +func (mmCreateTZ *mRequestServiceMockCreateTZ) Set(f func(ctx context.Context, userID int, requestTxt string) (u1 uuid.UUID, s1 string, err error)) *RequestServiceMock { + if mmCreateTZ.defaultExpectation != nil { + mmCreateTZ.mock.t.Fatalf("Default expectation is already set for the RequestService.CreateTZ method") + } + + if len(mmCreateTZ.expectations) > 0 { + mmCreateTZ.mock.t.Fatalf("Some expectations are already set for the RequestService.CreateTZ method") + } + + mmCreateTZ.mock.funcCreateTZ = f + mmCreateTZ.mock.funcCreateTZOrigin = minimock.CallerInfo(1) + return mmCreateTZ.mock +} + +// When sets expectation for the RequestService.CreateTZ which will trigger the result defined by the following +// Then helper +func (mmCreateTZ *mRequestServiceMockCreateTZ) When(ctx context.Context, userID int, requestTxt string) *RequestServiceMockCreateTZExpectation { + if mmCreateTZ.mock.funcCreateTZ != nil { + mmCreateTZ.mock.t.Fatalf("RequestServiceMock.CreateTZ mock is already set by Set") + } + + expectation := &RequestServiceMockCreateTZExpectation{ + mock: mmCreateTZ.mock, + params: &RequestServiceMockCreateTZParams{ctx, userID, requestTxt}, + expectationOrigins: RequestServiceMockCreateTZExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmCreateTZ.expectations = append(mmCreateTZ.expectations, expectation) + return expectation +} + +// Then sets up RequestService.CreateTZ return parameters for the expectation previously defined by the When method +func (e *RequestServiceMockCreateTZExpectation) Then(u1 uuid.UUID, s1 string, err error) *RequestServiceMock { + e.results = &RequestServiceMockCreateTZResults{u1, s1, err} + return e.mock +} + +// Times sets number of times RequestService.CreateTZ should be invoked +func (mmCreateTZ *mRequestServiceMockCreateTZ) Times(n uint64) *mRequestServiceMockCreateTZ { + if n == 0 { + mmCreateTZ.mock.t.Fatalf("Times of RequestServiceMock.CreateTZ mock can not be zero") + } + mm_atomic.StoreUint64(&mmCreateTZ.expectedInvocations, n) + mmCreateTZ.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmCreateTZ +} + +func (mmCreateTZ *mRequestServiceMockCreateTZ) invocationsDone() bool { + if len(mmCreateTZ.expectations) == 0 && mmCreateTZ.defaultExpectation == nil && mmCreateTZ.mock.funcCreateTZ == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmCreateTZ.mock.afterCreateTZCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmCreateTZ.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// CreateTZ implements mm_service.RequestService +func (mmCreateTZ *RequestServiceMock) CreateTZ(ctx context.Context, userID int, requestTxt string) (u1 uuid.UUID, s1 string, err error) { + mm_atomic.AddUint64(&mmCreateTZ.beforeCreateTZCounter, 1) + defer mm_atomic.AddUint64(&mmCreateTZ.afterCreateTZCounter, 1) + + mmCreateTZ.t.Helper() + + if mmCreateTZ.inspectFuncCreateTZ != nil { + mmCreateTZ.inspectFuncCreateTZ(ctx, userID, requestTxt) + } + + mm_params := RequestServiceMockCreateTZParams{ctx, userID, requestTxt} + + // Record call args + mmCreateTZ.CreateTZMock.mutex.Lock() + mmCreateTZ.CreateTZMock.callArgs = append(mmCreateTZ.CreateTZMock.callArgs, &mm_params) + mmCreateTZ.CreateTZMock.mutex.Unlock() + + for _, e := range mmCreateTZ.CreateTZMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.u1, e.results.s1, e.results.err + } + } + + if mmCreateTZ.CreateTZMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmCreateTZ.CreateTZMock.defaultExpectation.Counter, 1) + mm_want := mmCreateTZ.CreateTZMock.defaultExpectation.params + mm_want_ptrs := mmCreateTZ.CreateTZMock.defaultExpectation.paramPtrs + + mm_got := RequestServiceMockCreateTZParams{ctx, userID, requestTxt} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmCreateTZ.t.Errorf("RequestServiceMock.CreateTZ got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmCreateTZ.CreateTZMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.userID != nil && !minimock.Equal(*mm_want_ptrs.userID, mm_got.userID) { + mmCreateTZ.t.Errorf("RequestServiceMock.CreateTZ got unexpected parameter userID, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmCreateTZ.CreateTZMock.defaultExpectation.expectationOrigins.originUserID, *mm_want_ptrs.userID, mm_got.userID, minimock.Diff(*mm_want_ptrs.userID, mm_got.userID)) + } + + if mm_want_ptrs.requestTxt != nil && !minimock.Equal(*mm_want_ptrs.requestTxt, mm_got.requestTxt) { + mmCreateTZ.t.Errorf("RequestServiceMock.CreateTZ got unexpected parameter requestTxt, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmCreateTZ.CreateTZMock.defaultExpectation.expectationOrigins.originRequestTxt, *mm_want_ptrs.requestTxt, mm_got.requestTxt, minimock.Diff(*mm_want_ptrs.requestTxt, mm_got.requestTxt)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmCreateTZ.t.Errorf("RequestServiceMock.CreateTZ got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmCreateTZ.CreateTZMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmCreateTZ.CreateTZMock.defaultExpectation.results + if mm_results == nil { + mmCreateTZ.t.Fatal("No results are set for the RequestServiceMock.CreateTZ") + } + return (*mm_results).u1, (*mm_results).s1, (*mm_results).err + } + if mmCreateTZ.funcCreateTZ != nil { + return mmCreateTZ.funcCreateTZ(ctx, userID, requestTxt) + } + mmCreateTZ.t.Fatalf("Unexpected call to RequestServiceMock.CreateTZ. %v %v %v", ctx, userID, requestTxt) + return +} + +// CreateTZAfterCounter returns a count of finished RequestServiceMock.CreateTZ invocations +func (mmCreateTZ *RequestServiceMock) CreateTZAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmCreateTZ.afterCreateTZCounter) +} + +// CreateTZBeforeCounter returns a count of RequestServiceMock.CreateTZ invocations +func (mmCreateTZ *RequestServiceMock) CreateTZBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmCreateTZ.beforeCreateTZCounter) +} + +// Calls returns a list of arguments used in each call to RequestServiceMock.CreateTZ. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmCreateTZ *mRequestServiceMockCreateTZ) Calls() []*RequestServiceMockCreateTZParams { + mmCreateTZ.mutex.RLock() + + argCopy := make([]*RequestServiceMockCreateTZParams, len(mmCreateTZ.callArgs)) + copy(argCopy, mmCreateTZ.callArgs) + + mmCreateTZ.mutex.RUnlock() + + return argCopy +} + +// MinimockCreateTZDone returns true if the count of the CreateTZ invocations corresponds +// the number of defined expectations +func (m *RequestServiceMock) MinimockCreateTZDone() bool { + if m.CreateTZMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.CreateTZMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.CreateTZMock.invocationsDone() +} + +// MinimockCreateTZInspect logs each unmet expectation +func (m *RequestServiceMock) MinimockCreateTZInspect() { + for _, e := range m.CreateTZMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to RequestServiceMock.CreateTZ at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterCreateTZCounter := mm_atomic.LoadUint64(&m.afterCreateTZCounter) + // if default expectation was set then invocations count should be greater than zero + if m.CreateTZMock.defaultExpectation != nil && afterCreateTZCounter < 1 { + if m.CreateTZMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to RequestServiceMock.CreateTZ at\n%s", m.CreateTZMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to RequestServiceMock.CreateTZ at\n%s with params: %#v", m.CreateTZMock.defaultExpectation.expectationOrigins.origin, *m.CreateTZMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcCreateTZ != nil && afterCreateTZCounter < 1 { + m.t.Errorf("Expected call to RequestServiceMock.CreateTZ at\n%s", m.funcCreateTZOrigin) + } + + if !m.CreateTZMock.invocationsDone() && afterCreateTZCounter > 0 { + m.t.Errorf("Expected %d calls to RequestServiceMock.CreateTZ at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.CreateTZMock.expectedInvocations), m.CreateTZMock.expectedInvocationsOrigin, afterCreateTZCounter) + } +} + +type mRequestServiceMockGetMailingList struct { + optional bool + mock *RequestServiceMock + defaultExpectation *RequestServiceMockGetMailingListExpectation + expectations []*RequestServiceMockGetMailingListExpectation + + callArgs []*RequestServiceMockGetMailingListParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// RequestServiceMockGetMailingListExpectation specifies expectation struct of the RequestService.GetMailingList +type RequestServiceMockGetMailingListExpectation struct { + mock *RequestServiceMock + params *RequestServiceMockGetMailingListParams + paramPtrs *RequestServiceMockGetMailingListParamPtrs + expectationOrigins RequestServiceMockGetMailingListExpectationOrigins + results *RequestServiceMockGetMailingListResults + returnOrigin string + Counter uint64 +} + +// RequestServiceMockGetMailingListParams contains parameters of the RequestService.GetMailingList +type RequestServiceMockGetMailingListParams struct { + ctx context.Context + userID int +} + +// RequestServiceMockGetMailingListParamPtrs contains pointers to parameters of the RequestService.GetMailingList +type RequestServiceMockGetMailingListParamPtrs struct { + ctx *context.Context + userID *int +} + +// RequestServiceMockGetMailingListResults contains results of the RequestService.GetMailingList +type RequestServiceMockGetMailingListResults struct { + rpa1 []*model.Request + err error +} + +// RequestServiceMockGetMailingListOrigins contains origins of expectations of the RequestService.GetMailingList +type RequestServiceMockGetMailingListExpectationOrigins struct { + origin string + originCtx string + originUserID string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmGetMailingList *mRequestServiceMockGetMailingList) Optional() *mRequestServiceMockGetMailingList { + mmGetMailingList.optional = true + return mmGetMailingList +} + +// Expect sets up expected params for RequestService.GetMailingList +func (mmGetMailingList *mRequestServiceMockGetMailingList) Expect(ctx context.Context, userID int) *mRequestServiceMockGetMailingList { + if mmGetMailingList.mock.funcGetMailingList != nil { + mmGetMailingList.mock.t.Fatalf("RequestServiceMock.GetMailingList mock is already set by Set") + } + + if mmGetMailingList.defaultExpectation == nil { + mmGetMailingList.defaultExpectation = &RequestServiceMockGetMailingListExpectation{} + } + + if mmGetMailingList.defaultExpectation.paramPtrs != nil { + mmGetMailingList.mock.t.Fatalf("RequestServiceMock.GetMailingList mock is already set by ExpectParams functions") + } + + mmGetMailingList.defaultExpectation.params = &RequestServiceMockGetMailingListParams{ctx, userID} + mmGetMailingList.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmGetMailingList.expectations { + if minimock.Equal(e.params, mmGetMailingList.defaultExpectation.params) { + mmGetMailingList.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetMailingList.defaultExpectation.params) + } + } + + return mmGetMailingList +} + +// ExpectCtxParam1 sets up expected param ctx for RequestService.GetMailingList +func (mmGetMailingList *mRequestServiceMockGetMailingList) ExpectCtxParam1(ctx context.Context) *mRequestServiceMockGetMailingList { + if mmGetMailingList.mock.funcGetMailingList != nil { + mmGetMailingList.mock.t.Fatalf("RequestServiceMock.GetMailingList mock is already set by Set") + } + + if mmGetMailingList.defaultExpectation == nil { + mmGetMailingList.defaultExpectation = &RequestServiceMockGetMailingListExpectation{} + } + + if mmGetMailingList.defaultExpectation.params != nil { + mmGetMailingList.mock.t.Fatalf("RequestServiceMock.GetMailingList mock is already set by Expect") + } + + if mmGetMailingList.defaultExpectation.paramPtrs == nil { + mmGetMailingList.defaultExpectation.paramPtrs = &RequestServiceMockGetMailingListParamPtrs{} + } + mmGetMailingList.defaultExpectation.paramPtrs.ctx = &ctx + mmGetMailingList.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmGetMailingList +} + +// ExpectUserIDParam2 sets up expected param userID for RequestService.GetMailingList +func (mmGetMailingList *mRequestServiceMockGetMailingList) ExpectUserIDParam2(userID int) *mRequestServiceMockGetMailingList { + if mmGetMailingList.mock.funcGetMailingList != nil { + mmGetMailingList.mock.t.Fatalf("RequestServiceMock.GetMailingList mock is already set by Set") + } + + if mmGetMailingList.defaultExpectation == nil { + mmGetMailingList.defaultExpectation = &RequestServiceMockGetMailingListExpectation{} + } + + if mmGetMailingList.defaultExpectation.params != nil { + mmGetMailingList.mock.t.Fatalf("RequestServiceMock.GetMailingList mock is already set by Expect") + } + + if mmGetMailingList.defaultExpectation.paramPtrs == nil { + mmGetMailingList.defaultExpectation.paramPtrs = &RequestServiceMockGetMailingListParamPtrs{} + } + mmGetMailingList.defaultExpectation.paramPtrs.userID = &userID + mmGetMailingList.defaultExpectation.expectationOrigins.originUserID = minimock.CallerInfo(1) + + return mmGetMailingList +} + +// Inspect accepts an inspector function that has same arguments as the RequestService.GetMailingList +func (mmGetMailingList *mRequestServiceMockGetMailingList) Inspect(f func(ctx context.Context, userID int)) *mRequestServiceMockGetMailingList { + if mmGetMailingList.mock.inspectFuncGetMailingList != nil { + mmGetMailingList.mock.t.Fatalf("Inspect function is already set for RequestServiceMock.GetMailingList") + } + + mmGetMailingList.mock.inspectFuncGetMailingList = f + + return mmGetMailingList +} + +// Return sets up results that will be returned by RequestService.GetMailingList +func (mmGetMailingList *mRequestServiceMockGetMailingList) Return(rpa1 []*model.Request, err error) *RequestServiceMock { + if mmGetMailingList.mock.funcGetMailingList != nil { + mmGetMailingList.mock.t.Fatalf("RequestServiceMock.GetMailingList mock is already set by Set") + } + + if mmGetMailingList.defaultExpectation == nil { + mmGetMailingList.defaultExpectation = &RequestServiceMockGetMailingListExpectation{mock: mmGetMailingList.mock} + } + mmGetMailingList.defaultExpectation.results = &RequestServiceMockGetMailingListResults{rpa1, err} + mmGetMailingList.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmGetMailingList.mock +} + +// Set uses given function f to mock the RequestService.GetMailingList method +func (mmGetMailingList *mRequestServiceMockGetMailingList) Set(f func(ctx context.Context, userID int) (rpa1 []*model.Request, err error)) *RequestServiceMock { + if mmGetMailingList.defaultExpectation != nil { + mmGetMailingList.mock.t.Fatalf("Default expectation is already set for the RequestService.GetMailingList method") + } + + if len(mmGetMailingList.expectations) > 0 { + mmGetMailingList.mock.t.Fatalf("Some expectations are already set for the RequestService.GetMailingList method") + } + + mmGetMailingList.mock.funcGetMailingList = f + mmGetMailingList.mock.funcGetMailingListOrigin = minimock.CallerInfo(1) + return mmGetMailingList.mock +} + +// When sets expectation for the RequestService.GetMailingList which will trigger the result defined by the following +// Then helper +func (mmGetMailingList *mRequestServiceMockGetMailingList) When(ctx context.Context, userID int) *RequestServiceMockGetMailingListExpectation { + if mmGetMailingList.mock.funcGetMailingList != nil { + mmGetMailingList.mock.t.Fatalf("RequestServiceMock.GetMailingList mock is already set by Set") + } + + expectation := &RequestServiceMockGetMailingListExpectation{ + mock: mmGetMailingList.mock, + params: &RequestServiceMockGetMailingListParams{ctx, userID}, + expectationOrigins: RequestServiceMockGetMailingListExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmGetMailingList.expectations = append(mmGetMailingList.expectations, expectation) + return expectation +} + +// Then sets up RequestService.GetMailingList return parameters for the expectation previously defined by the When method +func (e *RequestServiceMockGetMailingListExpectation) Then(rpa1 []*model.Request, err error) *RequestServiceMock { + e.results = &RequestServiceMockGetMailingListResults{rpa1, err} + return e.mock +} + +// Times sets number of times RequestService.GetMailingList should be invoked +func (mmGetMailingList *mRequestServiceMockGetMailingList) Times(n uint64) *mRequestServiceMockGetMailingList { + if n == 0 { + mmGetMailingList.mock.t.Fatalf("Times of RequestServiceMock.GetMailingList mock can not be zero") + } + mm_atomic.StoreUint64(&mmGetMailingList.expectedInvocations, n) + mmGetMailingList.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmGetMailingList +} + +func (mmGetMailingList *mRequestServiceMockGetMailingList) invocationsDone() bool { + if len(mmGetMailingList.expectations) == 0 && mmGetMailingList.defaultExpectation == nil && mmGetMailingList.mock.funcGetMailingList == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmGetMailingList.mock.afterGetMailingListCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmGetMailingList.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// GetMailingList implements mm_service.RequestService +func (mmGetMailingList *RequestServiceMock) GetMailingList(ctx context.Context, userID int) (rpa1 []*model.Request, err error) { + mm_atomic.AddUint64(&mmGetMailingList.beforeGetMailingListCounter, 1) + defer mm_atomic.AddUint64(&mmGetMailingList.afterGetMailingListCounter, 1) + + mmGetMailingList.t.Helper() + + if mmGetMailingList.inspectFuncGetMailingList != nil { + mmGetMailingList.inspectFuncGetMailingList(ctx, userID) + } + + mm_params := RequestServiceMockGetMailingListParams{ctx, userID} + + // Record call args + mmGetMailingList.GetMailingListMock.mutex.Lock() + mmGetMailingList.GetMailingListMock.callArgs = append(mmGetMailingList.GetMailingListMock.callArgs, &mm_params) + mmGetMailingList.GetMailingListMock.mutex.Unlock() + + for _, e := range mmGetMailingList.GetMailingListMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.rpa1, e.results.err + } + } + + if mmGetMailingList.GetMailingListMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmGetMailingList.GetMailingListMock.defaultExpectation.Counter, 1) + mm_want := mmGetMailingList.GetMailingListMock.defaultExpectation.params + mm_want_ptrs := mmGetMailingList.GetMailingListMock.defaultExpectation.paramPtrs + + mm_got := RequestServiceMockGetMailingListParams{ctx, userID} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmGetMailingList.t.Errorf("RequestServiceMock.GetMailingList got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetMailingList.GetMailingListMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.userID != nil && !minimock.Equal(*mm_want_ptrs.userID, mm_got.userID) { + mmGetMailingList.t.Errorf("RequestServiceMock.GetMailingList got unexpected parameter userID, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetMailingList.GetMailingListMock.defaultExpectation.expectationOrigins.originUserID, *mm_want_ptrs.userID, mm_got.userID, minimock.Diff(*mm_want_ptrs.userID, mm_got.userID)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmGetMailingList.t.Errorf("RequestServiceMock.GetMailingList got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetMailingList.GetMailingListMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmGetMailingList.GetMailingListMock.defaultExpectation.results + if mm_results == nil { + mmGetMailingList.t.Fatal("No results are set for the RequestServiceMock.GetMailingList") + } + return (*mm_results).rpa1, (*mm_results).err + } + if mmGetMailingList.funcGetMailingList != nil { + return mmGetMailingList.funcGetMailingList(ctx, userID) + } + mmGetMailingList.t.Fatalf("Unexpected call to RequestServiceMock.GetMailingList. %v %v", ctx, userID) + return +} + +// GetMailingListAfterCounter returns a count of finished RequestServiceMock.GetMailingList invocations +func (mmGetMailingList *RequestServiceMock) GetMailingListAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetMailingList.afterGetMailingListCounter) +} + +// GetMailingListBeforeCounter returns a count of RequestServiceMock.GetMailingList invocations +func (mmGetMailingList *RequestServiceMock) GetMailingListBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetMailingList.beforeGetMailingListCounter) +} + +// Calls returns a list of arguments used in each call to RequestServiceMock.GetMailingList. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmGetMailingList *mRequestServiceMockGetMailingList) Calls() []*RequestServiceMockGetMailingListParams { + mmGetMailingList.mutex.RLock() + + argCopy := make([]*RequestServiceMockGetMailingListParams, len(mmGetMailingList.callArgs)) + copy(argCopy, mmGetMailingList.callArgs) + + mmGetMailingList.mutex.RUnlock() + + return argCopy +} + +// MinimockGetMailingListDone returns true if the count of the GetMailingList invocations corresponds +// the number of defined expectations +func (m *RequestServiceMock) MinimockGetMailingListDone() bool { + if m.GetMailingListMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.GetMailingListMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.GetMailingListMock.invocationsDone() +} + +// MinimockGetMailingListInspect logs each unmet expectation +func (m *RequestServiceMock) MinimockGetMailingListInspect() { + for _, e := range m.GetMailingListMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to RequestServiceMock.GetMailingList at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterGetMailingListCounter := mm_atomic.LoadUint64(&m.afterGetMailingListCounter) + // if default expectation was set then invocations count should be greater than zero + if m.GetMailingListMock.defaultExpectation != nil && afterGetMailingListCounter < 1 { + if m.GetMailingListMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to RequestServiceMock.GetMailingList at\n%s", m.GetMailingListMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to RequestServiceMock.GetMailingList at\n%s with params: %#v", m.GetMailingListMock.defaultExpectation.expectationOrigins.origin, *m.GetMailingListMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcGetMailingList != nil && afterGetMailingListCounter < 1 { + m.t.Errorf("Expected call to RequestServiceMock.GetMailingList at\n%s", m.funcGetMailingListOrigin) + } + + if !m.GetMailingListMock.invocationsDone() && afterGetMailingListCounter > 0 { + m.t.Errorf("Expected %d calls to RequestServiceMock.GetMailingList at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.GetMailingListMock.expectedInvocations), m.GetMailingListMock.expectedInvocationsOrigin, afterGetMailingListCounter) + } +} + +type mRequestServiceMockGetMailingListByID struct { + optional bool + mock *RequestServiceMock + defaultExpectation *RequestServiceMockGetMailingListByIDExpectation + expectations []*RequestServiceMockGetMailingListByIDExpectation + + callArgs []*RequestServiceMockGetMailingListByIDParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// RequestServiceMockGetMailingListByIDExpectation specifies expectation struct of the RequestService.GetMailingListByID +type RequestServiceMockGetMailingListByIDExpectation struct { + mock *RequestServiceMock + params *RequestServiceMockGetMailingListByIDParams + paramPtrs *RequestServiceMockGetMailingListByIDParamPtrs + expectationOrigins RequestServiceMockGetMailingListByIDExpectationOrigins + results *RequestServiceMockGetMailingListByIDResults + returnOrigin string + Counter uint64 +} + +// RequestServiceMockGetMailingListByIDParams contains parameters of the RequestService.GetMailingListByID +type RequestServiceMockGetMailingListByIDParams struct { + ctx context.Context + requestID uuid.UUID +} + +// RequestServiceMockGetMailingListByIDParamPtrs contains pointers to parameters of the RequestService.GetMailingListByID +type RequestServiceMockGetMailingListByIDParamPtrs struct { + ctx *context.Context + requestID *uuid.UUID +} + +// RequestServiceMockGetMailingListByIDResults contains results of the RequestService.GetMailingListByID +type RequestServiceMockGetMailingListByIDResults struct { + rp1 *model.RequestDetail + err error +} + +// RequestServiceMockGetMailingListByIDOrigins contains origins of expectations of the RequestService.GetMailingListByID +type RequestServiceMockGetMailingListByIDExpectationOrigins struct { + origin string + originCtx string + originRequestID string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmGetMailingListByID *mRequestServiceMockGetMailingListByID) Optional() *mRequestServiceMockGetMailingListByID { + mmGetMailingListByID.optional = true + return mmGetMailingListByID +} + +// Expect sets up expected params for RequestService.GetMailingListByID +func (mmGetMailingListByID *mRequestServiceMockGetMailingListByID) Expect(ctx context.Context, requestID uuid.UUID) *mRequestServiceMockGetMailingListByID { + if mmGetMailingListByID.mock.funcGetMailingListByID != nil { + mmGetMailingListByID.mock.t.Fatalf("RequestServiceMock.GetMailingListByID mock is already set by Set") + } + + if mmGetMailingListByID.defaultExpectation == nil { + mmGetMailingListByID.defaultExpectation = &RequestServiceMockGetMailingListByIDExpectation{} + } + + if mmGetMailingListByID.defaultExpectation.paramPtrs != nil { + mmGetMailingListByID.mock.t.Fatalf("RequestServiceMock.GetMailingListByID mock is already set by ExpectParams functions") + } + + mmGetMailingListByID.defaultExpectation.params = &RequestServiceMockGetMailingListByIDParams{ctx, requestID} + mmGetMailingListByID.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmGetMailingListByID.expectations { + if minimock.Equal(e.params, mmGetMailingListByID.defaultExpectation.params) { + mmGetMailingListByID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetMailingListByID.defaultExpectation.params) + } + } + + return mmGetMailingListByID +} + +// ExpectCtxParam1 sets up expected param ctx for RequestService.GetMailingListByID +func (mmGetMailingListByID *mRequestServiceMockGetMailingListByID) ExpectCtxParam1(ctx context.Context) *mRequestServiceMockGetMailingListByID { + if mmGetMailingListByID.mock.funcGetMailingListByID != nil { + mmGetMailingListByID.mock.t.Fatalf("RequestServiceMock.GetMailingListByID mock is already set by Set") + } + + if mmGetMailingListByID.defaultExpectation == nil { + mmGetMailingListByID.defaultExpectation = &RequestServiceMockGetMailingListByIDExpectation{} + } + + if mmGetMailingListByID.defaultExpectation.params != nil { + mmGetMailingListByID.mock.t.Fatalf("RequestServiceMock.GetMailingListByID mock is already set by Expect") + } + + if mmGetMailingListByID.defaultExpectation.paramPtrs == nil { + mmGetMailingListByID.defaultExpectation.paramPtrs = &RequestServiceMockGetMailingListByIDParamPtrs{} + } + mmGetMailingListByID.defaultExpectation.paramPtrs.ctx = &ctx + mmGetMailingListByID.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmGetMailingListByID +} + +// ExpectRequestIDParam2 sets up expected param requestID for RequestService.GetMailingListByID +func (mmGetMailingListByID *mRequestServiceMockGetMailingListByID) ExpectRequestIDParam2(requestID uuid.UUID) *mRequestServiceMockGetMailingListByID { + if mmGetMailingListByID.mock.funcGetMailingListByID != nil { + mmGetMailingListByID.mock.t.Fatalf("RequestServiceMock.GetMailingListByID mock is already set by Set") + } + + if mmGetMailingListByID.defaultExpectation == nil { + mmGetMailingListByID.defaultExpectation = &RequestServiceMockGetMailingListByIDExpectation{} + } + + if mmGetMailingListByID.defaultExpectation.params != nil { + mmGetMailingListByID.mock.t.Fatalf("RequestServiceMock.GetMailingListByID mock is already set by Expect") + } + + if mmGetMailingListByID.defaultExpectation.paramPtrs == nil { + mmGetMailingListByID.defaultExpectation.paramPtrs = &RequestServiceMockGetMailingListByIDParamPtrs{} + } + mmGetMailingListByID.defaultExpectation.paramPtrs.requestID = &requestID + mmGetMailingListByID.defaultExpectation.expectationOrigins.originRequestID = minimock.CallerInfo(1) + + return mmGetMailingListByID +} + +// Inspect accepts an inspector function that has same arguments as the RequestService.GetMailingListByID +func (mmGetMailingListByID *mRequestServiceMockGetMailingListByID) Inspect(f func(ctx context.Context, requestID uuid.UUID)) *mRequestServiceMockGetMailingListByID { + if mmGetMailingListByID.mock.inspectFuncGetMailingListByID != nil { + mmGetMailingListByID.mock.t.Fatalf("Inspect function is already set for RequestServiceMock.GetMailingListByID") + } + + mmGetMailingListByID.mock.inspectFuncGetMailingListByID = f + + return mmGetMailingListByID +} + +// Return sets up results that will be returned by RequestService.GetMailingListByID +func (mmGetMailingListByID *mRequestServiceMockGetMailingListByID) Return(rp1 *model.RequestDetail, err error) *RequestServiceMock { + if mmGetMailingListByID.mock.funcGetMailingListByID != nil { + mmGetMailingListByID.mock.t.Fatalf("RequestServiceMock.GetMailingListByID mock is already set by Set") + } + + if mmGetMailingListByID.defaultExpectation == nil { + mmGetMailingListByID.defaultExpectation = &RequestServiceMockGetMailingListByIDExpectation{mock: mmGetMailingListByID.mock} + } + mmGetMailingListByID.defaultExpectation.results = &RequestServiceMockGetMailingListByIDResults{rp1, err} + mmGetMailingListByID.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmGetMailingListByID.mock +} + +// Set uses given function f to mock the RequestService.GetMailingListByID method +func (mmGetMailingListByID *mRequestServiceMockGetMailingListByID) Set(f func(ctx context.Context, requestID uuid.UUID) (rp1 *model.RequestDetail, err error)) *RequestServiceMock { + if mmGetMailingListByID.defaultExpectation != nil { + mmGetMailingListByID.mock.t.Fatalf("Default expectation is already set for the RequestService.GetMailingListByID method") + } + + if len(mmGetMailingListByID.expectations) > 0 { + mmGetMailingListByID.mock.t.Fatalf("Some expectations are already set for the RequestService.GetMailingListByID method") + } + + mmGetMailingListByID.mock.funcGetMailingListByID = f + mmGetMailingListByID.mock.funcGetMailingListByIDOrigin = minimock.CallerInfo(1) + return mmGetMailingListByID.mock +} + +// When sets expectation for the RequestService.GetMailingListByID which will trigger the result defined by the following +// Then helper +func (mmGetMailingListByID *mRequestServiceMockGetMailingListByID) When(ctx context.Context, requestID uuid.UUID) *RequestServiceMockGetMailingListByIDExpectation { + if mmGetMailingListByID.mock.funcGetMailingListByID != nil { + mmGetMailingListByID.mock.t.Fatalf("RequestServiceMock.GetMailingListByID mock is already set by Set") + } + + expectation := &RequestServiceMockGetMailingListByIDExpectation{ + mock: mmGetMailingListByID.mock, + params: &RequestServiceMockGetMailingListByIDParams{ctx, requestID}, + expectationOrigins: RequestServiceMockGetMailingListByIDExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmGetMailingListByID.expectations = append(mmGetMailingListByID.expectations, expectation) + return expectation +} + +// Then sets up RequestService.GetMailingListByID return parameters for the expectation previously defined by the When method +func (e *RequestServiceMockGetMailingListByIDExpectation) Then(rp1 *model.RequestDetail, err error) *RequestServiceMock { + e.results = &RequestServiceMockGetMailingListByIDResults{rp1, err} + return e.mock +} + +// Times sets number of times RequestService.GetMailingListByID should be invoked +func (mmGetMailingListByID *mRequestServiceMockGetMailingListByID) Times(n uint64) *mRequestServiceMockGetMailingListByID { + if n == 0 { + mmGetMailingListByID.mock.t.Fatalf("Times of RequestServiceMock.GetMailingListByID mock can not be zero") + } + mm_atomic.StoreUint64(&mmGetMailingListByID.expectedInvocations, n) + mmGetMailingListByID.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmGetMailingListByID +} + +func (mmGetMailingListByID *mRequestServiceMockGetMailingListByID) invocationsDone() bool { + if len(mmGetMailingListByID.expectations) == 0 && mmGetMailingListByID.defaultExpectation == nil && mmGetMailingListByID.mock.funcGetMailingListByID == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmGetMailingListByID.mock.afterGetMailingListByIDCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmGetMailingListByID.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// GetMailingListByID implements mm_service.RequestService +func (mmGetMailingListByID *RequestServiceMock) GetMailingListByID(ctx context.Context, requestID uuid.UUID) (rp1 *model.RequestDetail, err error) { + mm_atomic.AddUint64(&mmGetMailingListByID.beforeGetMailingListByIDCounter, 1) + defer mm_atomic.AddUint64(&mmGetMailingListByID.afterGetMailingListByIDCounter, 1) + + mmGetMailingListByID.t.Helper() + + if mmGetMailingListByID.inspectFuncGetMailingListByID != nil { + mmGetMailingListByID.inspectFuncGetMailingListByID(ctx, requestID) + } + + mm_params := RequestServiceMockGetMailingListByIDParams{ctx, requestID} + + // Record call args + mmGetMailingListByID.GetMailingListByIDMock.mutex.Lock() + mmGetMailingListByID.GetMailingListByIDMock.callArgs = append(mmGetMailingListByID.GetMailingListByIDMock.callArgs, &mm_params) + mmGetMailingListByID.GetMailingListByIDMock.mutex.Unlock() + + for _, e := range mmGetMailingListByID.GetMailingListByIDMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.rp1, e.results.err + } + } + + if mmGetMailingListByID.GetMailingListByIDMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmGetMailingListByID.GetMailingListByIDMock.defaultExpectation.Counter, 1) + mm_want := mmGetMailingListByID.GetMailingListByIDMock.defaultExpectation.params + mm_want_ptrs := mmGetMailingListByID.GetMailingListByIDMock.defaultExpectation.paramPtrs + + mm_got := RequestServiceMockGetMailingListByIDParams{ctx, requestID} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmGetMailingListByID.t.Errorf("RequestServiceMock.GetMailingListByID got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetMailingListByID.GetMailingListByIDMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.requestID != nil && !minimock.Equal(*mm_want_ptrs.requestID, mm_got.requestID) { + mmGetMailingListByID.t.Errorf("RequestServiceMock.GetMailingListByID got unexpected parameter requestID, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetMailingListByID.GetMailingListByIDMock.defaultExpectation.expectationOrigins.originRequestID, *mm_want_ptrs.requestID, mm_got.requestID, minimock.Diff(*mm_want_ptrs.requestID, mm_got.requestID)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmGetMailingListByID.t.Errorf("RequestServiceMock.GetMailingListByID got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetMailingListByID.GetMailingListByIDMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmGetMailingListByID.GetMailingListByIDMock.defaultExpectation.results + if mm_results == nil { + mmGetMailingListByID.t.Fatal("No results are set for the RequestServiceMock.GetMailingListByID") + } + return (*mm_results).rp1, (*mm_results).err + } + if mmGetMailingListByID.funcGetMailingListByID != nil { + return mmGetMailingListByID.funcGetMailingListByID(ctx, requestID) + } + mmGetMailingListByID.t.Fatalf("Unexpected call to RequestServiceMock.GetMailingListByID. %v %v", ctx, requestID) + return +} + +// GetMailingListByIDAfterCounter returns a count of finished RequestServiceMock.GetMailingListByID invocations +func (mmGetMailingListByID *RequestServiceMock) GetMailingListByIDAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetMailingListByID.afterGetMailingListByIDCounter) +} + +// GetMailingListByIDBeforeCounter returns a count of RequestServiceMock.GetMailingListByID invocations +func (mmGetMailingListByID *RequestServiceMock) GetMailingListByIDBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetMailingListByID.beforeGetMailingListByIDCounter) +} + +// Calls returns a list of arguments used in each call to RequestServiceMock.GetMailingListByID. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmGetMailingListByID *mRequestServiceMockGetMailingListByID) Calls() []*RequestServiceMockGetMailingListByIDParams { + mmGetMailingListByID.mutex.RLock() + + argCopy := make([]*RequestServiceMockGetMailingListByIDParams, len(mmGetMailingListByID.callArgs)) + copy(argCopy, mmGetMailingListByID.callArgs) + + mmGetMailingListByID.mutex.RUnlock() + + return argCopy +} + +// MinimockGetMailingListByIDDone returns true if the count of the GetMailingListByID invocations corresponds +// the number of defined expectations +func (m *RequestServiceMock) MinimockGetMailingListByIDDone() bool { + if m.GetMailingListByIDMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.GetMailingListByIDMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.GetMailingListByIDMock.invocationsDone() +} + +// MinimockGetMailingListByIDInspect logs each unmet expectation +func (m *RequestServiceMock) MinimockGetMailingListByIDInspect() { + for _, e := range m.GetMailingListByIDMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to RequestServiceMock.GetMailingListByID at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterGetMailingListByIDCounter := mm_atomic.LoadUint64(&m.afterGetMailingListByIDCounter) + // if default expectation was set then invocations count should be greater than zero + if m.GetMailingListByIDMock.defaultExpectation != nil && afterGetMailingListByIDCounter < 1 { + if m.GetMailingListByIDMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to RequestServiceMock.GetMailingListByID at\n%s", m.GetMailingListByIDMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to RequestServiceMock.GetMailingListByID at\n%s with params: %#v", m.GetMailingListByIDMock.defaultExpectation.expectationOrigins.origin, *m.GetMailingListByIDMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcGetMailingListByID != nil && afterGetMailingListByIDCounter < 1 { + m.t.Errorf("Expected call to RequestServiceMock.GetMailingListByID at\n%s", m.funcGetMailingListByIDOrigin) + } + + if !m.GetMailingListByIDMock.invocationsDone() && afterGetMailingListByIDCounter > 0 { + m.t.Errorf("Expected %d calls to RequestServiceMock.GetMailingListByID at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.GetMailingListByIDMock.expectedInvocations), m.GetMailingListByIDMock.expectedInvocationsOrigin, afterGetMailingListByIDCounter) + } +} + +// MinimockFinish checks that all mocked methods have been called the expected number of times +func (m *RequestServiceMock) MinimockFinish() { + m.finishOnce.Do(func() { + if !m.minimockDone() { + m.MinimockApproveTZInspect() + + m.MinimockCreateTZInspect() + + m.MinimockGetMailingListInspect() + + m.MinimockGetMailingListByIDInspect() + } + }) +} + +// MinimockWait waits for all mocked methods to be called the expected number of times +func (m *RequestServiceMock) MinimockWait(timeout mm_time.Duration) { + timeoutCh := mm_time.After(timeout) + for { + if m.minimockDone() { + return + } + select { + case <-timeoutCh: + m.MinimockFinish() + return + case <-mm_time.After(10 * mm_time.Millisecond): + } + } +} + +func (m *RequestServiceMock) minimockDone() bool { + done := true + return done && + m.MinimockApproveTZDone() && + m.MinimockCreateTZDone() && + m.MinimockGetMailingListDone() && + m.MinimockGetMailingListByIDDone() +} diff --git a/internal/mocks/session_repository_mock.go b/internal/mocks/session_repository_mock.go new file mode 100644 index 0000000..21251b8 --- /dev/null +++ b/internal/mocks/session_repository_mock.go @@ -0,0 +1,1839 @@ +// Code generated by http://github.com/gojuno/minimock (v3.4.7). DO NOT EDIT. + +package mocks + +//go:generate minimock -i smart-search-back/internal/repository.SessionRepository -o session_repository_mock.go -n SessionRepositoryMock -p mocks + +import ( + "context" + "smart-search-back/internal/model" + "sync" + mm_atomic "sync/atomic" + mm_time "time" + + "github.com/gojuno/minimock/v3" +) + +// SessionRepositoryMock implements mm_repository.SessionRepository +type SessionRepositoryMock struct { + t minimock.Tester + finishOnce sync.Once + + funcCreate func(ctx context.Context, session *model.Session) (err error) + funcCreateOrigin string + inspectFuncCreate func(ctx context.Context, session *model.Session) + afterCreateCounter uint64 + beforeCreateCounter uint64 + CreateMock mSessionRepositoryMockCreate + + funcDeleteExpired func(ctx context.Context) (i1 int, err error) + funcDeleteExpiredOrigin string + inspectFuncDeleteExpired func(ctx context.Context) + afterDeleteExpiredCounter uint64 + beforeDeleteExpiredCounter uint64 + DeleteExpiredMock mSessionRepositoryMockDeleteExpired + + funcFindByRefreshToken func(ctx context.Context, token string) (sp1 *model.Session, err error) + funcFindByRefreshTokenOrigin string + inspectFuncFindByRefreshToken func(ctx context.Context, token string) + afterFindByRefreshTokenCounter uint64 + beforeFindByRefreshTokenCounter uint64 + FindByRefreshTokenMock mSessionRepositoryMockFindByRefreshToken + + funcRevoke func(ctx context.Context, refreshToken string) (err error) + funcRevokeOrigin string + inspectFuncRevoke func(ctx context.Context, refreshToken string) + afterRevokeCounter uint64 + beforeRevokeCounter uint64 + RevokeMock mSessionRepositoryMockRevoke + + funcUpdateAccessToken func(ctx context.Context, refreshToken string, newAccessToken string) (err error) + funcUpdateAccessTokenOrigin string + inspectFuncUpdateAccessToken func(ctx context.Context, refreshToken string, newAccessToken string) + afterUpdateAccessTokenCounter uint64 + beforeUpdateAccessTokenCounter uint64 + UpdateAccessTokenMock mSessionRepositoryMockUpdateAccessToken +} + +// NewSessionRepositoryMock returns a mock for mm_repository.SessionRepository +func NewSessionRepositoryMock(t minimock.Tester) *SessionRepositoryMock { + m := &SessionRepositoryMock{t: t} + + if controller, ok := t.(minimock.MockController); ok { + controller.RegisterMocker(m) + } + + m.CreateMock = mSessionRepositoryMockCreate{mock: m} + m.CreateMock.callArgs = []*SessionRepositoryMockCreateParams{} + + m.DeleteExpiredMock = mSessionRepositoryMockDeleteExpired{mock: m} + m.DeleteExpiredMock.callArgs = []*SessionRepositoryMockDeleteExpiredParams{} + + m.FindByRefreshTokenMock = mSessionRepositoryMockFindByRefreshToken{mock: m} + m.FindByRefreshTokenMock.callArgs = []*SessionRepositoryMockFindByRefreshTokenParams{} + + m.RevokeMock = mSessionRepositoryMockRevoke{mock: m} + m.RevokeMock.callArgs = []*SessionRepositoryMockRevokeParams{} + + m.UpdateAccessTokenMock = mSessionRepositoryMockUpdateAccessToken{mock: m} + m.UpdateAccessTokenMock.callArgs = []*SessionRepositoryMockUpdateAccessTokenParams{} + + t.Cleanup(m.MinimockFinish) + + return m +} + +type mSessionRepositoryMockCreate struct { + optional bool + mock *SessionRepositoryMock + defaultExpectation *SessionRepositoryMockCreateExpectation + expectations []*SessionRepositoryMockCreateExpectation + + callArgs []*SessionRepositoryMockCreateParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// SessionRepositoryMockCreateExpectation specifies expectation struct of the SessionRepository.Create +type SessionRepositoryMockCreateExpectation struct { + mock *SessionRepositoryMock + params *SessionRepositoryMockCreateParams + paramPtrs *SessionRepositoryMockCreateParamPtrs + expectationOrigins SessionRepositoryMockCreateExpectationOrigins + results *SessionRepositoryMockCreateResults + returnOrigin string + Counter uint64 +} + +// SessionRepositoryMockCreateParams contains parameters of the SessionRepository.Create +type SessionRepositoryMockCreateParams struct { + ctx context.Context + session *model.Session +} + +// SessionRepositoryMockCreateParamPtrs contains pointers to parameters of the SessionRepository.Create +type SessionRepositoryMockCreateParamPtrs struct { + ctx *context.Context + session **model.Session +} + +// SessionRepositoryMockCreateResults contains results of the SessionRepository.Create +type SessionRepositoryMockCreateResults struct { + err error +} + +// SessionRepositoryMockCreateOrigins contains origins of expectations of the SessionRepository.Create +type SessionRepositoryMockCreateExpectationOrigins struct { + origin string + originCtx string + originSession string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmCreate *mSessionRepositoryMockCreate) Optional() *mSessionRepositoryMockCreate { + mmCreate.optional = true + return mmCreate +} + +// Expect sets up expected params for SessionRepository.Create +func (mmCreate *mSessionRepositoryMockCreate) Expect(ctx context.Context, session *model.Session) *mSessionRepositoryMockCreate { + if mmCreate.mock.funcCreate != nil { + mmCreate.mock.t.Fatalf("SessionRepositoryMock.Create mock is already set by Set") + } + + if mmCreate.defaultExpectation == nil { + mmCreate.defaultExpectation = &SessionRepositoryMockCreateExpectation{} + } + + if mmCreate.defaultExpectation.paramPtrs != nil { + mmCreate.mock.t.Fatalf("SessionRepositoryMock.Create mock is already set by ExpectParams functions") + } + + mmCreate.defaultExpectation.params = &SessionRepositoryMockCreateParams{ctx, session} + mmCreate.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmCreate.expectations { + if minimock.Equal(e.params, mmCreate.defaultExpectation.params) { + mmCreate.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmCreate.defaultExpectation.params) + } + } + + return mmCreate +} + +// ExpectCtxParam1 sets up expected param ctx for SessionRepository.Create +func (mmCreate *mSessionRepositoryMockCreate) ExpectCtxParam1(ctx context.Context) *mSessionRepositoryMockCreate { + if mmCreate.mock.funcCreate != nil { + mmCreate.mock.t.Fatalf("SessionRepositoryMock.Create mock is already set by Set") + } + + if mmCreate.defaultExpectation == nil { + mmCreate.defaultExpectation = &SessionRepositoryMockCreateExpectation{} + } + + if mmCreate.defaultExpectation.params != nil { + mmCreate.mock.t.Fatalf("SessionRepositoryMock.Create mock is already set by Expect") + } + + if mmCreate.defaultExpectation.paramPtrs == nil { + mmCreate.defaultExpectation.paramPtrs = &SessionRepositoryMockCreateParamPtrs{} + } + mmCreate.defaultExpectation.paramPtrs.ctx = &ctx + mmCreate.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmCreate +} + +// ExpectSessionParam2 sets up expected param session for SessionRepository.Create +func (mmCreate *mSessionRepositoryMockCreate) ExpectSessionParam2(session *model.Session) *mSessionRepositoryMockCreate { + if mmCreate.mock.funcCreate != nil { + mmCreate.mock.t.Fatalf("SessionRepositoryMock.Create mock is already set by Set") + } + + if mmCreate.defaultExpectation == nil { + mmCreate.defaultExpectation = &SessionRepositoryMockCreateExpectation{} + } + + if mmCreate.defaultExpectation.params != nil { + mmCreate.mock.t.Fatalf("SessionRepositoryMock.Create mock is already set by Expect") + } + + if mmCreate.defaultExpectation.paramPtrs == nil { + mmCreate.defaultExpectation.paramPtrs = &SessionRepositoryMockCreateParamPtrs{} + } + mmCreate.defaultExpectation.paramPtrs.session = &session + mmCreate.defaultExpectation.expectationOrigins.originSession = minimock.CallerInfo(1) + + return mmCreate +} + +// Inspect accepts an inspector function that has same arguments as the SessionRepository.Create +func (mmCreate *mSessionRepositoryMockCreate) Inspect(f func(ctx context.Context, session *model.Session)) *mSessionRepositoryMockCreate { + if mmCreate.mock.inspectFuncCreate != nil { + mmCreate.mock.t.Fatalf("Inspect function is already set for SessionRepositoryMock.Create") + } + + mmCreate.mock.inspectFuncCreate = f + + return mmCreate +} + +// Return sets up results that will be returned by SessionRepository.Create +func (mmCreate *mSessionRepositoryMockCreate) Return(err error) *SessionRepositoryMock { + if mmCreate.mock.funcCreate != nil { + mmCreate.mock.t.Fatalf("SessionRepositoryMock.Create mock is already set by Set") + } + + if mmCreate.defaultExpectation == nil { + mmCreate.defaultExpectation = &SessionRepositoryMockCreateExpectation{mock: mmCreate.mock} + } + mmCreate.defaultExpectation.results = &SessionRepositoryMockCreateResults{err} + mmCreate.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmCreate.mock +} + +// Set uses given function f to mock the SessionRepository.Create method +func (mmCreate *mSessionRepositoryMockCreate) Set(f func(ctx context.Context, session *model.Session) (err error)) *SessionRepositoryMock { + if mmCreate.defaultExpectation != nil { + mmCreate.mock.t.Fatalf("Default expectation is already set for the SessionRepository.Create method") + } + + if len(mmCreate.expectations) > 0 { + mmCreate.mock.t.Fatalf("Some expectations are already set for the SessionRepository.Create method") + } + + mmCreate.mock.funcCreate = f + mmCreate.mock.funcCreateOrigin = minimock.CallerInfo(1) + return mmCreate.mock +} + +// When sets expectation for the SessionRepository.Create which will trigger the result defined by the following +// Then helper +func (mmCreate *mSessionRepositoryMockCreate) When(ctx context.Context, session *model.Session) *SessionRepositoryMockCreateExpectation { + if mmCreate.mock.funcCreate != nil { + mmCreate.mock.t.Fatalf("SessionRepositoryMock.Create mock is already set by Set") + } + + expectation := &SessionRepositoryMockCreateExpectation{ + mock: mmCreate.mock, + params: &SessionRepositoryMockCreateParams{ctx, session}, + expectationOrigins: SessionRepositoryMockCreateExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmCreate.expectations = append(mmCreate.expectations, expectation) + return expectation +} + +// Then sets up SessionRepository.Create return parameters for the expectation previously defined by the When method +func (e *SessionRepositoryMockCreateExpectation) Then(err error) *SessionRepositoryMock { + e.results = &SessionRepositoryMockCreateResults{err} + return e.mock +} + +// Times sets number of times SessionRepository.Create should be invoked +func (mmCreate *mSessionRepositoryMockCreate) Times(n uint64) *mSessionRepositoryMockCreate { + if n == 0 { + mmCreate.mock.t.Fatalf("Times of SessionRepositoryMock.Create mock can not be zero") + } + mm_atomic.StoreUint64(&mmCreate.expectedInvocations, n) + mmCreate.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmCreate +} + +func (mmCreate *mSessionRepositoryMockCreate) invocationsDone() bool { + if len(mmCreate.expectations) == 0 && mmCreate.defaultExpectation == nil && mmCreate.mock.funcCreate == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmCreate.mock.afterCreateCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmCreate.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// Create implements mm_repository.SessionRepository +func (mmCreate *SessionRepositoryMock) Create(ctx context.Context, session *model.Session) (err error) { + mm_atomic.AddUint64(&mmCreate.beforeCreateCounter, 1) + defer mm_atomic.AddUint64(&mmCreate.afterCreateCounter, 1) + + mmCreate.t.Helper() + + if mmCreate.inspectFuncCreate != nil { + mmCreate.inspectFuncCreate(ctx, session) + } + + mm_params := SessionRepositoryMockCreateParams{ctx, session} + + // Record call args + mmCreate.CreateMock.mutex.Lock() + mmCreate.CreateMock.callArgs = append(mmCreate.CreateMock.callArgs, &mm_params) + mmCreate.CreateMock.mutex.Unlock() + + for _, e := range mmCreate.CreateMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.err + } + } + + if mmCreate.CreateMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmCreate.CreateMock.defaultExpectation.Counter, 1) + mm_want := mmCreate.CreateMock.defaultExpectation.params + mm_want_ptrs := mmCreate.CreateMock.defaultExpectation.paramPtrs + + mm_got := SessionRepositoryMockCreateParams{ctx, session} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmCreate.t.Errorf("SessionRepositoryMock.Create got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmCreate.CreateMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.session != nil && !minimock.Equal(*mm_want_ptrs.session, mm_got.session) { + mmCreate.t.Errorf("SessionRepositoryMock.Create got unexpected parameter session, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmCreate.CreateMock.defaultExpectation.expectationOrigins.originSession, *mm_want_ptrs.session, mm_got.session, minimock.Diff(*mm_want_ptrs.session, mm_got.session)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmCreate.t.Errorf("SessionRepositoryMock.Create got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmCreate.CreateMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmCreate.CreateMock.defaultExpectation.results + if mm_results == nil { + mmCreate.t.Fatal("No results are set for the SessionRepositoryMock.Create") + } + return (*mm_results).err + } + if mmCreate.funcCreate != nil { + return mmCreate.funcCreate(ctx, session) + } + mmCreate.t.Fatalf("Unexpected call to SessionRepositoryMock.Create. %v %v", ctx, session) + return +} + +// CreateAfterCounter returns a count of finished SessionRepositoryMock.Create invocations +func (mmCreate *SessionRepositoryMock) CreateAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmCreate.afterCreateCounter) +} + +// CreateBeforeCounter returns a count of SessionRepositoryMock.Create invocations +func (mmCreate *SessionRepositoryMock) CreateBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmCreate.beforeCreateCounter) +} + +// Calls returns a list of arguments used in each call to SessionRepositoryMock.Create. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmCreate *mSessionRepositoryMockCreate) Calls() []*SessionRepositoryMockCreateParams { + mmCreate.mutex.RLock() + + argCopy := make([]*SessionRepositoryMockCreateParams, len(mmCreate.callArgs)) + copy(argCopy, mmCreate.callArgs) + + mmCreate.mutex.RUnlock() + + return argCopy +} + +// MinimockCreateDone returns true if the count of the Create invocations corresponds +// the number of defined expectations +func (m *SessionRepositoryMock) MinimockCreateDone() bool { + if m.CreateMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.CreateMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.CreateMock.invocationsDone() +} + +// MinimockCreateInspect logs each unmet expectation +func (m *SessionRepositoryMock) MinimockCreateInspect() { + for _, e := range m.CreateMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to SessionRepositoryMock.Create at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterCreateCounter := mm_atomic.LoadUint64(&m.afterCreateCounter) + // if default expectation was set then invocations count should be greater than zero + if m.CreateMock.defaultExpectation != nil && afterCreateCounter < 1 { + if m.CreateMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to SessionRepositoryMock.Create at\n%s", m.CreateMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to SessionRepositoryMock.Create at\n%s with params: %#v", m.CreateMock.defaultExpectation.expectationOrigins.origin, *m.CreateMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcCreate != nil && afterCreateCounter < 1 { + m.t.Errorf("Expected call to SessionRepositoryMock.Create at\n%s", m.funcCreateOrigin) + } + + if !m.CreateMock.invocationsDone() && afterCreateCounter > 0 { + m.t.Errorf("Expected %d calls to SessionRepositoryMock.Create at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.CreateMock.expectedInvocations), m.CreateMock.expectedInvocationsOrigin, afterCreateCounter) + } +} + +type mSessionRepositoryMockDeleteExpired struct { + optional bool + mock *SessionRepositoryMock + defaultExpectation *SessionRepositoryMockDeleteExpiredExpectation + expectations []*SessionRepositoryMockDeleteExpiredExpectation + + callArgs []*SessionRepositoryMockDeleteExpiredParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// SessionRepositoryMockDeleteExpiredExpectation specifies expectation struct of the SessionRepository.DeleteExpired +type SessionRepositoryMockDeleteExpiredExpectation struct { + mock *SessionRepositoryMock + params *SessionRepositoryMockDeleteExpiredParams + paramPtrs *SessionRepositoryMockDeleteExpiredParamPtrs + expectationOrigins SessionRepositoryMockDeleteExpiredExpectationOrigins + results *SessionRepositoryMockDeleteExpiredResults + returnOrigin string + Counter uint64 +} + +// SessionRepositoryMockDeleteExpiredParams contains parameters of the SessionRepository.DeleteExpired +type SessionRepositoryMockDeleteExpiredParams struct { + ctx context.Context +} + +// SessionRepositoryMockDeleteExpiredParamPtrs contains pointers to parameters of the SessionRepository.DeleteExpired +type SessionRepositoryMockDeleteExpiredParamPtrs struct { + ctx *context.Context +} + +// SessionRepositoryMockDeleteExpiredResults contains results of the SessionRepository.DeleteExpired +type SessionRepositoryMockDeleteExpiredResults struct { + i1 int + err error +} + +// SessionRepositoryMockDeleteExpiredOrigins contains origins of expectations of the SessionRepository.DeleteExpired +type SessionRepositoryMockDeleteExpiredExpectationOrigins struct { + origin string + originCtx string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmDeleteExpired *mSessionRepositoryMockDeleteExpired) Optional() *mSessionRepositoryMockDeleteExpired { + mmDeleteExpired.optional = true + return mmDeleteExpired +} + +// Expect sets up expected params for SessionRepository.DeleteExpired +func (mmDeleteExpired *mSessionRepositoryMockDeleteExpired) Expect(ctx context.Context) *mSessionRepositoryMockDeleteExpired { + if mmDeleteExpired.mock.funcDeleteExpired != nil { + mmDeleteExpired.mock.t.Fatalf("SessionRepositoryMock.DeleteExpired mock is already set by Set") + } + + if mmDeleteExpired.defaultExpectation == nil { + mmDeleteExpired.defaultExpectation = &SessionRepositoryMockDeleteExpiredExpectation{} + } + + if mmDeleteExpired.defaultExpectation.paramPtrs != nil { + mmDeleteExpired.mock.t.Fatalf("SessionRepositoryMock.DeleteExpired mock is already set by ExpectParams functions") + } + + mmDeleteExpired.defaultExpectation.params = &SessionRepositoryMockDeleteExpiredParams{ctx} + mmDeleteExpired.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmDeleteExpired.expectations { + if minimock.Equal(e.params, mmDeleteExpired.defaultExpectation.params) { + mmDeleteExpired.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDeleteExpired.defaultExpectation.params) + } + } + + return mmDeleteExpired +} + +// ExpectCtxParam1 sets up expected param ctx for SessionRepository.DeleteExpired +func (mmDeleteExpired *mSessionRepositoryMockDeleteExpired) ExpectCtxParam1(ctx context.Context) *mSessionRepositoryMockDeleteExpired { + if mmDeleteExpired.mock.funcDeleteExpired != nil { + mmDeleteExpired.mock.t.Fatalf("SessionRepositoryMock.DeleteExpired mock is already set by Set") + } + + if mmDeleteExpired.defaultExpectation == nil { + mmDeleteExpired.defaultExpectation = &SessionRepositoryMockDeleteExpiredExpectation{} + } + + if mmDeleteExpired.defaultExpectation.params != nil { + mmDeleteExpired.mock.t.Fatalf("SessionRepositoryMock.DeleteExpired mock is already set by Expect") + } + + if mmDeleteExpired.defaultExpectation.paramPtrs == nil { + mmDeleteExpired.defaultExpectation.paramPtrs = &SessionRepositoryMockDeleteExpiredParamPtrs{} + } + mmDeleteExpired.defaultExpectation.paramPtrs.ctx = &ctx + mmDeleteExpired.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmDeleteExpired +} + +// Inspect accepts an inspector function that has same arguments as the SessionRepository.DeleteExpired +func (mmDeleteExpired *mSessionRepositoryMockDeleteExpired) Inspect(f func(ctx context.Context)) *mSessionRepositoryMockDeleteExpired { + if mmDeleteExpired.mock.inspectFuncDeleteExpired != nil { + mmDeleteExpired.mock.t.Fatalf("Inspect function is already set for SessionRepositoryMock.DeleteExpired") + } + + mmDeleteExpired.mock.inspectFuncDeleteExpired = f + + return mmDeleteExpired +} + +// Return sets up results that will be returned by SessionRepository.DeleteExpired +func (mmDeleteExpired *mSessionRepositoryMockDeleteExpired) Return(i1 int, err error) *SessionRepositoryMock { + if mmDeleteExpired.mock.funcDeleteExpired != nil { + mmDeleteExpired.mock.t.Fatalf("SessionRepositoryMock.DeleteExpired mock is already set by Set") + } + + if mmDeleteExpired.defaultExpectation == nil { + mmDeleteExpired.defaultExpectation = &SessionRepositoryMockDeleteExpiredExpectation{mock: mmDeleteExpired.mock} + } + mmDeleteExpired.defaultExpectation.results = &SessionRepositoryMockDeleteExpiredResults{i1, err} + mmDeleteExpired.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmDeleteExpired.mock +} + +// Set uses given function f to mock the SessionRepository.DeleteExpired method +func (mmDeleteExpired *mSessionRepositoryMockDeleteExpired) Set(f func(ctx context.Context) (i1 int, err error)) *SessionRepositoryMock { + if mmDeleteExpired.defaultExpectation != nil { + mmDeleteExpired.mock.t.Fatalf("Default expectation is already set for the SessionRepository.DeleteExpired method") + } + + if len(mmDeleteExpired.expectations) > 0 { + mmDeleteExpired.mock.t.Fatalf("Some expectations are already set for the SessionRepository.DeleteExpired method") + } + + mmDeleteExpired.mock.funcDeleteExpired = f + mmDeleteExpired.mock.funcDeleteExpiredOrigin = minimock.CallerInfo(1) + return mmDeleteExpired.mock +} + +// When sets expectation for the SessionRepository.DeleteExpired which will trigger the result defined by the following +// Then helper +func (mmDeleteExpired *mSessionRepositoryMockDeleteExpired) When(ctx context.Context) *SessionRepositoryMockDeleteExpiredExpectation { + if mmDeleteExpired.mock.funcDeleteExpired != nil { + mmDeleteExpired.mock.t.Fatalf("SessionRepositoryMock.DeleteExpired mock is already set by Set") + } + + expectation := &SessionRepositoryMockDeleteExpiredExpectation{ + mock: mmDeleteExpired.mock, + params: &SessionRepositoryMockDeleteExpiredParams{ctx}, + expectationOrigins: SessionRepositoryMockDeleteExpiredExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmDeleteExpired.expectations = append(mmDeleteExpired.expectations, expectation) + return expectation +} + +// Then sets up SessionRepository.DeleteExpired return parameters for the expectation previously defined by the When method +func (e *SessionRepositoryMockDeleteExpiredExpectation) Then(i1 int, err error) *SessionRepositoryMock { + e.results = &SessionRepositoryMockDeleteExpiredResults{i1, err} + return e.mock +} + +// Times sets number of times SessionRepository.DeleteExpired should be invoked +func (mmDeleteExpired *mSessionRepositoryMockDeleteExpired) Times(n uint64) *mSessionRepositoryMockDeleteExpired { + if n == 0 { + mmDeleteExpired.mock.t.Fatalf("Times of SessionRepositoryMock.DeleteExpired mock can not be zero") + } + mm_atomic.StoreUint64(&mmDeleteExpired.expectedInvocations, n) + mmDeleteExpired.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmDeleteExpired +} + +func (mmDeleteExpired *mSessionRepositoryMockDeleteExpired) invocationsDone() bool { + if len(mmDeleteExpired.expectations) == 0 && mmDeleteExpired.defaultExpectation == nil && mmDeleteExpired.mock.funcDeleteExpired == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmDeleteExpired.mock.afterDeleteExpiredCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmDeleteExpired.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// DeleteExpired implements mm_repository.SessionRepository +func (mmDeleteExpired *SessionRepositoryMock) DeleteExpired(ctx context.Context) (i1 int, err error) { + mm_atomic.AddUint64(&mmDeleteExpired.beforeDeleteExpiredCounter, 1) + defer mm_atomic.AddUint64(&mmDeleteExpired.afterDeleteExpiredCounter, 1) + + mmDeleteExpired.t.Helper() + + if mmDeleteExpired.inspectFuncDeleteExpired != nil { + mmDeleteExpired.inspectFuncDeleteExpired(ctx) + } + + mm_params := SessionRepositoryMockDeleteExpiredParams{ctx} + + // Record call args + mmDeleteExpired.DeleteExpiredMock.mutex.Lock() + mmDeleteExpired.DeleteExpiredMock.callArgs = append(mmDeleteExpired.DeleteExpiredMock.callArgs, &mm_params) + mmDeleteExpired.DeleteExpiredMock.mutex.Unlock() + + for _, e := range mmDeleteExpired.DeleteExpiredMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.i1, e.results.err + } + } + + if mmDeleteExpired.DeleteExpiredMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmDeleteExpired.DeleteExpiredMock.defaultExpectation.Counter, 1) + mm_want := mmDeleteExpired.DeleteExpiredMock.defaultExpectation.params + mm_want_ptrs := mmDeleteExpired.DeleteExpiredMock.defaultExpectation.paramPtrs + + mm_got := SessionRepositoryMockDeleteExpiredParams{ctx} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmDeleteExpired.t.Errorf("SessionRepositoryMock.DeleteExpired got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmDeleteExpired.DeleteExpiredMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmDeleteExpired.t.Errorf("SessionRepositoryMock.DeleteExpired got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmDeleteExpired.DeleteExpiredMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmDeleteExpired.DeleteExpiredMock.defaultExpectation.results + if mm_results == nil { + mmDeleteExpired.t.Fatal("No results are set for the SessionRepositoryMock.DeleteExpired") + } + return (*mm_results).i1, (*mm_results).err + } + if mmDeleteExpired.funcDeleteExpired != nil { + return mmDeleteExpired.funcDeleteExpired(ctx) + } + mmDeleteExpired.t.Fatalf("Unexpected call to SessionRepositoryMock.DeleteExpired. %v", ctx) + return +} + +// DeleteExpiredAfterCounter returns a count of finished SessionRepositoryMock.DeleteExpired invocations +func (mmDeleteExpired *SessionRepositoryMock) DeleteExpiredAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmDeleteExpired.afterDeleteExpiredCounter) +} + +// DeleteExpiredBeforeCounter returns a count of SessionRepositoryMock.DeleteExpired invocations +func (mmDeleteExpired *SessionRepositoryMock) DeleteExpiredBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmDeleteExpired.beforeDeleteExpiredCounter) +} + +// Calls returns a list of arguments used in each call to SessionRepositoryMock.DeleteExpired. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmDeleteExpired *mSessionRepositoryMockDeleteExpired) Calls() []*SessionRepositoryMockDeleteExpiredParams { + mmDeleteExpired.mutex.RLock() + + argCopy := make([]*SessionRepositoryMockDeleteExpiredParams, len(mmDeleteExpired.callArgs)) + copy(argCopy, mmDeleteExpired.callArgs) + + mmDeleteExpired.mutex.RUnlock() + + return argCopy +} + +// MinimockDeleteExpiredDone returns true if the count of the DeleteExpired invocations corresponds +// the number of defined expectations +func (m *SessionRepositoryMock) MinimockDeleteExpiredDone() bool { + if m.DeleteExpiredMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.DeleteExpiredMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.DeleteExpiredMock.invocationsDone() +} + +// MinimockDeleteExpiredInspect logs each unmet expectation +func (m *SessionRepositoryMock) MinimockDeleteExpiredInspect() { + for _, e := range m.DeleteExpiredMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to SessionRepositoryMock.DeleteExpired at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterDeleteExpiredCounter := mm_atomic.LoadUint64(&m.afterDeleteExpiredCounter) + // if default expectation was set then invocations count should be greater than zero + if m.DeleteExpiredMock.defaultExpectation != nil && afterDeleteExpiredCounter < 1 { + if m.DeleteExpiredMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to SessionRepositoryMock.DeleteExpired at\n%s", m.DeleteExpiredMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to SessionRepositoryMock.DeleteExpired at\n%s with params: %#v", m.DeleteExpiredMock.defaultExpectation.expectationOrigins.origin, *m.DeleteExpiredMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcDeleteExpired != nil && afterDeleteExpiredCounter < 1 { + m.t.Errorf("Expected call to SessionRepositoryMock.DeleteExpired at\n%s", m.funcDeleteExpiredOrigin) + } + + if !m.DeleteExpiredMock.invocationsDone() && afterDeleteExpiredCounter > 0 { + m.t.Errorf("Expected %d calls to SessionRepositoryMock.DeleteExpired at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.DeleteExpiredMock.expectedInvocations), m.DeleteExpiredMock.expectedInvocationsOrigin, afterDeleteExpiredCounter) + } +} + +type mSessionRepositoryMockFindByRefreshToken struct { + optional bool + mock *SessionRepositoryMock + defaultExpectation *SessionRepositoryMockFindByRefreshTokenExpectation + expectations []*SessionRepositoryMockFindByRefreshTokenExpectation + + callArgs []*SessionRepositoryMockFindByRefreshTokenParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// SessionRepositoryMockFindByRefreshTokenExpectation specifies expectation struct of the SessionRepository.FindByRefreshToken +type SessionRepositoryMockFindByRefreshTokenExpectation struct { + mock *SessionRepositoryMock + params *SessionRepositoryMockFindByRefreshTokenParams + paramPtrs *SessionRepositoryMockFindByRefreshTokenParamPtrs + expectationOrigins SessionRepositoryMockFindByRefreshTokenExpectationOrigins + results *SessionRepositoryMockFindByRefreshTokenResults + returnOrigin string + Counter uint64 +} + +// SessionRepositoryMockFindByRefreshTokenParams contains parameters of the SessionRepository.FindByRefreshToken +type SessionRepositoryMockFindByRefreshTokenParams struct { + ctx context.Context + token string +} + +// SessionRepositoryMockFindByRefreshTokenParamPtrs contains pointers to parameters of the SessionRepository.FindByRefreshToken +type SessionRepositoryMockFindByRefreshTokenParamPtrs struct { + ctx *context.Context + token *string +} + +// SessionRepositoryMockFindByRefreshTokenResults contains results of the SessionRepository.FindByRefreshToken +type SessionRepositoryMockFindByRefreshTokenResults struct { + sp1 *model.Session + err error +} + +// SessionRepositoryMockFindByRefreshTokenOrigins contains origins of expectations of the SessionRepository.FindByRefreshToken +type SessionRepositoryMockFindByRefreshTokenExpectationOrigins struct { + origin string + originCtx string + originToken string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmFindByRefreshToken *mSessionRepositoryMockFindByRefreshToken) Optional() *mSessionRepositoryMockFindByRefreshToken { + mmFindByRefreshToken.optional = true + return mmFindByRefreshToken +} + +// Expect sets up expected params for SessionRepository.FindByRefreshToken +func (mmFindByRefreshToken *mSessionRepositoryMockFindByRefreshToken) Expect(ctx context.Context, token string) *mSessionRepositoryMockFindByRefreshToken { + if mmFindByRefreshToken.mock.funcFindByRefreshToken != nil { + mmFindByRefreshToken.mock.t.Fatalf("SessionRepositoryMock.FindByRefreshToken mock is already set by Set") + } + + if mmFindByRefreshToken.defaultExpectation == nil { + mmFindByRefreshToken.defaultExpectation = &SessionRepositoryMockFindByRefreshTokenExpectation{} + } + + if mmFindByRefreshToken.defaultExpectation.paramPtrs != nil { + mmFindByRefreshToken.mock.t.Fatalf("SessionRepositoryMock.FindByRefreshToken mock is already set by ExpectParams functions") + } + + mmFindByRefreshToken.defaultExpectation.params = &SessionRepositoryMockFindByRefreshTokenParams{ctx, token} + mmFindByRefreshToken.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmFindByRefreshToken.expectations { + if minimock.Equal(e.params, mmFindByRefreshToken.defaultExpectation.params) { + mmFindByRefreshToken.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmFindByRefreshToken.defaultExpectation.params) + } + } + + return mmFindByRefreshToken +} + +// ExpectCtxParam1 sets up expected param ctx for SessionRepository.FindByRefreshToken +func (mmFindByRefreshToken *mSessionRepositoryMockFindByRefreshToken) ExpectCtxParam1(ctx context.Context) *mSessionRepositoryMockFindByRefreshToken { + if mmFindByRefreshToken.mock.funcFindByRefreshToken != nil { + mmFindByRefreshToken.mock.t.Fatalf("SessionRepositoryMock.FindByRefreshToken mock is already set by Set") + } + + if mmFindByRefreshToken.defaultExpectation == nil { + mmFindByRefreshToken.defaultExpectation = &SessionRepositoryMockFindByRefreshTokenExpectation{} + } + + if mmFindByRefreshToken.defaultExpectation.params != nil { + mmFindByRefreshToken.mock.t.Fatalf("SessionRepositoryMock.FindByRefreshToken mock is already set by Expect") + } + + if mmFindByRefreshToken.defaultExpectation.paramPtrs == nil { + mmFindByRefreshToken.defaultExpectation.paramPtrs = &SessionRepositoryMockFindByRefreshTokenParamPtrs{} + } + mmFindByRefreshToken.defaultExpectation.paramPtrs.ctx = &ctx + mmFindByRefreshToken.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmFindByRefreshToken +} + +// ExpectTokenParam2 sets up expected param token for SessionRepository.FindByRefreshToken +func (mmFindByRefreshToken *mSessionRepositoryMockFindByRefreshToken) ExpectTokenParam2(token string) *mSessionRepositoryMockFindByRefreshToken { + if mmFindByRefreshToken.mock.funcFindByRefreshToken != nil { + mmFindByRefreshToken.mock.t.Fatalf("SessionRepositoryMock.FindByRefreshToken mock is already set by Set") + } + + if mmFindByRefreshToken.defaultExpectation == nil { + mmFindByRefreshToken.defaultExpectation = &SessionRepositoryMockFindByRefreshTokenExpectation{} + } + + if mmFindByRefreshToken.defaultExpectation.params != nil { + mmFindByRefreshToken.mock.t.Fatalf("SessionRepositoryMock.FindByRefreshToken mock is already set by Expect") + } + + if mmFindByRefreshToken.defaultExpectation.paramPtrs == nil { + mmFindByRefreshToken.defaultExpectation.paramPtrs = &SessionRepositoryMockFindByRefreshTokenParamPtrs{} + } + mmFindByRefreshToken.defaultExpectation.paramPtrs.token = &token + mmFindByRefreshToken.defaultExpectation.expectationOrigins.originToken = minimock.CallerInfo(1) + + return mmFindByRefreshToken +} + +// Inspect accepts an inspector function that has same arguments as the SessionRepository.FindByRefreshToken +func (mmFindByRefreshToken *mSessionRepositoryMockFindByRefreshToken) Inspect(f func(ctx context.Context, token string)) *mSessionRepositoryMockFindByRefreshToken { + if mmFindByRefreshToken.mock.inspectFuncFindByRefreshToken != nil { + mmFindByRefreshToken.mock.t.Fatalf("Inspect function is already set for SessionRepositoryMock.FindByRefreshToken") + } + + mmFindByRefreshToken.mock.inspectFuncFindByRefreshToken = f + + return mmFindByRefreshToken +} + +// Return sets up results that will be returned by SessionRepository.FindByRefreshToken +func (mmFindByRefreshToken *mSessionRepositoryMockFindByRefreshToken) Return(sp1 *model.Session, err error) *SessionRepositoryMock { + if mmFindByRefreshToken.mock.funcFindByRefreshToken != nil { + mmFindByRefreshToken.mock.t.Fatalf("SessionRepositoryMock.FindByRefreshToken mock is already set by Set") + } + + if mmFindByRefreshToken.defaultExpectation == nil { + mmFindByRefreshToken.defaultExpectation = &SessionRepositoryMockFindByRefreshTokenExpectation{mock: mmFindByRefreshToken.mock} + } + mmFindByRefreshToken.defaultExpectation.results = &SessionRepositoryMockFindByRefreshTokenResults{sp1, err} + mmFindByRefreshToken.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmFindByRefreshToken.mock +} + +// Set uses given function f to mock the SessionRepository.FindByRefreshToken method +func (mmFindByRefreshToken *mSessionRepositoryMockFindByRefreshToken) Set(f func(ctx context.Context, token string) (sp1 *model.Session, err error)) *SessionRepositoryMock { + if mmFindByRefreshToken.defaultExpectation != nil { + mmFindByRefreshToken.mock.t.Fatalf("Default expectation is already set for the SessionRepository.FindByRefreshToken method") + } + + if len(mmFindByRefreshToken.expectations) > 0 { + mmFindByRefreshToken.mock.t.Fatalf("Some expectations are already set for the SessionRepository.FindByRefreshToken method") + } + + mmFindByRefreshToken.mock.funcFindByRefreshToken = f + mmFindByRefreshToken.mock.funcFindByRefreshTokenOrigin = minimock.CallerInfo(1) + return mmFindByRefreshToken.mock +} + +// When sets expectation for the SessionRepository.FindByRefreshToken which will trigger the result defined by the following +// Then helper +func (mmFindByRefreshToken *mSessionRepositoryMockFindByRefreshToken) When(ctx context.Context, token string) *SessionRepositoryMockFindByRefreshTokenExpectation { + if mmFindByRefreshToken.mock.funcFindByRefreshToken != nil { + mmFindByRefreshToken.mock.t.Fatalf("SessionRepositoryMock.FindByRefreshToken mock is already set by Set") + } + + expectation := &SessionRepositoryMockFindByRefreshTokenExpectation{ + mock: mmFindByRefreshToken.mock, + params: &SessionRepositoryMockFindByRefreshTokenParams{ctx, token}, + expectationOrigins: SessionRepositoryMockFindByRefreshTokenExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmFindByRefreshToken.expectations = append(mmFindByRefreshToken.expectations, expectation) + return expectation +} + +// Then sets up SessionRepository.FindByRefreshToken return parameters for the expectation previously defined by the When method +func (e *SessionRepositoryMockFindByRefreshTokenExpectation) Then(sp1 *model.Session, err error) *SessionRepositoryMock { + e.results = &SessionRepositoryMockFindByRefreshTokenResults{sp1, err} + return e.mock +} + +// Times sets number of times SessionRepository.FindByRefreshToken should be invoked +func (mmFindByRefreshToken *mSessionRepositoryMockFindByRefreshToken) Times(n uint64) *mSessionRepositoryMockFindByRefreshToken { + if n == 0 { + mmFindByRefreshToken.mock.t.Fatalf("Times of SessionRepositoryMock.FindByRefreshToken mock can not be zero") + } + mm_atomic.StoreUint64(&mmFindByRefreshToken.expectedInvocations, n) + mmFindByRefreshToken.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmFindByRefreshToken +} + +func (mmFindByRefreshToken *mSessionRepositoryMockFindByRefreshToken) invocationsDone() bool { + if len(mmFindByRefreshToken.expectations) == 0 && mmFindByRefreshToken.defaultExpectation == nil && mmFindByRefreshToken.mock.funcFindByRefreshToken == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmFindByRefreshToken.mock.afterFindByRefreshTokenCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmFindByRefreshToken.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// FindByRefreshToken implements mm_repository.SessionRepository +func (mmFindByRefreshToken *SessionRepositoryMock) FindByRefreshToken(ctx context.Context, token string) (sp1 *model.Session, err error) { + mm_atomic.AddUint64(&mmFindByRefreshToken.beforeFindByRefreshTokenCounter, 1) + defer mm_atomic.AddUint64(&mmFindByRefreshToken.afterFindByRefreshTokenCounter, 1) + + mmFindByRefreshToken.t.Helper() + + if mmFindByRefreshToken.inspectFuncFindByRefreshToken != nil { + mmFindByRefreshToken.inspectFuncFindByRefreshToken(ctx, token) + } + + mm_params := SessionRepositoryMockFindByRefreshTokenParams{ctx, token} + + // Record call args + mmFindByRefreshToken.FindByRefreshTokenMock.mutex.Lock() + mmFindByRefreshToken.FindByRefreshTokenMock.callArgs = append(mmFindByRefreshToken.FindByRefreshTokenMock.callArgs, &mm_params) + mmFindByRefreshToken.FindByRefreshTokenMock.mutex.Unlock() + + for _, e := range mmFindByRefreshToken.FindByRefreshTokenMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.sp1, e.results.err + } + } + + if mmFindByRefreshToken.FindByRefreshTokenMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmFindByRefreshToken.FindByRefreshTokenMock.defaultExpectation.Counter, 1) + mm_want := mmFindByRefreshToken.FindByRefreshTokenMock.defaultExpectation.params + mm_want_ptrs := mmFindByRefreshToken.FindByRefreshTokenMock.defaultExpectation.paramPtrs + + mm_got := SessionRepositoryMockFindByRefreshTokenParams{ctx, token} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmFindByRefreshToken.t.Errorf("SessionRepositoryMock.FindByRefreshToken got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmFindByRefreshToken.FindByRefreshTokenMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.token != nil && !minimock.Equal(*mm_want_ptrs.token, mm_got.token) { + mmFindByRefreshToken.t.Errorf("SessionRepositoryMock.FindByRefreshToken got unexpected parameter token, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmFindByRefreshToken.FindByRefreshTokenMock.defaultExpectation.expectationOrigins.originToken, *mm_want_ptrs.token, mm_got.token, minimock.Diff(*mm_want_ptrs.token, mm_got.token)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmFindByRefreshToken.t.Errorf("SessionRepositoryMock.FindByRefreshToken got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmFindByRefreshToken.FindByRefreshTokenMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmFindByRefreshToken.FindByRefreshTokenMock.defaultExpectation.results + if mm_results == nil { + mmFindByRefreshToken.t.Fatal("No results are set for the SessionRepositoryMock.FindByRefreshToken") + } + return (*mm_results).sp1, (*mm_results).err + } + if mmFindByRefreshToken.funcFindByRefreshToken != nil { + return mmFindByRefreshToken.funcFindByRefreshToken(ctx, token) + } + mmFindByRefreshToken.t.Fatalf("Unexpected call to SessionRepositoryMock.FindByRefreshToken. %v %v", ctx, token) + return +} + +// FindByRefreshTokenAfterCounter returns a count of finished SessionRepositoryMock.FindByRefreshToken invocations +func (mmFindByRefreshToken *SessionRepositoryMock) FindByRefreshTokenAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmFindByRefreshToken.afterFindByRefreshTokenCounter) +} + +// FindByRefreshTokenBeforeCounter returns a count of SessionRepositoryMock.FindByRefreshToken invocations +func (mmFindByRefreshToken *SessionRepositoryMock) FindByRefreshTokenBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmFindByRefreshToken.beforeFindByRefreshTokenCounter) +} + +// Calls returns a list of arguments used in each call to SessionRepositoryMock.FindByRefreshToken. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmFindByRefreshToken *mSessionRepositoryMockFindByRefreshToken) Calls() []*SessionRepositoryMockFindByRefreshTokenParams { + mmFindByRefreshToken.mutex.RLock() + + argCopy := make([]*SessionRepositoryMockFindByRefreshTokenParams, len(mmFindByRefreshToken.callArgs)) + copy(argCopy, mmFindByRefreshToken.callArgs) + + mmFindByRefreshToken.mutex.RUnlock() + + return argCopy +} + +// MinimockFindByRefreshTokenDone returns true if the count of the FindByRefreshToken invocations corresponds +// the number of defined expectations +func (m *SessionRepositoryMock) MinimockFindByRefreshTokenDone() bool { + if m.FindByRefreshTokenMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.FindByRefreshTokenMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.FindByRefreshTokenMock.invocationsDone() +} + +// MinimockFindByRefreshTokenInspect logs each unmet expectation +func (m *SessionRepositoryMock) MinimockFindByRefreshTokenInspect() { + for _, e := range m.FindByRefreshTokenMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to SessionRepositoryMock.FindByRefreshToken at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterFindByRefreshTokenCounter := mm_atomic.LoadUint64(&m.afterFindByRefreshTokenCounter) + // if default expectation was set then invocations count should be greater than zero + if m.FindByRefreshTokenMock.defaultExpectation != nil && afterFindByRefreshTokenCounter < 1 { + if m.FindByRefreshTokenMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to SessionRepositoryMock.FindByRefreshToken at\n%s", m.FindByRefreshTokenMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to SessionRepositoryMock.FindByRefreshToken at\n%s with params: %#v", m.FindByRefreshTokenMock.defaultExpectation.expectationOrigins.origin, *m.FindByRefreshTokenMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcFindByRefreshToken != nil && afterFindByRefreshTokenCounter < 1 { + m.t.Errorf("Expected call to SessionRepositoryMock.FindByRefreshToken at\n%s", m.funcFindByRefreshTokenOrigin) + } + + if !m.FindByRefreshTokenMock.invocationsDone() && afterFindByRefreshTokenCounter > 0 { + m.t.Errorf("Expected %d calls to SessionRepositoryMock.FindByRefreshToken at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.FindByRefreshTokenMock.expectedInvocations), m.FindByRefreshTokenMock.expectedInvocationsOrigin, afterFindByRefreshTokenCounter) + } +} + +type mSessionRepositoryMockRevoke struct { + optional bool + mock *SessionRepositoryMock + defaultExpectation *SessionRepositoryMockRevokeExpectation + expectations []*SessionRepositoryMockRevokeExpectation + + callArgs []*SessionRepositoryMockRevokeParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// SessionRepositoryMockRevokeExpectation specifies expectation struct of the SessionRepository.Revoke +type SessionRepositoryMockRevokeExpectation struct { + mock *SessionRepositoryMock + params *SessionRepositoryMockRevokeParams + paramPtrs *SessionRepositoryMockRevokeParamPtrs + expectationOrigins SessionRepositoryMockRevokeExpectationOrigins + results *SessionRepositoryMockRevokeResults + returnOrigin string + Counter uint64 +} + +// SessionRepositoryMockRevokeParams contains parameters of the SessionRepository.Revoke +type SessionRepositoryMockRevokeParams struct { + ctx context.Context + refreshToken string +} + +// SessionRepositoryMockRevokeParamPtrs contains pointers to parameters of the SessionRepository.Revoke +type SessionRepositoryMockRevokeParamPtrs struct { + ctx *context.Context + refreshToken *string +} + +// SessionRepositoryMockRevokeResults contains results of the SessionRepository.Revoke +type SessionRepositoryMockRevokeResults struct { + err error +} + +// SessionRepositoryMockRevokeOrigins contains origins of expectations of the SessionRepository.Revoke +type SessionRepositoryMockRevokeExpectationOrigins struct { + origin string + originCtx string + originRefreshToken string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmRevoke *mSessionRepositoryMockRevoke) Optional() *mSessionRepositoryMockRevoke { + mmRevoke.optional = true + return mmRevoke +} + +// Expect sets up expected params for SessionRepository.Revoke +func (mmRevoke *mSessionRepositoryMockRevoke) Expect(ctx context.Context, refreshToken string) *mSessionRepositoryMockRevoke { + if mmRevoke.mock.funcRevoke != nil { + mmRevoke.mock.t.Fatalf("SessionRepositoryMock.Revoke mock is already set by Set") + } + + if mmRevoke.defaultExpectation == nil { + mmRevoke.defaultExpectation = &SessionRepositoryMockRevokeExpectation{} + } + + if mmRevoke.defaultExpectation.paramPtrs != nil { + mmRevoke.mock.t.Fatalf("SessionRepositoryMock.Revoke mock is already set by ExpectParams functions") + } + + mmRevoke.defaultExpectation.params = &SessionRepositoryMockRevokeParams{ctx, refreshToken} + mmRevoke.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmRevoke.expectations { + if minimock.Equal(e.params, mmRevoke.defaultExpectation.params) { + mmRevoke.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmRevoke.defaultExpectation.params) + } + } + + return mmRevoke +} + +// ExpectCtxParam1 sets up expected param ctx for SessionRepository.Revoke +func (mmRevoke *mSessionRepositoryMockRevoke) ExpectCtxParam1(ctx context.Context) *mSessionRepositoryMockRevoke { + if mmRevoke.mock.funcRevoke != nil { + mmRevoke.mock.t.Fatalf("SessionRepositoryMock.Revoke mock is already set by Set") + } + + if mmRevoke.defaultExpectation == nil { + mmRevoke.defaultExpectation = &SessionRepositoryMockRevokeExpectation{} + } + + if mmRevoke.defaultExpectation.params != nil { + mmRevoke.mock.t.Fatalf("SessionRepositoryMock.Revoke mock is already set by Expect") + } + + if mmRevoke.defaultExpectation.paramPtrs == nil { + mmRevoke.defaultExpectation.paramPtrs = &SessionRepositoryMockRevokeParamPtrs{} + } + mmRevoke.defaultExpectation.paramPtrs.ctx = &ctx + mmRevoke.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmRevoke +} + +// ExpectRefreshTokenParam2 sets up expected param refreshToken for SessionRepository.Revoke +func (mmRevoke *mSessionRepositoryMockRevoke) ExpectRefreshTokenParam2(refreshToken string) *mSessionRepositoryMockRevoke { + if mmRevoke.mock.funcRevoke != nil { + mmRevoke.mock.t.Fatalf("SessionRepositoryMock.Revoke mock is already set by Set") + } + + if mmRevoke.defaultExpectation == nil { + mmRevoke.defaultExpectation = &SessionRepositoryMockRevokeExpectation{} + } + + if mmRevoke.defaultExpectation.params != nil { + mmRevoke.mock.t.Fatalf("SessionRepositoryMock.Revoke mock is already set by Expect") + } + + if mmRevoke.defaultExpectation.paramPtrs == nil { + mmRevoke.defaultExpectation.paramPtrs = &SessionRepositoryMockRevokeParamPtrs{} + } + mmRevoke.defaultExpectation.paramPtrs.refreshToken = &refreshToken + mmRevoke.defaultExpectation.expectationOrigins.originRefreshToken = minimock.CallerInfo(1) + + return mmRevoke +} + +// Inspect accepts an inspector function that has same arguments as the SessionRepository.Revoke +func (mmRevoke *mSessionRepositoryMockRevoke) Inspect(f func(ctx context.Context, refreshToken string)) *mSessionRepositoryMockRevoke { + if mmRevoke.mock.inspectFuncRevoke != nil { + mmRevoke.mock.t.Fatalf("Inspect function is already set for SessionRepositoryMock.Revoke") + } + + mmRevoke.mock.inspectFuncRevoke = f + + return mmRevoke +} + +// Return sets up results that will be returned by SessionRepository.Revoke +func (mmRevoke *mSessionRepositoryMockRevoke) Return(err error) *SessionRepositoryMock { + if mmRevoke.mock.funcRevoke != nil { + mmRevoke.mock.t.Fatalf("SessionRepositoryMock.Revoke mock is already set by Set") + } + + if mmRevoke.defaultExpectation == nil { + mmRevoke.defaultExpectation = &SessionRepositoryMockRevokeExpectation{mock: mmRevoke.mock} + } + mmRevoke.defaultExpectation.results = &SessionRepositoryMockRevokeResults{err} + mmRevoke.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmRevoke.mock +} + +// Set uses given function f to mock the SessionRepository.Revoke method +func (mmRevoke *mSessionRepositoryMockRevoke) Set(f func(ctx context.Context, refreshToken string) (err error)) *SessionRepositoryMock { + if mmRevoke.defaultExpectation != nil { + mmRevoke.mock.t.Fatalf("Default expectation is already set for the SessionRepository.Revoke method") + } + + if len(mmRevoke.expectations) > 0 { + mmRevoke.mock.t.Fatalf("Some expectations are already set for the SessionRepository.Revoke method") + } + + mmRevoke.mock.funcRevoke = f + mmRevoke.mock.funcRevokeOrigin = minimock.CallerInfo(1) + return mmRevoke.mock +} + +// When sets expectation for the SessionRepository.Revoke which will trigger the result defined by the following +// Then helper +func (mmRevoke *mSessionRepositoryMockRevoke) When(ctx context.Context, refreshToken string) *SessionRepositoryMockRevokeExpectation { + if mmRevoke.mock.funcRevoke != nil { + mmRevoke.mock.t.Fatalf("SessionRepositoryMock.Revoke mock is already set by Set") + } + + expectation := &SessionRepositoryMockRevokeExpectation{ + mock: mmRevoke.mock, + params: &SessionRepositoryMockRevokeParams{ctx, refreshToken}, + expectationOrigins: SessionRepositoryMockRevokeExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmRevoke.expectations = append(mmRevoke.expectations, expectation) + return expectation +} + +// Then sets up SessionRepository.Revoke return parameters for the expectation previously defined by the When method +func (e *SessionRepositoryMockRevokeExpectation) Then(err error) *SessionRepositoryMock { + e.results = &SessionRepositoryMockRevokeResults{err} + return e.mock +} + +// Times sets number of times SessionRepository.Revoke should be invoked +func (mmRevoke *mSessionRepositoryMockRevoke) Times(n uint64) *mSessionRepositoryMockRevoke { + if n == 0 { + mmRevoke.mock.t.Fatalf("Times of SessionRepositoryMock.Revoke mock can not be zero") + } + mm_atomic.StoreUint64(&mmRevoke.expectedInvocations, n) + mmRevoke.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmRevoke +} + +func (mmRevoke *mSessionRepositoryMockRevoke) invocationsDone() bool { + if len(mmRevoke.expectations) == 0 && mmRevoke.defaultExpectation == nil && mmRevoke.mock.funcRevoke == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmRevoke.mock.afterRevokeCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmRevoke.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// Revoke implements mm_repository.SessionRepository +func (mmRevoke *SessionRepositoryMock) Revoke(ctx context.Context, refreshToken string) (err error) { + mm_atomic.AddUint64(&mmRevoke.beforeRevokeCounter, 1) + defer mm_atomic.AddUint64(&mmRevoke.afterRevokeCounter, 1) + + mmRevoke.t.Helper() + + if mmRevoke.inspectFuncRevoke != nil { + mmRevoke.inspectFuncRevoke(ctx, refreshToken) + } + + mm_params := SessionRepositoryMockRevokeParams{ctx, refreshToken} + + // Record call args + mmRevoke.RevokeMock.mutex.Lock() + mmRevoke.RevokeMock.callArgs = append(mmRevoke.RevokeMock.callArgs, &mm_params) + mmRevoke.RevokeMock.mutex.Unlock() + + for _, e := range mmRevoke.RevokeMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.err + } + } + + if mmRevoke.RevokeMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmRevoke.RevokeMock.defaultExpectation.Counter, 1) + mm_want := mmRevoke.RevokeMock.defaultExpectation.params + mm_want_ptrs := mmRevoke.RevokeMock.defaultExpectation.paramPtrs + + mm_got := SessionRepositoryMockRevokeParams{ctx, refreshToken} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmRevoke.t.Errorf("SessionRepositoryMock.Revoke got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmRevoke.RevokeMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.refreshToken != nil && !minimock.Equal(*mm_want_ptrs.refreshToken, mm_got.refreshToken) { + mmRevoke.t.Errorf("SessionRepositoryMock.Revoke got unexpected parameter refreshToken, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmRevoke.RevokeMock.defaultExpectation.expectationOrigins.originRefreshToken, *mm_want_ptrs.refreshToken, mm_got.refreshToken, minimock.Diff(*mm_want_ptrs.refreshToken, mm_got.refreshToken)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmRevoke.t.Errorf("SessionRepositoryMock.Revoke got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmRevoke.RevokeMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmRevoke.RevokeMock.defaultExpectation.results + if mm_results == nil { + mmRevoke.t.Fatal("No results are set for the SessionRepositoryMock.Revoke") + } + return (*mm_results).err + } + if mmRevoke.funcRevoke != nil { + return mmRevoke.funcRevoke(ctx, refreshToken) + } + mmRevoke.t.Fatalf("Unexpected call to SessionRepositoryMock.Revoke. %v %v", ctx, refreshToken) + return +} + +// RevokeAfterCounter returns a count of finished SessionRepositoryMock.Revoke invocations +func (mmRevoke *SessionRepositoryMock) RevokeAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmRevoke.afterRevokeCounter) +} + +// RevokeBeforeCounter returns a count of SessionRepositoryMock.Revoke invocations +func (mmRevoke *SessionRepositoryMock) RevokeBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmRevoke.beforeRevokeCounter) +} + +// Calls returns a list of arguments used in each call to SessionRepositoryMock.Revoke. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmRevoke *mSessionRepositoryMockRevoke) Calls() []*SessionRepositoryMockRevokeParams { + mmRevoke.mutex.RLock() + + argCopy := make([]*SessionRepositoryMockRevokeParams, len(mmRevoke.callArgs)) + copy(argCopy, mmRevoke.callArgs) + + mmRevoke.mutex.RUnlock() + + return argCopy +} + +// MinimockRevokeDone returns true if the count of the Revoke invocations corresponds +// the number of defined expectations +func (m *SessionRepositoryMock) MinimockRevokeDone() bool { + if m.RevokeMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.RevokeMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.RevokeMock.invocationsDone() +} + +// MinimockRevokeInspect logs each unmet expectation +func (m *SessionRepositoryMock) MinimockRevokeInspect() { + for _, e := range m.RevokeMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to SessionRepositoryMock.Revoke at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterRevokeCounter := mm_atomic.LoadUint64(&m.afterRevokeCounter) + // if default expectation was set then invocations count should be greater than zero + if m.RevokeMock.defaultExpectation != nil && afterRevokeCounter < 1 { + if m.RevokeMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to SessionRepositoryMock.Revoke at\n%s", m.RevokeMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to SessionRepositoryMock.Revoke at\n%s with params: %#v", m.RevokeMock.defaultExpectation.expectationOrigins.origin, *m.RevokeMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcRevoke != nil && afterRevokeCounter < 1 { + m.t.Errorf("Expected call to SessionRepositoryMock.Revoke at\n%s", m.funcRevokeOrigin) + } + + if !m.RevokeMock.invocationsDone() && afterRevokeCounter > 0 { + m.t.Errorf("Expected %d calls to SessionRepositoryMock.Revoke at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.RevokeMock.expectedInvocations), m.RevokeMock.expectedInvocationsOrigin, afterRevokeCounter) + } +} + +type mSessionRepositoryMockUpdateAccessToken struct { + optional bool + mock *SessionRepositoryMock + defaultExpectation *SessionRepositoryMockUpdateAccessTokenExpectation + expectations []*SessionRepositoryMockUpdateAccessTokenExpectation + + callArgs []*SessionRepositoryMockUpdateAccessTokenParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// SessionRepositoryMockUpdateAccessTokenExpectation specifies expectation struct of the SessionRepository.UpdateAccessToken +type SessionRepositoryMockUpdateAccessTokenExpectation struct { + mock *SessionRepositoryMock + params *SessionRepositoryMockUpdateAccessTokenParams + paramPtrs *SessionRepositoryMockUpdateAccessTokenParamPtrs + expectationOrigins SessionRepositoryMockUpdateAccessTokenExpectationOrigins + results *SessionRepositoryMockUpdateAccessTokenResults + returnOrigin string + Counter uint64 +} + +// SessionRepositoryMockUpdateAccessTokenParams contains parameters of the SessionRepository.UpdateAccessToken +type SessionRepositoryMockUpdateAccessTokenParams struct { + ctx context.Context + refreshToken string + newAccessToken string +} + +// SessionRepositoryMockUpdateAccessTokenParamPtrs contains pointers to parameters of the SessionRepository.UpdateAccessToken +type SessionRepositoryMockUpdateAccessTokenParamPtrs struct { + ctx *context.Context + refreshToken *string + newAccessToken *string +} + +// SessionRepositoryMockUpdateAccessTokenResults contains results of the SessionRepository.UpdateAccessToken +type SessionRepositoryMockUpdateAccessTokenResults struct { + err error +} + +// SessionRepositoryMockUpdateAccessTokenOrigins contains origins of expectations of the SessionRepository.UpdateAccessToken +type SessionRepositoryMockUpdateAccessTokenExpectationOrigins struct { + origin string + originCtx string + originRefreshToken string + originNewAccessToken string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmUpdateAccessToken *mSessionRepositoryMockUpdateAccessToken) Optional() *mSessionRepositoryMockUpdateAccessToken { + mmUpdateAccessToken.optional = true + return mmUpdateAccessToken +} + +// Expect sets up expected params for SessionRepository.UpdateAccessToken +func (mmUpdateAccessToken *mSessionRepositoryMockUpdateAccessToken) Expect(ctx context.Context, refreshToken string, newAccessToken string) *mSessionRepositoryMockUpdateAccessToken { + if mmUpdateAccessToken.mock.funcUpdateAccessToken != nil { + mmUpdateAccessToken.mock.t.Fatalf("SessionRepositoryMock.UpdateAccessToken mock is already set by Set") + } + + if mmUpdateAccessToken.defaultExpectation == nil { + mmUpdateAccessToken.defaultExpectation = &SessionRepositoryMockUpdateAccessTokenExpectation{} + } + + if mmUpdateAccessToken.defaultExpectation.paramPtrs != nil { + mmUpdateAccessToken.mock.t.Fatalf("SessionRepositoryMock.UpdateAccessToken mock is already set by ExpectParams functions") + } + + mmUpdateAccessToken.defaultExpectation.params = &SessionRepositoryMockUpdateAccessTokenParams{ctx, refreshToken, newAccessToken} + mmUpdateAccessToken.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmUpdateAccessToken.expectations { + if minimock.Equal(e.params, mmUpdateAccessToken.defaultExpectation.params) { + mmUpdateAccessToken.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmUpdateAccessToken.defaultExpectation.params) + } + } + + return mmUpdateAccessToken +} + +// ExpectCtxParam1 sets up expected param ctx for SessionRepository.UpdateAccessToken +func (mmUpdateAccessToken *mSessionRepositoryMockUpdateAccessToken) ExpectCtxParam1(ctx context.Context) *mSessionRepositoryMockUpdateAccessToken { + if mmUpdateAccessToken.mock.funcUpdateAccessToken != nil { + mmUpdateAccessToken.mock.t.Fatalf("SessionRepositoryMock.UpdateAccessToken mock is already set by Set") + } + + if mmUpdateAccessToken.defaultExpectation == nil { + mmUpdateAccessToken.defaultExpectation = &SessionRepositoryMockUpdateAccessTokenExpectation{} + } + + if mmUpdateAccessToken.defaultExpectation.params != nil { + mmUpdateAccessToken.mock.t.Fatalf("SessionRepositoryMock.UpdateAccessToken mock is already set by Expect") + } + + if mmUpdateAccessToken.defaultExpectation.paramPtrs == nil { + mmUpdateAccessToken.defaultExpectation.paramPtrs = &SessionRepositoryMockUpdateAccessTokenParamPtrs{} + } + mmUpdateAccessToken.defaultExpectation.paramPtrs.ctx = &ctx + mmUpdateAccessToken.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmUpdateAccessToken +} + +// ExpectRefreshTokenParam2 sets up expected param refreshToken for SessionRepository.UpdateAccessToken +func (mmUpdateAccessToken *mSessionRepositoryMockUpdateAccessToken) ExpectRefreshTokenParam2(refreshToken string) *mSessionRepositoryMockUpdateAccessToken { + if mmUpdateAccessToken.mock.funcUpdateAccessToken != nil { + mmUpdateAccessToken.mock.t.Fatalf("SessionRepositoryMock.UpdateAccessToken mock is already set by Set") + } + + if mmUpdateAccessToken.defaultExpectation == nil { + mmUpdateAccessToken.defaultExpectation = &SessionRepositoryMockUpdateAccessTokenExpectation{} + } + + if mmUpdateAccessToken.defaultExpectation.params != nil { + mmUpdateAccessToken.mock.t.Fatalf("SessionRepositoryMock.UpdateAccessToken mock is already set by Expect") + } + + if mmUpdateAccessToken.defaultExpectation.paramPtrs == nil { + mmUpdateAccessToken.defaultExpectation.paramPtrs = &SessionRepositoryMockUpdateAccessTokenParamPtrs{} + } + mmUpdateAccessToken.defaultExpectation.paramPtrs.refreshToken = &refreshToken + mmUpdateAccessToken.defaultExpectation.expectationOrigins.originRefreshToken = minimock.CallerInfo(1) + + return mmUpdateAccessToken +} + +// ExpectNewAccessTokenParam3 sets up expected param newAccessToken for SessionRepository.UpdateAccessToken +func (mmUpdateAccessToken *mSessionRepositoryMockUpdateAccessToken) ExpectNewAccessTokenParam3(newAccessToken string) *mSessionRepositoryMockUpdateAccessToken { + if mmUpdateAccessToken.mock.funcUpdateAccessToken != nil { + mmUpdateAccessToken.mock.t.Fatalf("SessionRepositoryMock.UpdateAccessToken mock is already set by Set") + } + + if mmUpdateAccessToken.defaultExpectation == nil { + mmUpdateAccessToken.defaultExpectation = &SessionRepositoryMockUpdateAccessTokenExpectation{} + } + + if mmUpdateAccessToken.defaultExpectation.params != nil { + mmUpdateAccessToken.mock.t.Fatalf("SessionRepositoryMock.UpdateAccessToken mock is already set by Expect") + } + + if mmUpdateAccessToken.defaultExpectation.paramPtrs == nil { + mmUpdateAccessToken.defaultExpectation.paramPtrs = &SessionRepositoryMockUpdateAccessTokenParamPtrs{} + } + mmUpdateAccessToken.defaultExpectation.paramPtrs.newAccessToken = &newAccessToken + mmUpdateAccessToken.defaultExpectation.expectationOrigins.originNewAccessToken = minimock.CallerInfo(1) + + return mmUpdateAccessToken +} + +// Inspect accepts an inspector function that has same arguments as the SessionRepository.UpdateAccessToken +func (mmUpdateAccessToken *mSessionRepositoryMockUpdateAccessToken) Inspect(f func(ctx context.Context, refreshToken string, newAccessToken string)) *mSessionRepositoryMockUpdateAccessToken { + if mmUpdateAccessToken.mock.inspectFuncUpdateAccessToken != nil { + mmUpdateAccessToken.mock.t.Fatalf("Inspect function is already set for SessionRepositoryMock.UpdateAccessToken") + } + + mmUpdateAccessToken.mock.inspectFuncUpdateAccessToken = f + + return mmUpdateAccessToken +} + +// Return sets up results that will be returned by SessionRepository.UpdateAccessToken +func (mmUpdateAccessToken *mSessionRepositoryMockUpdateAccessToken) Return(err error) *SessionRepositoryMock { + if mmUpdateAccessToken.mock.funcUpdateAccessToken != nil { + mmUpdateAccessToken.mock.t.Fatalf("SessionRepositoryMock.UpdateAccessToken mock is already set by Set") + } + + if mmUpdateAccessToken.defaultExpectation == nil { + mmUpdateAccessToken.defaultExpectation = &SessionRepositoryMockUpdateAccessTokenExpectation{mock: mmUpdateAccessToken.mock} + } + mmUpdateAccessToken.defaultExpectation.results = &SessionRepositoryMockUpdateAccessTokenResults{err} + mmUpdateAccessToken.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmUpdateAccessToken.mock +} + +// Set uses given function f to mock the SessionRepository.UpdateAccessToken method +func (mmUpdateAccessToken *mSessionRepositoryMockUpdateAccessToken) Set(f func(ctx context.Context, refreshToken string, newAccessToken string) (err error)) *SessionRepositoryMock { + if mmUpdateAccessToken.defaultExpectation != nil { + mmUpdateAccessToken.mock.t.Fatalf("Default expectation is already set for the SessionRepository.UpdateAccessToken method") + } + + if len(mmUpdateAccessToken.expectations) > 0 { + mmUpdateAccessToken.mock.t.Fatalf("Some expectations are already set for the SessionRepository.UpdateAccessToken method") + } + + mmUpdateAccessToken.mock.funcUpdateAccessToken = f + mmUpdateAccessToken.mock.funcUpdateAccessTokenOrigin = minimock.CallerInfo(1) + return mmUpdateAccessToken.mock +} + +// When sets expectation for the SessionRepository.UpdateAccessToken which will trigger the result defined by the following +// Then helper +func (mmUpdateAccessToken *mSessionRepositoryMockUpdateAccessToken) When(ctx context.Context, refreshToken string, newAccessToken string) *SessionRepositoryMockUpdateAccessTokenExpectation { + if mmUpdateAccessToken.mock.funcUpdateAccessToken != nil { + mmUpdateAccessToken.mock.t.Fatalf("SessionRepositoryMock.UpdateAccessToken mock is already set by Set") + } + + expectation := &SessionRepositoryMockUpdateAccessTokenExpectation{ + mock: mmUpdateAccessToken.mock, + params: &SessionRepositoryMockUpdateAccessTokenParams{ctx, refreshToken, newAccessToken}, + expectationOrigins: SessionRepositoryMockUpdateAccessTokenExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmUpdateAccessToken.expectations = append(mmUpdateAccessToken.expectations, expectation) + return expectation +} + +// Then sets up SessionRepository.UpdateAccessToken return parameters for the expectation previously defined by the When method +func (e *SessionRepositoryMockUpdateAccessTokenExpectation) Then(err error) *SessionRepositoryMock { + e.results = &SessionRepositoryMockUpdateAccessTokenResults{err} + return e.mock +} + +// Times sets number of times SessionRepository.UpdateAccessToken should be invoked +func (mmUpdateAccessToken *mSessionRepositoryMockUpdateAccessToken) Times(n uint64) *mSessionRepositoryMockUpdateAccessToken { + if n == 0 { + mmUpdateAccessToken.mock.t.Fatalf("Times of SessionRepositoryMock.UpdateAccessToken mock can not be zero") + } + mm_atomic.StoreUint64(&mmUpdateAccessToken.expectedInvocations, n) + mmUpdateAccessToken.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmUpdateAccessToken +} + +func (mmUpdateAccessToken *mSessionRepositoryMockUpdateAccessToken) invocationsDone() bool { + if len(mmUpdateAccessToken.expectations) == 0 && mmUpdateAccessToken.defaultExpectation == nil && mmUpdateAccessToken.mock.funcUpdateAccessToken == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmUpdateAccessToken.mock.afterUpdateAccessTokenCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmUpdateAccessToken.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// UpdateAccessToken implements mm_repository.SessionRepository +func (mmUpdateAccessToken *SessionRepositoryMock) UpdateAccessToken(ctx context.Context, refreshToken string, newAccessToken string) (err error) { + mm_atomic.AddUint64(&mmUpdateAccessToken.beforeUpdateAccessTokenCounter, 1) + defer mm_atomic.AddUint64(&mmUpdateAccessToken.afterUpdateAccessTokenCounter, 1) + + mmUpdateAccessToken.t.Helper() + + if mmUpdateAccessToken.inspectFuncUpdateAccessToken != nil { + mmUpdateAccessToken.inspectFuncUpdateAccessToken(ctx, refreshToken, newAccessToken) + } + + mm_params := SessionRepositoryMockUpdateAccessTokenParams{ctx, refreshToken, newAccessToken} + + // Record call args + mmUpdateAccessToken.UpdateAccessTokenMock.mutex.Lock() + mmUpdateAccessToken.UpdateAccessTokenMock.callArgs = append(mmUpdateAccessToken.UpdateAccessTokenMock.callArgs, &mm_params) + mmUpdateAccessToken.UpdateAccessTokenMock.mutex.Unlock() + + for _, e := range mmUpdateAccessToken.UpdateAccessTokenMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.err + } + } + + if mmUpdateAccessToken.UpdateAccessTokenMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmUpdateAccessToken.UpdateAccessTokenMock.defaultExpectation.Counter, 1) + mm_want := mmUpdateAccessToken.UpdateAccessTokenMock.defaultExpectation.params + mm_want_ptrs := mmUpdateAccessToken.UpdateAccessTokenMock.defaultExpectation.paramPtrs + + mm_got := SessionRepositoryMockUpdateAccessTokenParams{ctx, refreshToken, newAccessToken} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmUpdateAccessToken.t.Errorf("SessionRepositoryMock.UpdateAccessToken got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmUpdateAccessToken.UpdateAccessTokenMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.refreshToken != nil && !minimock.Equal(*mm_want_ptrs.refreshToken, mm_got.refreshToken) { + mmUpdateAccessToken.t.Errorf("SessionRepositoryMock.UpdateAccessToken got unexpected parameter refreshToken, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmUpdateAccessToken.UpdateAccessTokenMock.defaultExpectation.expectationOrigins.originRefreshToken, *mm_want_ptrs.refreshToken, mm_got.refreshToken, minimock.Diff(*mm_want_ptrs.refreshToken, mm_got.refreshToken)) + } + + if mm_want_ptrs.newAccessToken != nil && !minimock.Equal(*mm_want_ptrs.newAccessToken, mm_got.newAccessToken) { + mmUpdateAccessToken.t.Errorf("SessionRepositoryMock.UpdateAccessToken got unexpected parameter newAccessToken, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmUpdateAccessToken.UpdateAccessTokenMock.defaultExpectation.expectationOrigins.originNewAccessToken, *mm_want_ptrs.newAccessToken, mm_got.newAccessToken, minimock.Diff(*mm_want_ptrs.newAccessToken, mm_got.newAccessToken)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmUpdateAccessToken.t.Errorf("SessionRepositoryMock.UpdateAccessToken got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmUpdateAccessToken.UpdateAccessTokenMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmUpdateAccessToken.UpdateAccessTokenMock.defaultExpectation.results + if mm_results == nil { + mmUpdateAccessToken.t.Fatal("No results are set for the SessionRepositoryMock.UpdateAccessToken") + } + return (*mm_results).err + } + if mmUpdateAccessToken.funcUpdateAccessToken != nil { + return mmUpdateAccessToken.funcUpdateAccessToken(ctx, refreshToken, newAccessToken) + } + mmUpdateAccessToken.t.Fatalf("Unexpected call to SessionRepositoryMock.UpdateAccessToken. %v %v %v", ctx, refreshToken, newAccessToken) + return +} + +// UpdateAccessTokenAfterCounter returns a count of finished SessionRepositoryMock.UpdateAccessToken invocations +func (mmUpdateAccessToken *SessionRepositoryMock) UpdateAccessTokenAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmUpdateAccessToken.afterUpdateAccessTokenCounter) +} + +// UpdateAccessTokenBeforeCounter returns a count of SessionRepositoryMock.UpdateAccessToken invocations +func (mmUpdateAccessToken *SessionRepositoryMock) UpdateAccessTokenBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmUpdateAccessToken.beforeUpdateAccessTokenCounter) +} + +// Calls returns a list of arguments used in each call to SessionRepositoryMock.UpdateAccessToken. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmUpdateAccessToken *mSessionRepositoryMockUpdateAccessToken) Calls() []*SessionRepositoryMockUpdateAccessTokenParams { + mmUpdateAccessToken.mutex.RLock() + + argCopy := make([]*SessionRepositoryMockUpdateAccessTokenParams, len(mmUpdateAccessToken.callArgs)) + copy(argCopy, mmUpdateAccessToken.callArgs) + + mmUpdateAccessToken.mutex.RUnlock() + + return argCopy +} + +// MinimockUpdateAccessTokenDone returns true if the count of the UpdateAccessToken invocations corresponds +// the number of defined expectations +func (m *SessionRepositoryMock) MinimockUpdateAccessTokenDone() bool { + if m.UpdateAccessTokenMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.UpdateAccessTokenMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.UpdateAccessTokenMock.invocationsDone() +} + +// MinimockUpdateAccessTokenInspect logs each unmet expectation +func (m *SessionRepositoryMock) MinimockUpdateAccessTokenInspect() { + for _, e := range m.UpdateAccessTokenMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to SessionRepositoryMock.UpdateAccessToken at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterUpdateAccessTokenCounter := mm_atomic.LoadUint64(&m.afterUpdateAccessTokenCounter) + // if default expectation was set then invocations count should be greater than zero + if m.UpdateAccessTokenMock.defaultExpectation != nil && afterUpdateAccessTokenCounter < 1 { + if m.UpdateAccessTokenMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to SessionRepositoryMock.UpdateAccessToken at\n%s", m.UpdateAccessTokenMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to SessionRepositoryMock.UpdateAccessToken at\n%s with params: %#v", m.UpdateAccessTokenMock.defaultExpectation.expectationOrigins.origin, *m.UpdateAccessTokenMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcUpdateAccessToken != nil && afterUpdateAccessTokenCounter < 1 { + m.t.Errorf("Expected call to SessionRepositoryMock.UpdateAccessToken at\n%s", m.funcUpdateAccessTokenOrigin) + } + + if !m.UpdateAccessTokenMock.invocationsDone() && afterUpdateAccessTokenCounter > 0 { + m.t.Errorf("Expected %d calls to SessionRepositoryMock.UpdateAccessToken at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.UpdateAccessTokenMock.expectedInvocations), m.UpdateAccessTokenMock.expectedInvocationsOrigin, afterUpdateAccessTokenCounter) + } +} + +// MinimockFinish checks that all mocked methods have been called the expected number of times +func (m *SessionRepositoryMock) MinimockFinish() { + m.finishOnce.Do(func() { + if !m.minimockDone() { + m.MinimockCreateInspect() + + m.MinimockDeleteExpiredInspect() + + m.MinimockFindByRefreshTokenInspect() + + m.MinimockRevokeInspect() + + m.MinimockUpdateAccessTokenInspect() + } + }) +} + +// MinimockWait waits for all mocked methods to be called the expected number of times +func (m *SessionRepositoryMock) MinimockWait(timeout mm_time.Duration) { + timeoutCh := mm_time.After(timeout) + for { + if m.minimockDone() { + return + } + select { + case <-timeoutCh: + m.MinimockFinish() + return + case <-mm_time.After(10 * mm_time.Millisecond): + } + } +} + +func (m *SessionRepositoryMock) minimockDone() bool { + done := true + return done && + m.MinimockCreateDone() && + m.MinimockDeleteExpiredDone() && + m.MinimockFindByRefreshTokenDone() && + m.MinimockRevokeDone() && + m.MinimockUpdateAccessTokenDone() +} diff --git a/internal/mocks/supplier_repository_mock.go b/internal/mocks/supplier_repository_mock.go new file mode 100644 index 0000000..fde4942 --- /dev/null +++ b/internal/mocks/supplier_repository_mock.go @@ -0,0 +1,1160 @@ +// Code generated by http://github.com/gojuno/minimock (v3.4.7). DO NOT EDIT. + +package mocks + +//go:generate minimock -i smart-search-back/internal/repository.SupplierRepository -o supplier_repository_mock.go -n SupplierRepositoryMock -p mocks + +import ( + "context" + "smart-search-back/internal/model" + "sync" + mm_atomic "sync/atomic" + mm_time "time" + + "github.com/gojuno/minimock/v3" + "github.com/google/uuid" +) + +// SupplierRepositoryMock implements mm_repository.SupplierRepository +type SupplierRepositoryMock struct { + t minimock.Tester + finishOnce sync.Once + + funcBulkInsert func(ctx context.Context, requestID uuid.UUID, suppliers []*model.Supplier) (err error) + funcBulkInsertOrigin string + inspectFuncBulkInsert func(ctx context.Context, requestID uuid.UUID, suppliers []*model.Supplier) + afterBulkInsertCounter uint64 + beforeBulkInsertCounter uint64 + BulkInsertMock mSupplierRepositoryMockBulkInsert + + funcDeleteByRequestID func(ctx context.Context, requestID uuid.UUID) (err error) + funcDeleteByRequestIDOrigin string + inspectFuncDeleteByRequestID func(ctx context.Context, requestID uuid.UUID) + afterDeleteByRequestIDCounter uint64 + beforeDeleteByRequestIDCounter uint64 + DeleteByRequestIDMock mSupplierRepositoryMockDeleteByRequestID + + funcGetByRequestID func(ctx context.Context, requestID uuid.UUID) (spa1 []*model.Supplier, err error) + funcGetByRequestIDOrigin string + inspectFuncGetByRequestID func(ctx context.Context, requestID uuid.UUID) + afterGetByRequestIDCounter uint64 + beforeGetByRequestIDCounter uint64 + GetByRequestIDMock mSupplierRepositoryMockGetByRequestID +} + +// NewSupplierRepositoryMock returns a mock for mm_repository.SupplierRepository +func NewSupplierRepositoryMock(t minimock.Tester) *SupplierRepositoryMock { + m := &SupplierRepositoryMock{t: t} + + if controller, ok := t.(minimock.MockController); ok { + controller.RegisterMocker(m) + } + + m.BulkInsertMock = mSupplierRepositoryMockBulkInsert{mock: m} + m.BulkInsertMock.callArgs = []*SupplierRepositoryMockBulkInsertParams{} + + m.DeleteByRequestIDMock = mSupplierRepositoryMockDeleteByRequestID{mock: m} + m.DeleteByRequestIDMock.callArgs = []*SupplierRepositoryMockDeleteByRequestIDParams{} + + m.GetByRequestIDMock = mSupplierRepositoryMockGetByRequestID{mock: m} + m.GetByRequestIDMock.callArgs = []*SupplierRepositoryMockGetByRequestIDParams{} + + t.Cleanup(m.MinimockFinish) + + return m +} + +type mSupplierRepositoryMockBulkInsert struct { + optional bool + mock *SupplierRepositoryMock + defaultExpectation *SupplierRepositoryMockBulkInsertExpectation + expectations []*SupplierRepositoryMockBulkInsertExpectation + + callArgs []*SupplierRepositoryMockBulkInsertParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// SupplierRepositoryMockBulkInsertExpectation specifies expectation struct of the SupplierRepository.BulkInsert +type SupplierRepositoryMockBulkInsertExpectation struct { + mock *SupplierRepositoryMock + params *SupplierRepositoryMockBulkInsertParams + paramPtrs *SupplierRepositoryMockBulkInsertParamPtrs + expectationOrigins SupplierRepositoryMockBulkInsertExpectationOrigins + results *SupplierRepositoryMockBulkInsertResults + returnOrigin string + Counter uint64 +} + +// SupplierRepositoryMockBulkInsertParams contains parameters of the SupplierRepository.BulkInsert +type SupplierRepositoryMockBulkInsertParams struct { + ctx context.Context + requestID uuid.UUID + suppliers []*model.Supplier +} + +// SupplierRepositoryMockBulkInsertParamPtrs contains pointers to parameters of the SupplierRepository.BulkInsert +type SupplierRepositoryMockBulkInsertParamPtrs struct { + ctx *context.Context + requestID *uuid.UUID + suppliers *[]*model.Supplier +} + +// SupplierRepositoryMockBulkInsertResults contains results of the SupplierRepository.BulkInsert +type SupplierRepositoryMockBulkInsertResults struct { + err error +} + +// SupplierRepositoryMockBulkInsertOrigins contains origins of expectations of the SupplierRepository.BulkInsert +type SupplierRepositoryMockBulkInsertExpectationOrigins struct { + origin string + originCtx string + originRequestID string + originSuppliers string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmBulkInsert *mSupplierRepositoryMockBulkInsert) Optional() *mSupplierRepositoryMockBulkInsert { + mmBulkInsert.optional = true + return mmBulkInsert +} + +// Expect sets up expected params for SupplierRepository.BulkInsert +func (mmBulkInsert *mSupplierRepositoryMockBulkInsert) Expect(ctx context.Context, requestID uuid.UUID, suppliers []*model.Supplier) *mSupplierRepositoryMockBulkInsert { + if mmBulkInsert.mock.funcBulkInsert != nil { + mmBulkInsert.mock.t.Fatalf("SupplierRepositoryMock.BulkInsert mock is already set by Set") + } + + if mmBulkInsert.defaultExpectation == nil { + mmBulkInsert.defaultExpectation = &SupplierRepositoryMockBulkInsertExpectation{} + } + + if mmBulkInsert.defaultExpectation.paramPtrs != nil { + mmBulkInsert.mock.t.Fatalf("SupplierRepositoryMock.BulkInsert mock is already set by ExpectParams functions") + } + + mmBulkInsert.defaultExpectation.params = &SupplierRepositoryMockBulkInsertParams{ctx, requestID, suppliers} + mmBulkInsert.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmBulkInsert.expectations { + if minimock.Equal(e.params, mmBulkInsert.defaultExpectation.params) { + mmBulkInsert.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmBulkInsert.defaultExpectation.params) + } + } + + return mmBulkInsert +} + +// ExpectCtxParam1 sets up expected param ctx for SupplierRepository.BulkInsert +func (mmBulkInsert *mSupplierRepositoryMockBulkInsert) ExpectCtxParam1(ctx context.Context) *mSupplierRepositoryMockBulkInsert { + if mmBulkInsert.mock.funcBulkInsert != nil { + mmBulkInsert.mock.t.Fatalf("SupplierRepositoryMock.BulkInsert mock is already set by Set") + } + + if mmBulkInsert.defaultExpectation == nil { + mmBulkInsert.defaultExpectation = &SupplierRepositoryMockBulkInsertExpectation{} + } + + if mmBulkInsert.defaultExpectation.params != nil { + mmBulkInsert.mock.t.Fatalf("SupplierRepositoryMock.BulkInsert mock is already set by Expect") + } + + if mmBulkInsert.defaultExpectation.paramPtrs == nil { + mmBulkInsert.defaultExpectation.paramPtrs = &SupplierRepositoryMockBulkInsertParamPtrs{} + } + mmBulkInsert.defaultExpectation.paramPtrs.ctx = &ctx + mmBulkInsert.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmBulkInsert +} + +// ExpectRequestIDParam2 sets up expected param requestID for SupplierRepository.BulkInsert +func (mmBulkInsert *mSupplierRepositoryMockBulkInsert) ExpectRequestIDParam2(requestID uuid.UUID) *mSupplierRepositoryMockBulkInsert { + if mmBulkInsert.mock.funcBulkInsert != nil { + mmBulkInsert.mock.t.Fatalf("SupplierRepositoryMock.BulkInsert mock is already set by Set") + } + + if mmBulkInsert.defaultExpectation == nil { + mmBulkInsert.defaultExpectation = &SupplierRepositoryMockBulkInsertExpectation{} + } + + if mmBulkInsert.defaultExpectation.params != nil { + mmBulkInsert.mock.t.Fatalf("SupplierRepositoryMock.BulkInsert mock is already set by Expect") + } + + if mmBulkInsert.defaultExpectation.paramPtrs == nil { + mmBulkInsert.defaultExpectation.paramPtrs = &SupplierRepositoryMockBulkInsertParamPtrs{} + } + mmBulkInsert.defaultExpectation.paramPtrs.requestID = &requestID + mmBulkInsert.defaultExpectation.expectationOrigins.originRequestID = minimock.CallerInfo(1) + + return mmBulkInsert +} + +// ExpectSuppliersParam3 sets up expected param suppliers for SupplierRepository.BulkInsert +func (mmBulkInsert *mSupplierRepositoryMockBulkInsert) ExpectSuppliersParam3(suppliers []*model.Supplier) *mSupplierRepositoryMockBulkInsert { + if mmBulkInsert.mock.funcBulkInsert != nil { + mmBulkInsert.mock.t.Fatalf("SupplierRepositoryMock.BulkInsert mock is already set by Set") + } + + if mmBulkInsert.defaultExpectation == nil { + mmBulkInsert.defaultExpectation = &SupplierRepositoryMockBulkInsertExpectation{} + } + + if mmBulkInsert.defaultExpectation.params != nil { + mmBulkInsert.mock.t.Fatalf("SupplierRepositoryMock.BulkInsert mock is already set by Expect") + } + + if mmBulkInsert.defaultExpectation.paramPtrs == nil { + mmBulkInsert.defaultExpectation.paramPtrs = &SupplierRepositoryMockBulkInsertParamPtrs{} + } + mmBulkInsert.defaultExpectation.paramPtrs.suppliers = &suppliers + mmBulkInsert.defaultExpectation.expectationOrigins.originSuppliers = minimock.CallerInfo(1) + + return mmBulkInsert +} + +// Inspect accepts an inspector function that has same arguments as the SupplierRepository.BulkInsert +func (mmBulkInsert *mSupplierRepositoryMockBulkInsert) Inspect(f func(ctx context.Context, requestID uuid.UUID, suppliers []*model.Supplier)) *mSupplierRepositoryMockBulkInsert { + if mmBulkInsert.mock.inspectFuncBulkInsert != nil { + mmBulkInsert.mock.t.Fatalf("Inspect function is already set for SupplierRepositoryMock.BulkInsert") + } + + mmBulkInsert.mock.inspectFuncBulkInsert = f + + return mmBulkInsert +} + +// Return sets up results that will be returned by SupplierRepository.BulkInsert +func (mmBulkInsert *mSupplierRepositoryMockBulkInsert) Return(err error) *SupplierRepositoryMock { + if mmBulkInsert.mock.funcBulkInsert != nil { + mmBulkInsert.mock.t.Fatalf("SupplierRepositoryMock.BulkInsert mock is already set by Set") + } + + if mmBulkInsert.defaultExpectation == nil { + mmBulkInsert.defaultExpectation = &SupplierRepositoryMockBulkInsertExpectation{mock: mmBulkInsert.mock} + } + mmBulkInsert.defaultExpectation.results = &SupplierRepositoryMockBulkInsertResults{err} + mmBulkInsert.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmBulkInsert.mock +} + +// Set uses given function f to mock the SupplierRepository.BulkInsert method +func (mmBulkInsert *mSupplierRepositoryMockBulkInsert) Set(f func(ctx context.Context, requestID uuid.UUID, suppliers []*model.Supplier) (err error)) *SupplierRepositoryMock { + if mmBulkInsert.defaultExpectation != nil { + mmBulkInsert.mock.t.Fatalf("Default expectation is already set for the SupplierRepository.BulkInsert method") + } + + if len(mmBulkInsert.expectations) > 0 { + mmBulkInsert.mock.t.Fatalf("Some expectations are already set for the SupplierRepository.BulkInsert method") + } + + mmBulkInsert.mock.funcBulkInsert = f + mmBulkInsert.mock.funcBulkInsertOrigin = minimock.CallerInfo(1) + return mmBulkInsert.mock +} + +// When sets expectation for the SupplierRepository.BulkInsert which will trigger the result defined by the following +// Then helper +func (mmBulkInsert *mSupplierRepositoryMockBulkInsert) When(ctx context.Context, requestID uuid.UUID, suppliers []*model.Supplier) *SupplierRepositoryMockBulkInsertExpectation { + if mmBulkInsert.mock.funcBulkInsert != nil { + mmBulkInsert.mock.t.Fatalf("SupplierRepositoryMock.BulkInsert mock is already set by Set") + } + + expectation := &SupplierRepositoryMockBulkInsertExpectation{ + mock: mmBulkInsert.mock, + params: &SupplierRepositoryMockBulkInsertParams{ctx, requestID, suppliers}, + expectationOrigins: SupplierRepositoryMockBulkInsertExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmBulkInsert.expectations = append(mmBulkInsert.expectations, expectation) + return expectation +} + +// Then sets up SupplierRepository.BulkInsert return parameters for the expectation previously defined by the When method +func (e *SupplierRepositoryMockBulkInsertExpectation) Then(err error) *SupplierRepositoryMock { + e.results = &SupplierRepositoryMockBulkInsertResults{err} + return e.mock +} + +// Times sets number of times SupplierRepository.BulkInsert should be invoked +func (mmBulkInsert *mSupplierRepositoryMockBulkInsert) Times(n uint64) *mSupplierRepositoryMockBulkInsert { + if n == 0 { + mmBulkInsert.mock.t.Fatalf("Times of SupplierRepositoryMock.BulkInsert mock can not be zero") + } + mm_atomic.StoreUint64(&mmBulkInsert.expectedInvocations, n) + mmBulkInsert.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmBulkInsert +} + +func (mmBulkInsert *mSupplierRepositoryMockBulkInsert) invocationsDone() bool { + if len(mmBulkInsert.expectations) == 0 && mmBulkInsert.defaultExpectation == nil && mmBulkInsert.mock.funcBulkInsert == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmBulkInsert.mock.afterBulkInsertCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmBulkInsert.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// BulkInsert implements mm_repository.SupplierRepository +func (mmBulkInsert *SupplierRepositoryMock) BulkInsert(ctx context.Context, requestID uuid.UUID, suppliers []*model.Supplier) (err error) { + mm_atomic.AddUint64(&mmBulkInsert.beforeBulkInsertCounter, 1) + defer mm_atomic.AddUint64(&mmBulkInsert.afterBulkInsertCounter, 1) + + mmBulkInsert.t.Helper() + + if mmBulkInsert.inspectFuncBulkInsert != nil { + mmBulkInsert.inspectFuncBulkInsert(ctx, requestID, suppliers) + } + + mm_params := SupplierRepositoryMockBulkInsertParams{ctx, requestID, suppliers} + + // Record call args + mmBulkInsert.BulkInsertMock.mutex.Lock() + mmBulkInsert.BulkInsertMock.callArgs = append(mmBulkInsert.BulkInsertMock.callArgs, &mm_params) + mmBulkInsert.BulkInsertMock.mutex.Unlock() + + for _, e := range mmBulkInsert.BulkInsertMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.err + } + } + + if mmBulkInsert.BulkInsertMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmBulkInsert.BulkInsertMock.defaultExpectation.Counter, 1) + mm_want := mmBulkInsert.BulkInsertMock.defaultExpectation.params + mm_want_ptrs := mmBulkInsert.BulkInsertMock.defaultExpectation.paramPtrs + + mm_got := SupplierRepositoryMockBulkInsertParams{ctx, requestID, suppliers} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmBulkInsert.t.Errorf("SupplierRepositoryMock.BulkInsert got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmBulkInsert.BulkInsertMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.requestID != nil && !minimock.Equal(*mm_want_ptrs.requestID, mm_got.requestID) { + mmBulkInsert.t.Errorf("SupplierRepositoryMock.BulkInsert got unexpected parameter requestID, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmBulkInsert.BulkInsertMock.defaultExpectation.expectationOrigins.originRequestID, *mm_want_ptrs.requestID, mm_got.requestID, minimock.Diff(*mm_want_ptrs.requestID, mm_got.requestID)) + } + + if mm_want_ptrs.suppliers != nil && !minimock.Equal(*mm_want_ptrs.suppliers, mm_got.suppliers) { + mmBulkInsert.t.Errorf("SupplierRepositoryMock.BulkInsert got unexpected parameter suppliers, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmBulkInsert.BulkInsertMock.defaultExpectation.expectationOrigins.originSuppliers, *mm_want_ptrs.suppliers, mm_got.suppliers, minimock.Diff(*mm_want_ptrs.suppliers, mm_got.suppliers)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmBulkInsert.t.Errorf("SupplierRepositoryMock.BulkInsert got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmBulkInsert.BulkInsertMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmBulkInsert.BulkInsertMock.defaultExpectation.results + if mm_results == nil { + mmBulkInsert.t.Fatal("No results are set for the SupplierRepositoryMock.BulkInsert") + } + return (*mm_results).err + } + if mmBulkInsert.funcBulkInsert != nil { + return mmBulkInsert.funcBulkInsert(ctx, requestID, suppliers) + } + mmBulkInsert.t.Fatalf("Unexpected call to SupplierRepositoryMock.BulkInsert. %v %v %v", ctx, requestID, suppliers) + return +} + +// BulkInsertAfterCounter returns a count of finished SupplierRepositoryMock.BulkInsert invocations +func (mmBulkInsert *SupplierRepositoryMock) BulkInsertAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmBulkInsert.afterBulkInsertCounter) +} + +// BulkInsertBeforeCounter returns a count of SupplierRepositoryMock.BulkInsert invocations +func (mmBulkInsert *SupplierRepositoryMock) BulkInsertBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmBulkInsert.beforeBulkInsertCounter) +} + +// Calls returns a list of arguments used in each call to SupplierRepositoryMock.BulkInsert. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmBulkInsert *mSupplierRepositoryMockBulkInsert) Calls() []*SupplierRepositoryMockBulkInsertParams { + mmBulkInsert.mutex.RLock() + + argCopy := make([]*SupplierRepositoryMockBulkInsertParams, len(mmBulkInsert.callArgs)) + copy(argCopy, mmBulkInsert.callArgs) + + mmBulkInsert.mutex.RUnlock() + + return argCopy +} + +// MinimockBulkInsertDone returns true if the count of the BulkInsert invocations corresponds +// the number of defined expectations +func (m *SupplierRepositoryMock) MinimockBulkInsertDone() bool { + if m.BulkInsertMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.BulkInsertMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.BulkInsertMock.invocationsDone() +} + +// MinimockBulkInsertInspect logs each unmet expectation +func (m *SupplierRepositoryMock) MinimockBulkInsertInspect() { + for _, e := range m.BulkInsertMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to SupplierRepositoryMock.BulkInsert at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterBulkInsertCounter := mm_atomic.LoadUint64(&m.afterBulkInsertCounter) + // if default expectation was set then invocations count should be greater than zero + if m.BulkInsertMock.defaultExpectation != nil && afterBulkInsertCounter < 1 { + if m.BulkInsertMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to SupplierRepositoryMock.BulkInsert at\n%s", m.BulkInsertMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to SupplierRepositoryMock.BulkInsert at\n%s with params: %#v", m.BulkInsertMock.defaultExpectation.expectationOrigins.origin, *m.BulkInsertMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcBulkInsert != nil && afterBulkInsertCounter < 1 { + m.t.Errorf("Expected call to SupplierRepositoryMock.BulkInsert at\n%s", m.funcBulkInsertOrigin) + } + + if !m.BulkInsertMock.invocationsDone() && afterBulkInsertCounter > 0 { + m.t.Errorf("Expected %d calls to SupplierRepositoryMock.BulkInsert at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.BulkInsertMock.expectedInvocations), m.BulkInsertMock.expectedInvocationsOrigin, afterBulkInsertCounter) + } +} + +type mSupplierRepositoryMockDeleteByRequestID struct { + optional bool + mock *SupplierRepositoryMock + defaultExpectation *SupplierRepositoryMockDeleteByRequestIDExpectation + expectations []*SupplierRepositoryMockDeleteByRequestIDExpectation + + callArgs []*SupplierRepositoryMockDeleteByRequestIDParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// SupplierRepositoryMockDeleteByRequestIDExpectation specifies expectation struct of the SupplierRepository.DeleteByRequestID +type SupplierRepositoryMockDeleteByRequestIDExpectation struct { + mock *SupplierRepositoryMock + params *SupplierRepositoryMockDeleteByRequestIDParams + paramPtrs *SupplierRepositoryMockDeleteByRequestIDParamPtrs + expectationOrigins SupplierRepositoryMockDeleteByRequestIDExpectationOrigins + results *SupplierRepositoryMockDeleteByRequestIDResults + returnOrigin string + Counter uint64 +} + +// SupplierRepositoryMockDeleteByRequestIDParams contains parameters of the SupplierRepository.DeleteByRequestID +type SupplierRepositoryMockDeleteByRequestIDParams struct { + ctx context.Context + requestID uuid.UUID +} + +// SupplierRepositoryMockDeleteByRequestIDParamPtrs contains pointers to parameters of the SupplierRepository.DeleteByRequestID +type SupplierRepositoryMockDeleteByRequestIDParamPtrs struct { + ctx *context.Context + requestID *uuid.UUID +} + +// SupplierRepositoryMockDeleteByRequestIDResults contains results of the SupplierRepository.DeleteByRequestID +type SupplierRepositoryMockDeleteByRequestIDResults struct { + err error +} + +// SupplierRepositoryMockDeleteByRequestIDOrigins contains origins of expectations of the SupplierRepository.DeleteByRequestID +type SupplierRepositoryMockDeleteByRequestIDExpectationOrigins struct { + origin string + originCtx string + originRequestID string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmDeleteByRequestID *mSupplierRepositoryMockDeleteByRequestID) Optional() *mSupplierRepositoryMockDeleteByRequestID { + mmDeleteByRequestID.optional = true + return mmDeleteByRequestID +} + +// Expect sets up expected params for SupplierRepository.DeleteByRequestID +func (mmDeleteByRequestID *mSupplierRepositoryMockDeleteByRequestID) Expect(ctx context.Context, requestID uuid.UUID) *mSupplierRepositoryMockDeleteByRequestID { + if mmDeleteByRequestID.mock.funcDeleteByRequestID != nil { + mmDeleteByRequestID.mock.t.Fatalf("SupplierRepositoryMock.DeleteByRequestID mock is already set by Set") + } + + if mmDeleteByRequestID.defaultExpectation == nil { + mmDeleteByRequestID.defaultExpectation = &SupplierRepositoryMockDeleteByRequestIDExpectation{} + } + + if mmDeleteByRequestID.defaultExpectation.paramPtrs != nil { + mmDeleteByRequestID.mock.t.Fatalf("SupplierRepositoryMock.DeleteByRequestID mock is already set by ExpectParams functions") + } + + mmDeleteByRequestID.defaultExpectation.params = &SupplierRepositoryMockDeleteByRequestIDParams{ctx, requestID} + mmDeleteByRequestID.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmDeleteByRequestID.expectations { + if minimock.Equal(e.params, mmDeleteByRequestID.defaultExpectation.params) { + mmDeleteByRequestID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDeleteByRequestID.defaultExpectation.params) + } + } + + return mmDeleteByRequestID +} + +// ExpectCtxParam1 sets up expected param ctx for SupplierRepository.DeleteByRequestID +func (mmDeleteByRequestID *mSupplierRepositoryMockDeleteByRequestID) ExpectCtxParam1(ctx context.Context) *mSupplierRepositoryMockDeleteByRequestID { + if mmDeleteByRequestID.mock.funcDeleteByRequestID != nil { + mmDeleteByRequestID.mock.t.Fatalf("SupplierRepositoryMock.DeleteByRequestID mock is already set by Set") + } + + if mmDeleteByRequestID.defaultExpectation == nil { + mmDeleteByRequestID.defaultExpectation = &SupplierRepositoryMockDeleteByRequestIDExpectation{} + } + + if mmDeleteByRequestID.defaultExpectation.params != nil { + mmDeleteByRequestID.mock.t.Fatalf("SupplierRepositoryMock.DeleteByRequestID mock is already set by Expect") + } + + if mmDeleteByRequestID.defaultExpectation.paramPtrs == nil { + mmDeleteByRequestID.defaultExpectation.paramPtrs = &SupplierRepositoryMockDeleteByRequestIDParamPtrs{} + } + mmDeleteByRequestID.defaultExpectation.paramPtrs.ctx = &ctx + mmDeleteByRequestID.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmDeleteByRequestID +} + +// ExpectRequestIDParam2 sets up expected param requestID for SupplierRepository.DeleteByRequestID +func (mmDeleteByRequestID *mSupplierRepositoryMockDeleteByRequestID) ExpectRequestIDParam2(requestID uuid.UUID) *mSupplierRepositoryMockDeleteByRequestID { + if mmDeleteByRequestID.mock.funcDeleteByRequestID != nil { + mmDeleteByRequestID.mock.t.Fatalf("SupplierRepositoryMock.DeleteByRequestID mock is already set by Set") + } + + if mmDeleteByRequestID.defaultExpectation == nil { + mmDeleteByRequestID.defaultExpectation = &SupplierRepositoryMockDeleteByRequestIDExpectation{} + } + + if mmDeleteByRequestID.defaultExpectation.params != nil { + mmDeleteByRequestID.mock.t.Fatalf("SupplierRepositoryMock.DeleteByRequestID mock is already set by Expect") + } + + if mmDeleteByRequestID.defaultExpectation.paramPtrs == nil { + mmDeleteByRequestID.defaultExpectation.paramPtrs = &SupplierRepositoryMockDeleteByRequestIDParamPtrs{} + } + mmDeleteByRequestID.defaultExpectation.paramPtrs.requestID = &requestID + mmDeleteByRequestID.defaultExpectation.expectationOrigins.originRequestID = minimock.CallerInfo(1) + + return mmDeleteByRequestID +} + +// Inspect accepts an inspector function that has same arguments as the SupplierRepository.DeleteByRequestID +func (mmDeleteByRequestID *mSupplierRepositoryMockDeleteByRequestID) Inspect(f func(ctx context.Context, requestID uuid.UUID)) *mSupplierRepositoryMockDeleteByRequestID { + if mmDeleteByRequestID.mock.inspectFuncDeleteByRequestID != nil { + mmDeleteByRequestID.mock.t.Fatalf("Inspect function is already set for SupplierRepositoryMock.DeleteByRequestID") + } + + mmDeleteByRequestID.mock.inspectFuncDeleteByRequestID = f + + return mmDeleteByRequestID +} + +// Return sets up results that will be returned by SupplierRepository.DeleteByRequestID +func (mmDeleteByRequestID *mSupplierRepositoryMockDeleteByRequestID) Return(err error) *SupplierRepositoryMock { + if mmDeleteByRequestID.mock.funcDeleteByRequestID != nil { + mmDeleteByRequestID.mock.t.Fatalf("SupplierRepositoryMock.DeleteByRequestID mock is already set by Set") + } + + if mmDeleteByRequestID.defaultExpectation == nil { + mmDeleteByRequestID.defaultExpectation = &SupplierRepositoryMockDeleteByRequestIDExpectation{mock: mmDeleteByRequestID.mock} + } + mmDeleteByRequestID.defaultExpectation.results = &SupplierRepositoryMockDeleteByRequestIDResults{err} + mmDeleteByRequestID.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmDeleteByRequestID.mock +} + +// Set uses given function f to mock the SupplierRepository.DeleteByRequestID method +func (mmDeleteByRequestID *mSupplierRepositoryMockDeleteByRequestID) Set(f func(ctx context.Context, requestID uuid.UUID) (err error)) *SupplierRepositoryMock { + if mmDeleteByRequestID.defaultExpectation != nil { + mmDeleteByRequestID.mock.t.Fatalf("Default expectation is already set for the SupplierRepository.DeleteByRequestID method") + } + + if len(mmDeleteByRequestID.expectations) > 0 { + mmDeleteByRequestID.mock.t.Fatalf("Some expectations are already set for the SupplierRepository.DeleteByRequestID method") + } + + mmDeleteByRequestID.mock.funcDeleteByRequestID = f + mmDeleteByRequestID.mock.funcDeleteByRequestIDOrigin = minimock.CallerInfo(1) + return mmDeleteByRequestID.mock +} + +// When sets expectation for the SupplierRepository.DeleteByRequestID which will trigger the result defined by the following +// Then helper +func (mmDeleteByRequestID *mSupplierRepositoryMockDeleteByRequestID) When(ctx context.Context, requestID uuid.UUID) *SupplierRepositoryMockDeleteByRequestIDExpectation { + if mmDeleteByRequestID.mock.funcDeleteByRequestID != nil { + mmDeleteByRequestID.mock.t.Fatalf("SupplierRepositoryMock.DeleteByRequestID mock is already set by Set") + } + + expectation := &SupplierRepositoryMockDeleteByRequestIDExpectation{ + mock: mmDeleteByRequestID.mock, + params: &SupplierRepositoryMockDeleteByRequestIDParams{ctx, requestID}, + expectationOrigins: SupplierRepositoryMockDeleteByRequestIDExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmDeleteByRequestID.expectations = append(mmDeleteByRequestID.expectations, expectation) + return expectation +} + +// Then sets up SupplierRepository.DeleteByRequestID return parameters for the expectation previously defined by the When method +func (e *SupplierRepositoryMockDeleteByRequestIDExpectation) Then(err error) *SupplierRepositoryMock { + e.results = &SupplierRepositoryMockDeleteByRequestIDResults{err} + return e.mock +} + +// Times sets number of times SupplierRepository.DeleteByRequestID should be invoked +func (mmDeleteByRequestID *mSupplierRepositoryMockDeleteByRequestID) Times(n uint64) *mSupplierRepositoryMockDeleteByRequestID { + if n == 0 { + mmDeleteByRequestID.mock.t.Fatalf("Times of SupplierRepositoryMock.DeleteByRequestID mock can not be zero") + } + mm_atomic.StoreUint64(&mmDeleteByRequestID.expectedInvocations, n) + mmDeleteByRequestID.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmDeleteByRequestID +} + +func (mmDeleteByRequestID *mSupplierRepositoryMockDeleteByRequestID) invocationsDone() bool { + if len(mmDeleteByRequestID.expectations) == 0 && mmDeleteByRequestID.defaultExpectation == nil && mmDeleteByRequestID.mock.funcDeleteByRequestID == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmDeleteByRequestID.mock.afterDeleteByRequestIDCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmDeleteByRequestID.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// DeleteByRequestID implements mm_repository.SupplierRepository +func (mmDeleteByRequestID *SupplierRepositoryMock) DeleteByRequestID(ctx context.Context, requestID uuid.UUID) (err error) { + mm_atomic.AddUint64(&mmDeleteByRequestID.beforeDeleteByRequestIDCounter, 1) + defer mm_atomic.AddUint64(&mmDeleteByRequestID.afterDeleteByRequestIDCounter, 1) + + mmDeleteByRequestID.t.Helper() + + if mmDeleteByRequestID.inspectFuncDeleteByRequestID != nil { + mmDeleteByRequestID.inspectFuncDeleteByRequestID(ctx, requestID) + } + + mm_params := SupplierRepositoryMockDeleteByRequestIDParams{ctx, requestID} + + // Record call args + mmDeleteByRequestID.DeleteByRequestIDMock.mutex.Lock() + mmDeleteByRequestID.DeleteByRequestIDMock.callArgs = append(mmDeleteByRequestID.DeleteByRequestIDMock.callArgs, &mm_params) + mmDeleteByRequestID.DeleteByRequestIDMock.mutex.Unlock() + + for _, e := range mmDeleteByRequestID.DeleteByRequestIDMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.err + } + } + + if mmDeleteByRequestID.DeleteByRequestIDMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmDeleteByRequestID.DeleteByRequestIDMock.defaultExpectation.Counter, 1) + mm_want := mmDeleteByRequestID.DeleteByRequestIDMock.defaultExpectation.params + mm_want_ptrs := mmDeleteByRequestID.DeleteByRequestIDMock.defaultExpectation.paramPtrs + + mm_got := SupplierRepositoryMockDeleteByRequestIDParams{ctx, requestID} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmDeleteByRequestID.t.Errorf("SupplierRepositoryMock.DeleteByRequestID got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmDeleteByRequestID.DeleteByRequestIDMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.requestID != nil && !minimock.Equal(*mm_want_ptrs.requestID, mm_got.requestID) { + mmDeleteByRequestID.t.Errorf("SupplierRepositoryMock.DeleteByRequestID got unexpected parameter requestID, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmDeleteByRequestID.DeleteByRequestIDMock.defaultExpectation.expectationOrigins.originRequestID, *mm_want_ptrs.requestID, mm_got.requestID, minimock.Diff(*mm_want_ptrs.requestID, mm_got.requestID)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmDeleteByRequestID.t.Errorf("SupplierRepositoryMock.DeleteByRequestID got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmDeleteByRequestID.DeleteByRequestIDMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmDeleteByRequestID.DeleteByRequestIDMock.defaultExpectation.results + if mm_results == nil { + mmDeleteByRequestID.t.Fatal("No results are set for the SupplierRepositoryMock.DeleteByRequestID") + } + return (*mm_results).err + } + if mmDeleteByRequestID.funcDeleteByRequestID != nil { + return mmDeleteByRequestID.funcDeleteByRequestID(ctx, requestID) + } + mmDeleteByRequestID.t.Fatalf("Unexpected call to SupplierRepositoryMock.DeleteByRequestID. %v %v", ctx, requestID) + return +} + +// DeleteByRequestIDAfterCounter returns a count of finished SupplierRepositoryMock.DeleteByRequestID invocations +func (mmDeleteByRequestID *SupplierRepositoryMock) DeleteByRequestIDAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmDeleteByRequestID.afterDeleteByRequestIDCounter) +} + +// DeleteByRequestIDBeforeCounter returns a count of SupplierRepositoryMock.DeleteByRequestID invocations +func (mmDeleteByRequestID *SupplierRepositoryMock) DeleteByRequestIDBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmDeleteByRequestID.beforeDeleteByRequestIDCounter) +} + +// Calls returns a list of arguments used in each call to SupplierRepositoryMock.DeleteByRequestID. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmDeleteByRequestID *mSupplierRepositoryMockDeleteByRequestID) Calls() []*SupplierRepositoryMockDeleteByRequestIDParams { + mmDeleteByRequestID.mutex.RLock() + + argCopy := make([]*SupplierRepositoryMockDeleteByRequestIDParams, len(mmDeleteByRequestID.callArgs)) + copy(argCopy, mmDeleteByRequestID.callArgs) + + mmDeleteByRequestID.mutex.RUnlock() + + return argCopy +} + +// MinimockDeleteByRequestIDDone returns true if the count of the DeleteByRequestID invocations corresponds +// the number of defined expectations +func (m *SupplierRepositoryMock) MinimockDeleteByRequestIDDone() bool { + if m.DeleteByRequestIDMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.DeleteByRequestIDMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.DeleteByRequestIDMock.invocationsDone() +} + +// MinimockDeleteByRequestIDInspect logs each unmet expectation +func (m *SupplierRepositoryMock) MinimockDeleteByRequestIDInspect() { + for _, e := range m.DeleteByRequestIDMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to SupplierRepositoryMock.DeleteByRequestID at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterDeleteByRequestIDCounter := mm_atomic.LoadUint64(&m.afterDeleteByRequestIDCounter) + // if default expectation was set then invocations count should be greater than zero + if m.DeleteByRequestIDMock.defaultExpectation != nil && afterDeleteByRequestIDCounter < 1 { + if m.DeleteByRequestIDMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to SupplierRepositoryMock.DeleteByRequestID at\n%s", m.DeleteByRequestIDMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to SupplierRepositoryMock.DeleteByRequestID at\n%s with params: %#v", m.DeleteByRequestIDMock.defaultExpectation.expectationOrigins.origin, *m.DeleteByRequestIDMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcDeleteByRequestID != nil && afterDeleteByRequestIDCounter < 1 { + m.t.Errorf("Expected call to SupplierRepositoryMock.DeleteByRequestID at\n%s", m.funcDeleteByRequestIDOrigin) + } + + if !m.DeleteByRequestIDMock.invocationsDone() && afterDeleteByRequestIDCounter > 0 { + m.t.Errorf("Expected %d calls to SupplierRepositoryMock.DeleteByRequestID at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.DeleteByRequestIDMock.expectedInvocations), m.DeleteByRequestIDMock.expectedInvocationsOrigin, afterDeleteByRequestIDCounter) + } +} + +type mSupplierRepositoryMockGetByRequestID struct { + optional bool + mock *SupplierRepositoryMock + defaultExpectation *SupplierRepositoryMockGetByRequestIDExpectation + expectations []*SupplierRepositoryMockGetByRequestIDExpectation + + callArgs []*SupplierRepositoryMockGetByRequestIDParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// SupplierRepositoryMockGetByRequestIDExpectation specifies expectation struct of the SupplierRepository.GetByRequestID +type SupplierRepositoryMockGetByRequestIDExpectation struct { + mock *SupplierRepositoryMock + params *SupplierRepositoryMockGetByRequestIDParams + paramPtrs *SupplierRepositoryMockGetByRequestIDParamPtrs + expectationOrigins SupplierRepositoryMockGetByRequestIDExpectationOrigins + results *SupplierRepositoryMockGetByRequestIDResults + returnOrigin string + Counter uint64 +} + +// SupplierRepositoryMockGetByRequestIDParams contains parameters of the SupplierRepository.GetByRequestID +type SupplierRepositoryMockGetByRequestIDParams struct { + ctx context.Context + requestID uuid.UUID +} + +// SupplierRepositoryMockGetByRequestIDParamPtrs contains pointers to parameters of the SupplierRepository.GetByRequestID +type SupplierRepositoryMockGetByRequestIDParamPtrs struct { + ctx *context.Context + requestID *uuid.UUID +} + +// SupplierRepositoryMockGetByRequestIDResults contains results of the SupplierRepository.GetByRequestID +type SupplierRepositoryMockGetByRequestIDResults struct { + spa1 []*model.Supplier + err error +} + +// SupplierRepositoryMockGetByRequestIDOrigins contains origins of expectations of the SupplierRepository.GetByRequestID +type SupplierRepositoryMockGetByRequestIDExpectationOrigins struct { + origin string + originCtx string + originRequestID string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmGetByRequestID *mSupplierRepositoryMockGetByRequestID) Optional() *mSupplierRepositoryMockGetByRequestID { + mmGetByRequestID.optional = true + return mmGetByRequestID +} + +// Expect sets up expected params for SupplierRepository.GetByRequestID +func (mmGetByRequestID *mSupplierRepositoryMockGetByRequestID) Expect(ctx context.Context, requestID uuid.UUID) *mSupplierRepositoryMockGetByRequestID { + if mmGetByRequestID.mock.funcGetByRequestID != nil { + mmGetByRequestID.mock.t.Fatalf("SupplierRepositoryMock.GetByRequestID mock is already set by Set") + } + + if mmGetByRequestID.defaultExpectation == nil { + mmGetByRequestID.defaultExpectation = &SupplierRepositoryMockGetByRequestIDExpectation{} + } + + if mmGetByRequestID.defaultExpectation.paramPtrs != nil { + mmGetByRequestID.mock.t.Fatalf("SupplierRepositoryMock.GetByRequestID mock is already set by ExpectParams functions") + } + + mmGetByRequestID.defaultExpectation.params = &SupplierRepositoryMockGetByRequestIDParams{ctx, requestID} + mmGetByRequestID.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmGetByRequestID.expectations { + if minimock.Equal(e.params, mmGetByRequestID.defaultExpectation.params) { + mmGetByRequestID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByRequestID.defaultExpectation.params) + } + } + + return mmGetByRequestID +} + +// ExpectCtxParam1 sets up expected param ctx for SupplierRepository.GetByRequestID +func (mmGetByRequestID *mSupplierRepositoryMockGetByRequestID) ExpectCtxParam1(ctx context.Context) *mSupplierRepositoryMockGetByRequestID { + if mmGetByRequestID.mock.funcGetByRequestID != nil { + mmGetByRequestID.mock.t.Fatalf("SupplierRepositoryMock.GetByRequestID mock is already set by Set") + } + + if mmGetByRequestID.defaultExpectation == nil { + mmGetByRequestID.defaultExpectation = &SupplierRepositoryMockGetByRequestIDExpectation{} + } + + if mmGetByRequestID.defaultExpectation.params != nil { + mmGetByRequestID.mock.t.Fatalf("SupplierRepositoryMock.GetByRequestID mock is already set by Expect") + } + + if mmGetByRequestID.defaultExpectation.paramPtrs == nil { + mmGetByRequestID.defaultExpectation.paramPtrs = &SupplierRepositoryMockGetByRequestIDParamPtrs{} + } + mmGetByRequestID.defaultExpectation.paramPtrs.ctx = &ctx + mmGetByRequestID.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmGetByRequestID +} + +// ExpectRequestIDParam2 sets up expected param requestID for SupplierRepository.GetByRequestID +func (mmGetByRequestID *mSupplierRepositoryMockGetByRequestID) ExpectRequestIDParam2(requestID uuid.UUID) *mSupplierRepositoryMockGetByRequestID { + if mmGetByRequestID.mock.funcGetByRequestID != nil { + mmGetByRequestID.mock.t.Fatalf("SupplierRepositoryMock.GetByRequestID mock is already set by Set") + } + + if mmGetByRequestID.defaultExpectation == nil { + mmGetByRequestID.defaultExpectation = &SupplierRepositoryMockGetByRequestIDExpectation{} + } + + if mmGetByRequestID.defaultExpectation.params != nil { + mmGetByRequestID.mock.t.Fatalf("SupplierRepositoryMock.GetByRequestID mock is already set by Expect") + } + + if mmGetByRequestID.defaultExpectation.paramPtrs == nil { + mmGetByRequestID.defaultExpectation.paramPtrs = &SupplierRepositoryMockGetByRequestIDParamPtrs{} + } + mmGetByRequestID.defaultExpectation.paramPtrs.requestID = &requestID + mmGetByRequestID.defaultExpectation.expectationOrigins.originRequestID = minimock.CallerInfo(1) + + return mmGetByRequestID +} + +// Inspect accepts an inspector function that has same arguments as the SupplierRepository.GetByRequestID +func (mmGetByRequestID *mSupplierRepositoryMockGetByRequestID) Inspect(f func(ctx context.Context, requestID uuid.UUID)) *mSupplierRepositoryMockGetByRequestID { + if mmGetByRequestID.mock.inspectFuncGetByRequestID != nil { + mmGetByRequestID.mock.t.Fatalf("Inspect function is already set for SupplierRepositoryMock.GetByRequestID") + } + + mmGetByRequestID.mock.inspectFuncGetByRequestID = f + + return mmGetByRequestID +} + +// Return sets up results that will be returned by SupplierRepository.GetByRequestID +func (mmGetByRequestID *mSupplierRepositoryMockGetByRequestID) Return(spa1 []*model.Supplier, err error) *SupplierRepositoryMock { + if mmGetByRequestID.mock.funcGetByRequestID != nil { + mmGetByRequestID.mock.t.Fatalf("SupplierRepositoryMock.GetByRequestID mock is already set by Set") + } + + if mmGetByRequestID.defaultExpectation == nil { + mmGetByRequestID.defaultExpectation = &SupplierRepositoryMockGetByRequestIDExpectation{mock: mmGetByRequestID.mock} + } + mmGetByRequestID.defaultExpectation.results = &SupplierRepositoryMockGetByRequestIDResults{spa1, err} + mmGetByRequestID.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmGetByRequestID.mock +} + +// Set uses given function f to mock the SupplierRepository.GetByRequestID method +func (mmGetByRequestID *mSupplierRepositoryMockGetByRequestID) Set(f func(ctx context.Context, requestID uuid.UUID) (spa1 []*model.Supplier, err error)) *SupplierRepositoryMock { + if mmGetByRequestID.defaultExpectation != nil { + mmGetByRequestID.mock.t.Fatalf("Default expectation is already set for the SupplierRepository.GetByRequestID method") + } + + if len(mmGetByRequestID.expectations) > 0 { + mmGetByRequestID.mock.t.Fatalf("Some expectations are already set for the SupplierRepository.GetByRequestID method") + } + + mmGetByRequestID.mock.funcGetByRequestID = f + mmGetByRequestID.mock.funcGetByRequestIDOrigin = minimock.CallerInfo(1) + return mmGetByRequestID.mock +} + +// When sets expectation for the SupplierRepository.GetByRequestID which will trigger the result defined by the following +// Then helper +func (mmGetByRequestID *mSupplierRepositoryMockGetByRequestID) When(ctx context.Context, requestID uuid.UUID) *SupplierRepositoryMockGetByRequestIDExpectation { + if mmGetByRequestID.mock.funcGetByRequestID != nil { + mmGetByRequestID.mock.t.Fatalf("SupplierRepositoryMock.GetByRequestID mock is already set by Set") + } + + expectation := &SupplierRepositoryMockGetByRequestIDExpectation{ + mock: mmGetByRequestID.mock, + params: &SupplierRepositoryMockGetByRequestIDParams{ctx, requestID}, + expectationOrigins: SupplierRepositoryMockGetByRequestIDExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmGetByRequestID.expectations = append(mmGetByRequestID.expectations, expectation) + return expectation +} + +// Then sets up SupplierRepository.GetByRequestID return parameters for the expectation previously defined by the When method +func (e *SupplierRepositoryMockGetByRequestIDExpectation) Then(spa1 []*model.Supplier, err error) *SupplierRepositoryMock { + e.results = &SupplierRepositoryMockGetByRequestIDResults{spa1, err} + return e.mock +} + +// Times sets number of times SupplierRepository.GetByRequestID should be invoked +func (mmGetByRequestID *mSupplierRepositoryMockGetByRequestID) Times(n uint64) *mSupplierRepositoryMockGetByRequestID { + if n == 0 { + mmGetByRequestID.mock.t.Fatalf("Times of SupplierRepositoryMock.GetByRequestID mock can not be zero") + } + mm_atomic.StoreUint64(&mmGetByRequestID.expectedInvocations, n) + mmGetByRequestID.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmGetByRequestID +} + +func (mmGetByRequestID *mSupplierRepositoryMockGetByRequestID) invocationsDone() bool { + if len(mmGetByRequestID.expectations) == 0 && mmGetByRequestID.defaultExpectation == nil && mmGetByRequestID.mock.funcGetByRequestID == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmGetByRequestID.mock.afterGetByRequestIDCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmGetByRequestID.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// GetByRequestID implements mm_repository.SupplierRepository +func (mmGetByRequestID *SupplierRepositoryMock) GetByRequestID(ctx context.Context, requestID uuid.UUID) (spa1 []*model.Supplier, err error) { + mm_atomic.AddUint64(&mmGetByRequestID.beforeGetByRequestIDCounter, 1) + defer mm_atomic.AddUint64(&mmGetByRequestID.afterGetByRequestIDCounter, 1) + + mmGetByRequestID.t.Helper() + + if mmGetByRequestID.inspectFuncGetByRequestID != nil { + mmGetByRequestID.inspectFuncGetByRequestID(ctx, requestID) + } + + mm_params := SupplierRepositoryMockGetByRequestIDParams{ctx, requestID} + + // Record call args + mmGetByRequestID.GetByRequestIDMock.mutex.Lock() + mmGetByRequestID.GetByRequestIDMock.callArgs = append(mmGetByRequestID.GetByRequestIDMock.callArgs, &mm_params) + mmGetByRequestID.GetByRequestIDMock.mutex.Unlock() + + for _, e := range mmGetByRequestID.GetByRequestIDMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.spa1, e.results.err + } + } + + if mmGetByRequestID.GetByRequestIDMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmGetByRequestID.GetByRequestIDMock.defaultExpectation.Counter, 1) + mm_want := mmGetByRequestID.GetByRequestIDMock.defaultExpectation.params + mm_want_ptrs := mmGetByRequestID.GetByRequestIDMock.defaultExpectation.paramPtrs + + mm_got := SupplierRepositoryMockGetByRequestIDParams{ctx, requestID} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmGetByRequestID.t.Errorf("SupplierRepositoryMock.GetByRequestID got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetByRequestID.GetByRequestIDMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.requestID != nil && !minimock.Equal(*mm_want_ptrs.requestID, mm_got.requestID) { + mmGetByRequestID.t.Errorf("SupplierRepositoryMock.GetByRequestID got unexpected parameter requestID, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetByRequestID.GetByRequestIDMock.defaultExpectation.expectationOrigins.originRequestID, *mm_want_ptrs.requestID, mm_got.requestID, minimock.Diff(*mm_want_ptrs.requestID, mm_got.requestID)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmGetByRequestID.t.Errorf("SupplierRepositoryMock.GetByRequestID got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetByRequestID.GetByRequestIDMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmGetByRequestID.GetByRequestIDMock.defaultExpectation.results + if mm_results == nil { + mmGetByRequestID.t.Fatal("No results are set for the SupplierRepositoryMock.GetByRequestID") + } + return (*mm_results).spa1, (*mm_results).err + } + if mmGetByRequestID.funcGetByRequestID != nil { + return mmGetByRequestID.funcGetByRequestID(ctx, requestID) + } + mmGetByRequestID.t.Fatalf("Unexpected call to SupplierRepositoryMock.GetByRequestID. %v %v", ctx, requestID) + return +} + +// GetByRequestIDAfterCounter returns a count of finished SupplierRepositoryMock.GetByRequestID invocations +func (mmGetByRequestID *SupplierRepositoryMock) GetByRequestIDAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetByRequestID.afterGetByRequestIDCounter) +} + +// GetByRequestIDBeforeCounter returns a count of SupplierRepositoryMock.GetByRequestID invocations +func (mmGetByRequestID *SupplierRepositoryMock) GetByRequestIDBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetByRequestID.beforeGetByRequestIDCounter) +} + +// Calls returns a list of arguments used in each call to SupplierRepositoryMock.GetByRequestID. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmGetByRequestID *mSupplierRepositoryMockGetByRequestID) Calls() []*SupplierRepositoryMockGetByRequestIDParams { + mmGetByRequestID.mutex.RLock() + + argCopy := make([]*SupplierRepositoryMockGetByRequestIDParams, len(mmGetByRequestID.callArgs)) + copy(argCopy, mmGetByRequestID.callArgs) + + mmGetByRequestID.mutex.RUnlock() + + return argCopy +} + +// MinimockGetByRequestIDDone returns true if the count of the GetByRequestID invocations corresponds +// the number of defined expectations +func (m *SupplierRepositoryMock) MinimockGetByRequestIDDone() bool { + if m.GetByRequestIDMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.GetByRequestIDMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.GetByRequestIDMock.invocationsDone() +} + +// MinimockGetByRequestIDInspect logs each unmet expectation +func (m *SupplierRepositoryMock) MinimockGetByRequestIDInspect() { + for _, e := range m.GetByRequestIDMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to SupplierRepositoryMock.GetByRequestID at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterGetByRequestIDCounter := mm_atomic.LoadUint64(&m.afterGetByRequestIDCounter) + // if default expectation was set then invocations count should be greater than zero + if m.GetByRequestIDMock.defaultExpectation != nil && afterGetByRequestIDCounter < 1 { + if m.GetByRequestIDMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to SupplierRepositoryMock.GetByRequestID at\n%s", m.GetByRequestIDMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to SupplierRepositoryMock.GetByRequestID at\n%s with params: %#v", m.GetByRequestIDMock.defaultExpectation.expectationOrigins.origin, *m.GetByRequestIDMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcGetByRequestID != nil && afterGetByRequestIDCounter < 1 { + m.t.Errorf("Expected call to SupplierRepositoryMock.GetByRequestID at\n%s", m.funcGetByRequestIDOrigin) + } + + if !m.GetByRequestIDMock.invocationsDone() && afterGetByRequestIDCounter > 0 { + m.t.Errorf("Expected %d calls to SupplierRepositoryMock.GetByRequestID at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.GetByRequestIDMock.expectedInvocations), m.GetByRequestIDMock.expectedInvocationsOrigin, afterGetByRequestIDCounter) + } +} + +// MinimockFinish checks that all mocked methods have been called the expected number of times +func (m *SupplierRepositoryMock) MinimockFinish() { + m.finishOnce.Do(func() { + if !m.minimockDone() { + m.MinimockBulkInsertInspect() + + m.MinimockDeleteByRequestIDInspect() + + m.MinimockGetByRequestIDInspect() + } + }) +} + +// MinimockWait waits for all mocked methods to be called the expected number of times +func (m *SupplierRepositoryMock) MinimockWait(timeout mm_time.Duration) { + timeoutCh := mm_time.After(timeout) + for { + if m.minimockDone() { + return + } + select { + case <-timeoutCh: + m.MinimockFinish() + return + case <-mm_time.After(10 * mm_time.Millisecond): + } + } +} + +func (m *SupplierRepositoryMock) minimockDone() bool { + done := true + return done && + m.MinimockBulkInsertDone() && + m.MinimockDeleteByRequestIDDone() && + m.MinimockGetByRequestIDDone() +} diff --git a/internal/mocks/supplier_service_mock.go b/internal/mocks/supplier_service_mock.go new file mode 100644 index 0000000..aa48e56 --- /dev/null +++ b/internal/mocks/supplier_service_mock.go @@ -0,0 +1,418 @@ +// Code generated by http://github.com/gojuno/minimock (v3.4.7). DO NOT EDIT. + +package mocks + +//go:generate minimock -i smart-search-back/internal/service.SupplierService -o supplier_service_mock.go -n SupplierServiceMock -p mocks + +import ( + "context" + "sync" + mm_atomic "sync/atomic" + mm_time "time" + + "github.com/gojuno/minimock/v3" + "github.com/google/uuid" +) + +// SupplierServiceMock implements mm_service.SupplierService +type SupplierServiceMock struct { + t minimock.Tester + finishOnce sync.Once + + funcExportExcel func(ctx context.Context, requestID uuid.UUID) (ba1 []byte, err error) + funcExportExcelOrigin string + inspectFuncExportExcel func(ctx context.Context, requestID uuid.UUID) + afterExportExcelCounter uint64 + beforeExportExcelCounter uint64 + ExportExcelMock mSupplierServiceMockExportExcel +} + +// NewSupplierServiceMock returns a mock for mm_service.SupplierService +func NewSupplierServiceMock(t minimock.Tester) *SupplierServiceMock { + m := &SupplierServiceMock{t: t} + + if controller, ok := t.(minimock.MockController); ok { + controller.RegisterMocker(m) + } + + m.ExportExcelMock = mSupplierServiceMockExportExcel{mock: m} + m.ExportExcelMock.callArgs = []*SupplierServiceMockExportExcelParams{} + + t.Cleanup(m.MinimockFinish) + + return m +} + +type mSupplierServiceMockExportExcel struct { + optional bool + mock *SupplierServiceMock + defaultExpectation *SupplierServiceMockExportExcelExpectation + expectations []*SupplierServiceMockExportExcelExpectation + + callArgs []*SupplierServiceMockExportExcelParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// SupplierServiceMockExportExcelExpectation specifies expectation struct of the SupplierService.ExportExcel +type SupplierServiceMockExportExcelExpectation struct { + mock *SupplierServiceMock + params *SupplierServiceMockExportExcelParams + paramPtrs *SupplierServiceMockExportExcelParamPtrs + expectationOrigins SupplierServiceMockExportExcelExpectationOrigins + results *SupplierServiceMockExportExcelResults + returnOrigin string + Counter uint64 +} + +// SupplierServiceMockExportExcelParams contains parameters of the SupplierService.ExportExcel +type SupplierServiceMockExportExcelParams struct { + ctx context.Context + requestID uuid.UUID +} + +// SupplierServiceMockExportExcelParamPtrs contains pointers to parameters of the SupplierService.ExportExcel +type SupplierServiceMockExportExcelParamPtrs struct { + ctx *context.Context + requestID *uuid.UUID +} + +// SupplierServiceMockExportExcelResults contains results of the SupplierService.ExportExcel +type SupplierServiceMockExportExcelResults struct { + ba1 []byte + err error +} + +// SupplierServiceMockExportExcelOrigins contains origins of expectations of the SupplierService.ExportExcel +type SupplierServiceMockExportExcelExpectationOrigins struct { + origin string + originCtx string + originRequestID string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmExportExcel *mSupplierServiceMockExportExcel) Optional() *mSupplierServiceMockExportExcel { + mmExportExcel.optional = true + return mmExportExcel +} + +// Expect sets up expected params for SupplierService.ExportExcel +func (mmExportExcel *mSupplierServiceMockExportExcel) Expect(ctx context.Context, requestID uuid.UUID) *mSupplierServiceMockExportExcel { + if mmExportExcel.mock.funcExportExcel != nil { + mmExportExcel.mock.t.Fatalf("SupplierServiceMock.ExportExcel mock is already set by Set") + } + + if mmExportExcel.defaultExpectation == nil { + mmExportExcel.defaultExpectation = &SupplierServiceMockExportExcelExpectation{} + } + + if mmExportExcel.defaultExpectation.paramPtrs != nil { + mmExportExcel.mock.t.Fatalf("SupplierServiceMock.ExportExcel mock is already set by ExpectParams functions") + } + + mmExportExcel.defaultExpectation.params = &SupplierServiceMockExportExcelParams{ctx, requestID} + mmExportExcel.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmExportExcel.expectations { + if minimock.Equal(e.params, mmExportExcel.defaultExpectation.params) { + mmExportExcel.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmExportExcel.defaultExpectation.params) + } + } + + return mmExportExcel +} + +// ExpectCtxParam1 sets up expected param ctx for SupplierService.ExportExcel +func (mmExportExcel *mSupplierServiceMockExportExcel) ExpectCtxParam1(ctx context.Context) *mSupplierServiceMockExportExcel { + if mmExportExcel.mock.funcExportExcel != nil { + mmExportExcel.mock.t.Fatalf("SupplierServiceMock.ExportExcel mock is already set by Set") + } + + if mmExportExcel.defaultExpectation == nil { + mmExportExcel.defaultExpectation = &SupplierServiceMockExportExcelExpectation{} + } + + if mmExportExcel.defaultExpectation.params != nil { + mmExportExcel.mock.t.Fatalf("SupplierServiceMock.ExportExcel mock is already set by Expect") + } + + if mmExportExcel.defaultExpectation.paramPtrs == nil { + mmExportExcel.defaultExpectation.paramPtrs = &SupplierServiceMockExportExcelParamPtrs{} + } + mmExportExcel.defaultExpectation.paramPtrs.ctx = &ctx + mmExportExcel.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmExportExcel +} + +// ExpectRequestIDParam2 sets up expected param requestID for SupplierService.ExportExcel +func (mmExportExcel *mSupplierServiceMockExportExcel) ExpectRequestIDParam2(requestID uuid.UUID) *mSupplierServiceMockExportExcel { + if mmExportExcel.mock.funcExportExcel != nil { + mmExportExcel.mock.t.Fatalf("SupplierServiceMock.ExportExcel mock is already set by Set") + } + + if mmExportExcel.defaultExpectation == nil { + mmExportExcel.defaultExpectation = &SupplierServiceMockExportExcelExpectation{} + } + + if mmExportExcel.defaultExpectation.params != nil { + mmExportExcel.mock.t.Fatalf("SupplierServiceMock.ExportExcel mock is already set by Expect") + } + + if mmExportExcel.defaultExpectation.paramPtrs == nil { + mmExportExcel.defaultExpectation.paramPtrs = &SupplierServiceMockExportExcelParamPtrs{} + } + mmExportExcel.defaultExpectation.paramPtrs.requestID = &requestID + mmExportExcel.defaultExpectation.expectationOrigins.originRequestID = minimock.CallerInfo(1) + + return mmExportExcel +} + +// Inspect accepts an inspector function that has same arguments as the SupplierService.ExportExcel +func (mmExportExcel *mSupplierServiceMockExportExcel) Inspect(f func(ctx context.Context, requestID uuid.UUID)) *mSupplierServiceMockExportExcel { + if mmExportExcel.mock.inspectFuncExportExcel != nil { + mmExportExcel.mock.t.Fatalf("Inspect function is already set for SupplierServiceMock.ExportExcel") + } + + mmExportExcel.mock.inspectFuncExportExcel = f + + return mmExportExcel +} + +// Return sets up results that will be returned by SupplierService.ExportExcel +func (mmExportExcel *mSupplierServiceMockExportExcel) Return(ba1 []byte, err error) *SupplierServiceMock { + if mmExportExcel.mock.funcExportExcel != nil { + mmExportExcel.mock.t.Fatalf("SupplierServiceMock.ExportExcel mock is already set by Set") + } + + if mmExportExcel.defaultExpectation == nil { + mmExportExcel.defaultExpectation = &SupplierServiceMockExportExcelExpectation{mock: mmExportExcel.mock} + } + mmExportExcel.defaultExpectation.results = &SupplierServiceMockExportExcelResults{ba1, err} + mmExportExcel.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmExportExcel.mock +} + +// Set uses given function f to mock the SupplierService.ExportExcel method +func (mmExportExcel *mSupplierServiceMockExportExcel) Set(f func(ctx context.Context, requestID uuid.UUID) (ba1 []byte, err error)) *SupplierServiceMock { + if mmExportExcel.defaultExpectation != nil { + mmExportExcel.mock.t.Fatalf("Default expectation is already set for the SupplierService.ExportExcel method") + } + + if len(mmExportExcel.expectations) > 0 { + mmExportExcel.mock.t.Fatalf("Some expectations are already set for the SupplierService.ExportExcel method") + } + + mmExportExcel.mock.funcExportExcel = f + mmExportExcel.mock.funcExportExcelOrigin = minimock.CallerInfo(1) + return mmExportExcel.mock +} + +// When sets expectation for the SupplierService.ExportExcel which will trigger the result defined by the following +// Then helper +func (mmExportExcel *mSupplierServiceMockExportExcel) When(ctx context.Context, requestID uuid.UUID) *SupplierServiceMockExportExcelExpectation { + if mmExportExcel.mock.funcExportExcel != nil { + mmExportExcel.mock.t.Fatalf("SupplierServiceMock.ExportExcel mock is already set by Set") + } + + expectation := &SupplierServiceMockExportExcelExpectation{ + mock: mmExportExcel.mock, + params: &SupplierServiceMockExportExcelParams{ctx, requestID}, + expectationOrigins: SupplierServiceMockExportExcelExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmExportExcel.expectations = append(mmExportExcel.expectations, expectation) + return expectation +} + +// Then sets up SupplierService.ExportExcel return parameters for the expectation previously defined by the When method +func (e *SupplierServiceMockExportExcelExpectation) Then(ba1 []byte, err error) *SupplierServiceMock { + e.results = &SupplierServiceMockExportExcelResults{ba1, err} + return e.mock +} + +// Times sets number of times SupplierService.ExportExcel should be invoked +func (mmExportExcel *mSupplierServiceMockExportExcel) Times(n uint64) *mSupplierServiceMockExportExcel { + if n == 0 { + mmExportExcel.mock.t.Fatalf("Times of SupplierServiceMock.ExportExcel mock can not be zero") + } + mm_atomic.StoreUint64(&mmExportExcel.expectedInvocations, n) + mmExportExcel.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmExportExcel +} + +func (mmExportExcel *mSupplierServiceMockExportExcel) invocationsDone() bool { + if len(mmExportExcel.expectations) == 0 && mmExportExcel.defaultExpectation == nil && mmExportExcel.mock.funcExportExcel == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmExportExcel.mock.afterExportExcelCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmExportExcel.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// ExportExcel implements mm_service.SupplierService +func (mmExportExcel *SupplierServiceMock) ExportExcel(ctx context.Context, requestID uuid.UUID) (ba1 []byte, err error) { + mm_atomic.AddUint64(&mmExportExcel.beforeExportExcelCounter, 1) + defer mm_atomic.AddUint64(&mmExportExcel.afterExportExcelCounter, 1) + + mmExportExcel.t.Helper() + + if mmExportExcel.inspectFuncExportExcel != nil { + mmExportExcel.inspectFuncExportExcel(ctx, requestID) + } + + mm_params := SupplierServiceMockExportExcelParams{ctx, requestID} + + // Record call args + mmExportExcel.ExportExcelMock.mutex.Lock() + mmExportExcel.ExportExcelMock.callArgs = append(mmExportExcel.ExportExcelMock.callArgs, &mm_params) + mmExportExcel.ExportExcelMock.mutex.Unlock() + + for _, e := range mmExportExcel.ExportExcelMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.ba1, e.results.err + } + } + + if mmExportExcel.ExportExcelMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmExportExcel.ExportExcelMock.defaultExpectation.Counter, 1) + mm_want := mmExportExcel.ExportExcelMock.defaultExpectation.params + mm_want_ptrs := mmExportExcel.ExportExcelMock.defaultExpectation.paramPtrs + + mm_got := SupplierServiceMockExportExcelParams{ctx, requestID} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmExportExcel.t.Errorf("SupplierServiceMock.ExportExcel got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmExportExcel.ExportExcelMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.requestID != nil && !minimock.Equal(*mm_want_ptrs.requestID, mm_got.requestID) { + mmExportExcel.t.Errorf("SupplierServiceMock.ExportExcel got unexpected parameter requestID, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmExportExcel.ExportExcelMock.defaultExpectation.expectationOrigins.originRequestID, *mm_want_ptrs.requestID, mm_got.requestID, minimock.Diff(*mm_want_ptrs.requestID, mm_got.requestID)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmExportExcel.t.Errorf("SupplierServiceMock.ExportExcel got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmExportExcel.ExportExcelMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmExportExcel.ExportExcelMock.defaultExpectation.results + if mm_results == nil { + mmExportExcel.t.Fatal("No results are set for the SupplierServiceMock.ExportExcel") + } + return (*mm_results).ba1, (*mm_results).err + } + if mmExportExcel.funcExportExcel != nil { + return mmExportExcel.funcExportExcel(ctx, requestID) + } + mmExportExcel.t.Fatalf("Unexpected call to SupplierServiceMock.ExportExcel. %v %v", ctx, requestID) + return +} + +// ExportExcelAfterCounter returns a count of finished SupplierServiceMock.ExportExcel invocations +func (mmExportExcel *SupplierServiceMock) ExportExcelAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmExportExcel.afterExportExcelCounter) +} + +// ExportExcelBeforeCounter returns a count of SupplierServiceMock.ExportExcel invocations +func (mmExportExcel *SupplierServiceMock) ExportExcelBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmExportExcel.beforeExportExcelCounter) +} + +// Calls returns a list of arguments used in each call to SupplierServiceMock.ExportExcel. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmExportExcel *mSupplierServiceMockExportExcel) Calls() []*SupplierServiceMockExportExcelParams { + mmExportExcel.mutex.RLock() + + argCopy := make([]*SupplierServiceMockExportExcelParams, len(mmExportExcel.callArgs)) + copy(argCopy, mmExportExcel.callArgs) + + mmExportExcel.mutex.RUnlock() + + return argCopy +} + +// MinimockExportExcelDone returns true if the count of the ExportExcel invocations corresponds +// the number of defined expectations +func (m *SupplierServiceMock) MinimockExportExcelDone() bool { + if m.ExportExcelMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.ExportExcelMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.ExportExcelMock.invocationsDone() +} + +// MinimockExportExcelInspect logs each unmet expectation +func (m *SupplierServiceMock) MinimockExportExcelInspect() { + for _, e := range m.ExportExcelMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to SupplierServiceMock.ExportExcel at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterExportExcelCounter := mm_atomic.LoadUint64(&m.afterExportExcelCounter) + // if default expectation was set then invocations count should be greater than zero + if m.ExportExcelMock.defaultExpectation != nil && afterExportExcelCounter < 1 { + if m.ExportExcelMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to SupplierServiceMock.ExportExcel at\n%s", m.ExportExcelMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to SupplierServiceMock.ExportExcel at\n%s with params: %#v", m.ExportExcelMock.defaultExpectation.expectationOrigins.origin, *m.ExportExcelMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcExportExcel != nil && afterExportExcelCounter < 1 { + m.t.Errorf("Expected call to SupplierServiceMock.ExportExcel at\n%s", m.funcExportExcelOrigin) + } + + if !m.ExportExcelMock.invocationsDone() && afterExportExcelCounter > 0 { + m.t.Errorf("Expected %d calls to SupplierServiceMock.ExportExcel at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.ExportExcelMock.expectedInvocations), m.ExportExcelMock.expectedInvocationsOrigin, afterExportExcelCounter) + } +} + +// MinimockFinish checks that all mocked methods have been called the expected number of times +func (m *SupplierServiceMock) MinimockFinish() { + m.finishOnce.Do(func() { + if !m.minimockDone() { + m.MinimockExportExcelInspect() + } + }) +} + +// MinimockWait waits for all mocked methods to be called the expected number of times +func (m *SupplierServiceMock) MinimockWait(timeout mm_time.Duration) { + timeoutCh := mm_time.After(timeout) + for { + if m.minimockDone() { + return + } + select { + case <-timeoutCh: + m.MinimockFinish() + return + case <-mm_time.After(10 * mm_time.Millisecond): + } + } +} + +func (m *SupplierServiceMock) minimockDone() bool { + done := true + return done && + m.MinimockExportExcelDone() +} diff --git a/internal/mocks/token_usage_repository_mock.go b/internal/mocks/token_usage_repository_mock.go new file mode 100644 index 0000000..d610e6d --- /dev/null +++ b/internal/mocks/token_usage_repository_mock.go @@ -0,0 +1,417 @@ +// Code generated by http://github.com/gojuno/minimock (v3.4.7). DO NOT EDIT. + +package mocks + +//go:generate minimock -i smart-search-back/internal/repository.TokenUsageRepository -o token_usage_repository_mock.go -n TokenUsageRepositoryMock -p mocks + +import ( + "context" + "smart-search-back/internal/model" + "sync" + mm_atomic "sync/atomic" + mm_time "time" + + "github.com/gojuno/minimock/v3" +) + +// TokenUsageRepositoryMock implements mm_repository.TokenUsageRepository +type TokenUsageRepositoryMock struct { + t minimock.Tester + finishOnce sync.Once + + funcCreate func(ctx context.Context, usage *model.TokenUsage) (err error) + funcCreateOrigin string + inspectFuncCreate func(ctx context.Context, usage *model.TokenUsage) + afterCreateCounter uint64 + beforeCreateCounter uint64 + CreateMock mTokenUsageRepositoryMockCreate +} + +// NewTokenUsageRepositoryMock returns a mock for mm_repository.TokenUsageRepository +func NewTokenUsageRepositoryMock(t minimock.Tester) *TokenUsageRepositoryMock { + m := &TokenUsageRepositoryMock{t: t} + + if controller, ok := t.(minimock.MockController); ok { + controller.RegisterMocker(m) + } + + m.CreateMock = mTokenUsageRepositoryMockCreate{mock: m} + m.CreateMock.callArgs = []*TokenUsageRepositoryMockCreateParams{} + + t.Cleanup(m.MinimockFinish) + + return m +} + +type mTokenUsageRepositoryMockCreate struct { + optional bool + mock *TokenUsageRepositoryMock + defaultExpectation *TokenUsageRepositoryMockCreateExpectation + expectations []*TokenUsageRepositoryMockCreateExpectation + + callArgs []*TokenUsageRepositoryMockCreateParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// TokenUsageRepositoryMockCreateExpectation specifies expectation struct of the TokenUsageRepository.Create +type TokenUsageRepositoryMockCreateExpectation struct { + mock *TokenUsageRepositoryMock + params *TokenUsageRepositoryMockCreateParams + paramPtrs *TokenUsageRepositoryMockCreateParamPtrs + expectationOrigins TokenUsageRepositoryMockCreateExpectationOrigins + results *TokenUsageRepositoryMockCreateResults + returnOrigin string + Counter uint64 +} + +// TokenUsageRepositoryMockCreateParams contains parameters of the TokenUsageRepository.Create +type TokenUsageRepositoryMockCreateParams struct { + ctx context.Context + usage *model.TokenUsage +} + +// TokenUsageRepositoryMockCreateParamPtrs contains pointers to parameters of the TokenUsageRepository.Create +type TokenUsageRepositoryMockCreateParamPtrs struct { + ctx *context.Context + usage **model.TokenUsage +} + +// TokenUsageRepositoryMockCreateResults contains results of the TokenUsageRepository.Create +type TokenUsageRepositoryMockCreateResults struct { + err error +} + +// TokenUsageRepositoryMockCreateOrigins contains origins of expectations of the TokenUsageRepository.Create +type TokenUsageRepositoryMockCreateExpectationOrigins struct { + origin string + originCtx string + originUsage string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmCreate *mTokenUsageRepositoryMockCreate) Optional() *mTokenUsageRepositoryMockCreate { + mmCreate.optional = true + return mmCreate +} + +// Expect sets up expected params for TokenUsageRepository.Create +func (mmCreate *mTokenUsageRepositoryMockCreate) Expect(ctx context.Context, usage *model.TokenUsage) *mTokenUsageRepositoryMockCreate { + if mmCreate.mock.funcCreate != nil { + mmCreate.mock.t.Fatalf("TokenUsageRepositoryMock.Create mock is already set by Set") + } + + if mmCreate.defaultExpectation == nil { + mmCreate.defaultExpectation = &TokenUsageRepositoryMockCreateExpectation{} + } + + if mmCreate.defaultExpectation.paramPtrs != nil { + mmCreate.mock.t.Fatalf("TokenUsageRepositoryMock.Create mock is already set by ExpectParams functions") + } + + mmCreate.defaultExpectation.params = &TokenUsageRepositoryMockCreateParams{ctx, usage} + mmCreate.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmCreate.expectations { + if minimock.Equal(e.params, mmCreate.defaultExpectation.params) { + mmCreate.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmCreate.defaultExpectation.params) + } + } + + return mmCreate +} + +// ExpectCtxParam1 sets up expected param ctx for TokenUsageRepository.Create +func (mmCreate *mTokenUsageRepositoryMockCreate) ExpectCtxParam1(ctx context.Context) *mTokenUsageRepositoryMockCreate { + if mmCreate.mock.funcCreate != nil { + mmCreate.mock.t.Fatalf("TokenUsageRepositoryMock.Create mock is already set by Set") + } + + if mmCreate.defaultExpectation == nil { + mmCreate.defaultExpectation = &TokenUsageRepositoryMockCreateExpectation{} + } + + if mmCreate.defaultExpectation.params != nil { + mmCreate.mock.t.Fatalf("TokenUsageRepositoryMock.Create mock is already set by Expect") + } + + if mmCreate.defaultExpectation.paramPtrs == nil { + mmCreate.defaultExpectation.paramPtrs = &TokenUsageRepositoryMockCreateParamPtrs{} + } + mmCreate.defaultExpectation.paramPtrs.ctx = &ctx + mmCreate.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmCreate +} + +// ExpectUsageParam2 sets up expected param usage for TokenUsageRepository.Create +func (mmCreate *mTokenUsageRepositoryMockCreate) ExpectUsageParam2(usage *model.TokenUsage) *mTokenUsageRepositoryMockCreate { + if mmCreate.mock.funcCreate != nil { + mmCreate.mock.t.Fatalf("TokenUsageRepositoryMock.Create mock is already set by Set") + } + + if mmCreate.defaultExpectation == nil { + mmCreate.defaultExpectation = &TokenUsageRepositoryMockCreateExpectation{} + } + + if mmCreate.defaultExpectation.params != nil { + mmCreate.mock.t.Fatalf("TokenUsageRepositoryMock.Create mock is already set by Expect") + } + + if mmCreate.defaultExpectation.paramPtrs == nil { + mmCreate.defaultExpectation.paramPtrs = &TokenUsageRepositoryMockCreateParamPtrs{} + } + mmCreate.defaultExpectation.paramPtrs.usage = &usage + mmCreate.defaultExpectation.expectationOrigins.originUsage = minimock.CallerInfo(1) + + return mmCreate +} + +// Inspect accepts an inspector function that has same arguments as the TokenUsageRepository.Create +func (mmCreate *mTokenUsageRepositoryMockCreate) Inspect(f func(ctx context.Context, usage *model.TokenUsage)) *mTokenUsageRepositoryMockCreate { + if mmCreate.mock.inspectFuncCreate != nil { + mmCreate.mock.t.Fatalf("Inspect function is already set for TokenUsageRepositoryMock.Create") + } + + mmCreate.mock.inspectFuncCreate = f + + return mmCreate +} + +// Return sets up results that will be returned by TokenUsageRepository.Create +func (mmCreate *mTokenUsageRepositoryMockCreate) Return(err error) *TokenUsageRepositoryMock { + if mmCreate.mock.funcCreate != nil { + mmCreate.mock.t.Fatalf("TokenUsageRepositoryMock.Create mock is already set by Set") + } + + if mmCreate.defaultExpectation == nil { + mmCreate.defaultExpectation = &TokenUsageRepositoryMockCreateExpectation{mock: mmCreate.mock} + } + mmCreate.defaultExpectation.results = &TokenUsageRepositoryMockCreateResults{err} + mmCreate.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmCreate.mock +} + +// Set uses given function f to mock the TokenUsageRepository.Create method +func (mmCreate *mTokenUsageRepositoryMockCreate) Set(f func(ctx context.Context, usage *model.TokenUsage) (err error)) *TokenUsageRepositoryMock { + if mmCreate.defaultExpectation != nil { + mmCreate.mock.t.Fatalf("Default expectation is already set for the TokenUsageRepository.Create method") + } + + if len(mmCreate.expectations) > 0 { + mmCreate.mock.t.Fatalf("Some expectations are already set for the TokenUsageRepository.Create method") + } + + mmCreate.mock.funcCreate = f + mmCreate.mock.funcCreateOrigin = minimock.CallerInfo(1) + return mmCreate.mock +} + +// When sets expectation for the TokenUsageRepository.Create which will trigger the result defined by the following +// Then helper +func (mmCreate *mTokenUsageRepositoryMockCreate) When(ctx context.Context, usage *model.TokenUsage) *TokenUsageRepositoryMockCreateExpectation { + if mmCreate.mock.funcCreate != nil { + mmCreate.mock.t.Fatalf("TokenUsageRepositoryMock.Create mock is already set by Set") + } + + expectation := &TokenUsageRepositoryMockCreateExpectation{ + mock: mmCreate.mock, + params: &TokenUsageRepositoryMockCreateParams{ctx, usage}, + expectationOrigins: TokenUsageRepositoryMockCreateExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmCreate.expectations = append(mmCreate.expectations, expectation) + return expectation +} + +// Then sets up TokenUsageRepository.Create return parameters for the expectation previously defined by the When method +func (e *TokenUsageRepositoryMockCreateExpectation) Then(err error) *TokenUsageRepositoryMock { + e.results = &TokenUsageRepositoryMockCreateResults{err} + return e.mock +} + +// Times sets number of times TokenUsageRepository.Create should be invoked +func (mmCreate *mTokenUsageRepositoryMockCreate) Times(n uint64) *mTokenUsageRepositoryMockCreate { + if n == 0 { + mmCreate.mock.t.Fatalf("Times of TokenUsageRepositoryMock.Create mock can not be zero") + } + mm_atomic.StoreUint64(&mmCreate.expectedInvocations, n) + mmCreate.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmCreate +} + +func (mmCreate *mTokenUsageRepositoryMockCreate) invocationsDone() bool { + if len(mmCreate.expectations) == 0 && mmCreate.defaultExpectation == nil && mmCreate.mock.funcCreate == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmCreate.mock.afterCreateCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmCreate.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// Create implements mm_repository.TokenUsageRepository +func (mmCreate *TokenUsageRepositoryMock) Create(ctx context.Context, usage *model.TokenUsage) (err error) { + mm_atomic.AddUint64(&mmCreate.beforeCreateCounter, 1) + defer mm_atomic.AddUint64(&mmCreate.afterCreateCounter, 1) + + mmCreate.t.Helper() + + if mmCreate.inspectFuncCreate != nil { + mmCreate.inspectFuncCreate(ctx, usage) + } + + mm_params := TokenUsageRepositoryMockCreateParams{ctx, usage} + + // Record call args + mmCreate.CreateMock.mutex.Lock() + mmCreate.CreateMock.callArgs = append(mmCreate.CreateMock.callArgs, &mm_params) + mmCreate.CreateMock.mutex.Unlock() + + for _, e := range mmCreate.CreateMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.err + } + } + + if mmCreate.CreateMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmCreate.CreateMock.defaultExpectation.Counter, 1) + mm_want := mmCreate.CreateMock.defaultExpectation.params + mm_want_ptrs := mmCreate.CreateMock.defaultExpectation.paramPtrs + + mm_got := TokenUsageRepositoryMockCreateParams{ctx, usage} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmCreate.t.Errorf("TokenUsageRepositoryMock.Create got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmCreate.CreateMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.usage != nil && !minimock.Equal(*mm_want_ptrs.usage, mm_got.usage) { + mmCreate.t.Errorf("TokenUsageRepositoryMock.Create got unexpected parameter usage, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmCreate.CreateMock.defaultExpectation.expectationOrigins.originUsage, *mm_want_ptrs.usage, mm_got.usage, minimock.Diff(*mm_want_ptrs.usage, mm_got.usage)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmCreate.t.Errorf("TokenUsageRepositoryMock.Create got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmCreate.CreateMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmCreate.CreateMock.defaultExpectation.results + if mm_results == nil { + mmCreate.t.Fatal("No results are set for the TokenUsageRepositoryMock.Create") + } + return (*mm_results).err + } + if mmCreate.funcCreate != nil { + return mmCreate.funcCreate(ctx, usage) + } + mmCreate.t.Fatalf("Unexpected call to TokenUsageRepositoryMock.Create. %v %v", ctx, usage) + return +} + +// CreateAfterCounter returns a count of finished TokenUsageRepositoryMock.Create invocations +func (mmCreate *TokenUsageRepositoryMock) CreateAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmCreate.afterCreateCounter) +} + +// CreateBeforeCounter returns a count of TokenUsageRepositoryMock.Create invocations +func (mmCreate *TokenUsageRepositoryMock) CreateBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmCreate.beforeCreateCounter) +} + +// Calls returns a list of arguments used in each call to TokenUsageRepositoryMock.Create. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmCreate *mTokenUsageRepositoryMockCreate) Calls() []*TokenUsageRepositoryMockCreateParams { + mmCreate.mutex.RLock() + + argCopy := make([]*TokenUsageRepositoryMockCreateParams, len(mmCreate.callArgs)) + copy(argCopy, mmCreate.callArgs) + + mmCreate.mutex.RUnlock() + + return argCopy +} + +// MinimockCreateDone returns true if the count of the Create invocations corresponds +// the number of defined expectations +func (m *TokenUsageRepositoryMock) MinimockCreateDone() bool { + if m.CreateMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.CreateMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.CreateMock.invocationsDone() +} + +// MinimockCreateInspect logs each unmet expectation +func (m *TokenUsageRepositoryMock) MinimockCreateInspect() { + for _, e := range m.CreateMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to TokenUsageRepositoryMock.Create at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterCreateCounter := mm_atomic.LoadUint64(&m.afterCreateCounter) + // if default expectation was set then invocations count should be greater than zero + if m.CreateMock.defaultExpectation != nil && afterCreateCounter < 1 { + if m.CreateMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to TokenUsageRepositoryMock.Create at\n%s", m.CreateMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to TokenUsageRepositoryMock.Create at\n%s with params: %#v", m.CreateMock.defaultExpectation.expectationOrigins.origin, *m.CreateMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcCreate != nil && afterCreateCounter < 1 { + m.t.Errorf("Expected call to TokenUsageRepositoryMock.Create at\n%s", m.funcCreateOrigin) + } + + if !m.CreateMock.invocationsDone() && afterCreateCounter > 0 { + m.t.Errorf("Expected %d calls to TokenUsageRepositoryMock.Create at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.CreateMock.expectedInvocations), m.CreateMock.expectedInvocationsOrigin, afterCreateCounter) + } +} + +// MinimockFinish checks that all mocked methods have been called the expected number of times +func (m *TokenUsageRepositoryMock) MinimockFinish() { + m.finishOnce.Do(func() { + if !m.minimockDone() { + m.MinimockCreateInspect() + } + }) +} + +// MinimockWait waits for all mocked methods to be called the expected number of times +func (m *TokenUsageRepositoryMock) MinimockWait(timeout mm_time.Duration) { + timeoutCh := mm_time.After(timeout) + for { + if m.minimockDone() { + return + } + select { + case <-timeoutCh: + m.MinimockFinish() + return + case <-mm_time.After(10 * mm_time.Millisecond): + } + } +} + +func (m *TokenUsageRepositoryMock) minimockDone() bool { + done := true + return done && + m.MinimockCreateDone() +} diff --git a/internal/mocks/user_repository_mock.go b/internal/mocks/user_repository_mock.go new file mode 100644 index 0000000..9497aff --- /dev/null +++ b/internal/mocks/user_repository_mock.go @@ -0,0 +1,2582 @@ +// Code generated by http://github.com/gojuno/minimock (v3.4.7). DO NOT EDIT. + +package mocks + +//go:generate minimock -i smart-search-back/internal/repository.UserRepository -o user_repository_mock.go -n UserRepositoryMock -p mocks + +import ( + "context" + "smart-search-back/internal/model" + "sync" + mm_atomic "sync/atomic" + mm_time "time" + + "github.com/gojuno/minimock/v3" +) + +// UserRepositoryMock implements mm_repository.UserRepository +type UserRepositoryMock struct { + t minimock.Tester + finishOnce sync.Once + + funcCheckInviteLimit func(ctx context.Context, userID int) (b1 bool, err error) + funcCheckInviteLimitOrigin string + inspectFuncCheckInviteLimit func(ctx context.Context, userID int) + afterCheckInviteLimitCounter uint64 + beforeCheckInviteLimitCounter uint64 + CheckInviteLimitMock mUserRepositoryMockCheckInviteLimit + + funcCreate func(ctx context.Context, user *model.User) (err error) + funcCreateOrigin string + inspectFuncCreate func(ctx context.Context, user *model.User) + afterCreateCounter uint64 + beforeCreateCounter uint64 + CreateMock mUserRepositoryMockCreate + + funcFindByEmailHash func(ctx context.Context, emailHash string) (up1 *model.User, err error) + funcFindByEmailHashOrigin string + inspectFuncFindByEmailHash func(ctx context.Context, emailHash string) + afterFindByEmailHashCounter uint64 + beforeFindByEmailHashCounter uint64 + FindByEmailHashMock mUserRepositoryMockFindByEmailHash + + funcFindByID func(ctx context.Context, userID int) (up1 *model.User, err error) + funcFindByIDOrigin string + inspectFuncFindByID func(ctx context.Context, userID int) + afterFindByIDCounter uint64 + beforeFindByIDCounter uint64 + FindByIDMock mUserRepositoryMockFindByID + + funcGetBalance func(ctx context.Context, userID int) (f1 float64, err error) + funcGetBalanceOrigin string + inspectFuncGetBalance func(ctx context.Context, userID int) + afterGetBalanceCounter uint64 + beforeGetBalanceCounter uint64 + GetBalanceMock mUserRepositoryMockGetBalance + + funcIncrementInvitesIssued func(ctx context.Context, userID int) (err error) + funcIncrementInvitesIssuedOrigin string + inspectFuncIncrementInvitesIssued func(ctx context.Context, userID int) + afterIncrementInvitesIssuedCounter uint64 + beforeIncrementInvitesIssuedCounter uint64 + IncrementInvitesIssuedMock mUserRepositoryMockIncrementInvitesIssued + + funcUpdateBalance func(ctx context.Context, userID int, delta float64) (err error) + funcUpdateBalanceOrigin string + inspectFuncUpdateBalance func(ctx context.Context, userID int, delta float64) + afterUpdateBalanceCounter uint64 + beforeUpdateBalanceCounter uint64 + UpdateBalanceMock mUserRepositoryMockUpdateBalance +} + +// NewUserRepositoryMock returns a mock for mm_repository.UserRepository +func NewUserRepositoryMock(t minimock.Tester) *UserRepositoryMock { + m := &UserRepositoryMock{t: t} + + if controller, ok := t.(minimock.MockController); ok { + controller.RegisterMocker(m) + } + + m.CheckInviteLimitMock = mUserRepositoryMockCheckInviteLimit{mock: m} + m.CheckInviteLimitMock.callArgs = []*UserRepositoryMockCheckInviteLimitParams{} + + m.CreateMock = mUserRepositoryMockCreate{mock: m} + m.CreateMock.callArgs = []*UserRepositoryMockCreateParams{} + + m.FindByEmailHashMock = mUserRepositoryMockFindByEmailHash{mock: m} + m.FindByEmailHashMock.callArgs = []*UserRepositoryMockFindByEmailHashParams{} + + m.FindByIDMock = mUserRepositoryMockFindByID{mock: m} + m.FindByIDMock.callArgs = []*UserRepositoryMockFindByIDParams{} + + m.GetBalanceMock = mUserRepositoryMockGetBalance{mock: m} + m.GetBalanceMock.callArgs = []*UserRepositoryMockGetBalanceParams{} + + m.IncrementInvitesIssuedMock = mUserRepositoryMockIncrementInvitesIssued{mock: m} + m.IncrementInvitesIssuedMock.callArgs = []*UserRepositoryMockIncrementInvitesIssuedParams{} + + m.UpdateBalanceMock = mUserRepositoryMockUpdateBalance{mock: m} + m.UpdateBalanceMock.callArgs = []*UserRepositoryMockUpdateBalanceParams{} + + t.Cleanup(m.MinimockFinish) + + return m +} + +type mUserRepositoryMockCheckInviteLimit struct { + optional bool + mock *UserRepositoryMock + defaultExpectation *UserRepositoryMockCheckInviteLimitExpectation + expectations []*UserRepositoryMockCheckInviteLimitExpectation + + callArgs []*UserRepositoryMockCheckInviteLimitParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// UserRepositoryMockCheckInviteLimitExpectation specifies expectation struct of the UserRepository.CheckInviteLimit +type UserRepositoryMockCheckInviteLimitExpectation struct { + mock *UserRepositoryMock + params *UserRepositoryMockCheckInviteLimitParams + paramPtrs *UserRepositoryMockCheckInviteLimitParamPtrs + expectationOrigins UserRepositoryMockCheckInviteLimitExpectationOrigins + results *UserRepositoryMockCheckInviteLimitResults + returnOrigin string + Counter uint64 +} + +// UserRepositoryMockCheckInviteLimitParams contains parameters of the UserRepository.CheckInviteLimit +type UserRepositoryMockCheckInviteLimitParams struct { + ctx context.Context + userID int +} + +// UserRepositoryMockCheckInviteLimitParamPtrs contains pointers to parameters of the UserRepository.CheckInviteLimit +type UserRepositoryMockCheckInviteLimitParamPtrs struct { + ctx *context.Context + userID *int +} + +// UserRepositoryMockCheckInviteLimitResults contains results of the UserRepository.CheckInviteLimit +type UserRepositoryMockCheckInviteLimitResults struct { + b1 bool + err error +} + +// UserRepositoryMockCheckInviteLimitOrigins contains origins of expectations of the UserRepository.CheckInviteLimit +type UserRepositoryMockCheckInviteLimitExpectationOrigins struct { + origin string + originCtx string + originUserID string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmCheckInviteLimit *mUserRepositoryMockCheckInviteLimit) Optional() *mUserRepositoryMockCheckInviteLimit { + mmCheckInviteLimit.optional = true + return mmCheckInviteLimit +} + +// Expect sets up expected params for UserRepository.CheckInviteLimit +func (mmCheckInviteLimit *mUserRepositoryMockCheckInviteLimit) Expect(ctx context.Context, userID int) *mUserRepositoryMockCheckInviteLimit { + if mmCheckInviteLimit.mock.funcCheckInviteLimit != nil { + mmCheckInviteLimit.mock.t.Fatalf("UserRepositoryMock.CheckInviteLimit mock is already set by Set") + } + + if mmCheckInviteLimit.defaultExpectation == nil { + mmCheckInviteLimit.defaultExpectation = &UserRepositoryMockCheckInviteLimitExpectation{} + } + + if mmCheckInviteLimit.defaultExpectation.paramPtrs != nil { + mmCheckInviteLimit.mock.t.Fatalf("UserRepositoryMock.CheckInviteLimit mock is already set by ExpectParams functions") + } + + mmCheckInviteLimit.defaultExpectation.params = &UserRepositoryMockCheckInviteLimitParams{ctx, userID} + mmCheckInviteLimit.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmCheckInviteLimit.expectations { + if minimock.Equal(e.params, mmCheckInviteLimit.defaultExpectation.params) { + mmCheckInviteLimit.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmCheckInviteLimit.defaultExpectation.params) + } + } + + return mmCheckInviteLimit +} + +// ExpectCtxParam1 sets up expected param ctx for UserRepository.CheckInviteLimit +func (mmCheckInviteLimit *mUserRepositoryMockCheckInviteLimit) ExpectCtxParam1(ctx context.Context) *mUserRepositoryMockCheckInviteLimit { + if mmCheckInviteLimit.mock.funcCheckInviteLimit != nil { + mmCheckInviteLimit.mock.t.Fatalf("UserRepositoryMock.CheckInviteLimit mock is already set by Set") + } + + if mmCheckInviteLimit.defaultExpectation == nil { + mmCheckInviteLimit.defaultExpectation = &UserRepositoryMockCheckInviteLimitExpectation{} + } + + if mmCheckInviteLimit.defaultExpectation.params != nil { + mmCheckInviteLimit.mock.t.Fatalf("UserRepositoryMock.CheckInviteLimit mock is already set by Expect") + } + + if mmCheckInviteLimit.defaultExpectation.paramPtrs == nil { + mmCheckInviteLimit.defaultExpectation.paramPtrs = &UserRepositoryMockCheckInviteLimitParamPtrs{} + } + mmCheckInviteLimit.defaultExpectation.paramPtrs.ctx = &ctx + mmCheckInviteLimit.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmCheckInviteLimit +} + +// ExpectUserIDParam2 sets up expected param userID for UserRepository.CheckInviteLimit +func (mmCheckInviteLimit *mUserRepositoryMockCheckInviteLimit) ExpectUserIDParam2(userID int) *mUserRepositoryMockCheckInviteLimit { + if mmCheckInviteLimit.mock.funcCheckInviteLimit != nil { + mmCheckInviteLimit.mock.t.Fatalf("UserRepositoryMock.CheckInviteLimit mock is already set by Set") + } + + if mmCheckInviteLimit.defaultExpectation == nil { + mmCheckInviteLimit.defaultExpectation = &UserRepositoryMockCheckInviteLimitExpectation{} + } + + if mmCheckInviteLimit.defaultExpectation.params != nil { + mmCheckInviteLimit.mock.t.Fatalf("UserRepositoryMock.CheckInviteLimit mock is already set by Expect") + } + + if mmCheckInviteLimit.defaultExpectation.paramPtrs == nil { + mmCheckInviteLimit.defaultExpectation.paramPtrs = &UserRepositoryMockCheckInviteLimitParamPtrs{} + } + mmCheckInviteLimit.defaultExpectation.paramPtrs.userID = &userID + mmCheckInviteLimit.defaultExpectation.expectationOrigins.originUserID = minimock.CallerInfo(1) + + return mmCheckInviteLimit +} + +// Inspect accepts an inspector function that has same arguments as the UserRepository.CheckInviteLimit +func (mmCheckInviteLimit *mUserRepositoryMockCheckInviteLimit) Inspect(f func(ctx context.Context, userID int)) *mUserRepositoryMockCheckInviteLimit { + if mmCheckInviteLimit.mock.inspectFuncCheckInviteLimit != nil { + mmCheckInviteLimit.mock.t.Fatalf("Inspect function is already set for UserRepositoryMock.CheckInviteLimit") + } + + mmCheckInviteLimit.mock.inspectFuncCheckInviteLimit = f + + return mmCheckInviteLimit +} + +// Return sets up results that will be returned by UserRepository.CheckInviteLimit +func (mmCheckInviteLimit *mUserRepositoryMockCheckInviteLimit) Return(b1 bool, err error) *UserRepositoryMock { + if mmCheckInviteLimit.mock.funcCheckInviteLimit != nil { + mmCheckInviteLimit.mock.t.Fatalf("UserRepositoryMock.CheckInviteLimit mock is already set by Set") + } + + if mmCheckInviteLimit.defaultExpectation == nil { + mmCheckInviteLimit.defaultExpectation = &UserRepositoryMockCheckInviteLimitExpectation{mock: mmCheckInviteLimit.mock} + } + mmCheckInviteLimit.defaultExpectation.results = &UserRepositoryMockCheckInviteLimitResults{b1, err} + mmCheckInviteLimit.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmCheckInviteLimit.mock +} + +// Set uses given function f to mock the UserRepository.CheckInviteLimit method +func (mmCheckInviteLimit *mUserRepositoryMockCheckInviteLimit) Set(f func(ctx context.Context, userID int) (b1 bool, err error)) *UserRepositoryMock { + if mmCheckInviteLimit.defaultExpectation != nil { + mmCheckInviteLimit.mock.t.Fatalf("Default expectation is already set for the UserRepository.CheckInviteLimit method") + } + + if len(mmCheckInviteLimit.expectations) > 0 { + mmCheckInviteLimit.mock.t.Fatalf("Some expectations are already set for the UserRepository.CheckInviteLimit method") + } + + mmCheckInviteLimit.mock.funcCheckInviteLimit = f + mmCheckInviteLimit.mock.funcCheckInviteLimitOrigin = minimock.CallerInfo(1) + return mmCheckInviteLimit.mock +} + +// When sets expectation for the UserRepository.CheckInviteLimit which will trigger the result defined by the following +// Then helper +func (mmCheckInviteLimit *mUserRepositoryMockCheckInviteLimit) When(ctx context.Context, userID int) *UserRepositoryMockCheckInviteLimitExpectation { + if mmCheckInviteLimit.mock.funcCheckInviteLimit != nil { + mmCheckInviteLimit.mock.t.Fatalf("UserRepositoryMock.CheckInviteLimit mock is already set by Set") + } + + expectation := &UserRepositoryMockCheckInviteLimitExpectation{ + mock: mmCheckInviteLimit.mock, + params: &UserRepositoryMockCheckInviteLimitParams{ctx, userID}, + expectationOrigins: UserRepositoryMockCheckInviteLimitExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmCheckInviteLimit.expectations = append(mmCheckInviteLimit.expectations, expectation) + return expectation +} + +// Then sets up UserRepository.CheckInviteLimit return parameters for the expectation previously defined by the When method +func (e *UserRepositoryMockCheckInviteLimitExpectation) Then(b1 bool, err error) *UserRepositoryMock { + e.results = &UserRepositoryMockCheckInviteLimitResults{b1, err} + return e.mock +} + +// Times sets number of times UserRepository.CheckInviteLimit should be invoked +func (mmCheckInviteLimit *mUserRepositoryMockCheckInviteLimit) Times(n uint64) *mUserRepositoryMockCheckInviteLimit { + if n == 0 { + mmCheckInviteLimit.mock.t.Fatalf("Times of UserRepositoryMock.CheckInviteLimit mock can not be zero") + } + mm_atomic.StoreUint64(&mmCheckInviteLimit.expectedInvocations, n) + mmCheckInviteLimit.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmCheckInviteLimit +} + +func (mmCheckInviteLimit *mUserRepositoryMockCheckInviteLimit) invocationsDone() bool { + if len(mmCheckInviteLimit.expectations) == 0 && mmCheckInviteLimit.defaultExpectation == nil && mmCheckInviteLimit.mock.funcCheckInviteLimit == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmCheckInviteLimit.mock.afterCheckInviteLimitCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmCheckInviteLimit.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// CheckInviteLimit implements mm_repository.UserRepository +func (mmCheckInviteLimit *UserRepositoryMock) CheckInviteLimit(ctx context.Context, userID int) (b1 bool, err error) { + mm_atomic.AddUint64(&mmCheckInviteLimit.beforeCheckInviteLimitCounter, 1) + defer mm_atomic.AddUint64(&mmCheckInviteLimit.afterCheckInviteLimitCounter, 1) + + mmCheckInviteLimit.t.Helper() + + if mmCheckInviteLimit.inspectFuncCheckInviteLimit != nil { + mmCheckInviteLimit.inspectFuncCheckInviteLimit(ctx, userID) + } + + mm_params := UserRepositoryMockCheckInviteLimitParams{ctx, userID} + + // Record call args + mmCheckInviteLimit.CheckInviteLimitMock.mutex.Lock() + mmCheckInviteLimit.CheckInviteLimitMock.callArgs = append(mmCheckInviteLimit.CheckInviteLimitMock.callArgs, &mm_params) + mmCheckInviteLimit.CheckInviteLimitMock.mutex.Unlock() + + for _, e := range mmCheckInviteLimit.CheckInviteLimitMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.b1, e.results.err + } + } + + if mmCheckInviteLimit.CheckInviteLimitMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmCheckInviteLimit.CheckInviteLimitMock.defaultExpectation.Counter, 1) + mm_want := mmCheckInviteLimit.CheckInviteLimitMock.defaultExpectation.params + mm_want_ptrs := mmCheckInviteLimit.CheckInviteLimitMock.defaultExpectation.paramPtrs + + mm_got := UserRepositoryMockCheckInviteLimitParams{ctx, userID} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmCheckInviteLimit.t.Errorf("UserRepositoryMock.CheckInviteLimit got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmCheckInviteLimit.CheckInviteLimitMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.userID != nil && !minimock.Equal(*mm_want_ptrs.userID, mm_got.userID) { + mmCheckInviteLimit.t.Errorf("UserRepositoryMock.CheckInviteLimit got unexpected parameter userID, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmCheckInviteLimit.CheckInviteLimitMock.defaultExpectation.expectationOrigins.originUserID, *mm_want_ptrs.userID, mm_got.userID, minimock.Diff(*mm_want_ptrs.userID, mm_got.userID)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmCheckInviteLimit.t.Errorf("UserRepositoryMock.CheckInviteLimit got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmCheckInviteLimit.CheckInviteLimitMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmCheckInviteLimit.CheckInviteLimitMock.defaultExpectation.results + if mm_results == nil { + mmCheckInviteLimit.t.Fatal("No results are set for the UserRepositoryMock.CheckInviteLimit") + } + return (*mm_results).b1, (*mm_results).err + } + if mmCheckInviteLimit.funcCheckInviteLimit != nil { + return mmCheckInviteLimit.funcCheckInviteLimit(ctx, userID) + } + mmCheckInviteLimit.t.Fatalf("Unexpected call to UserRepositoryMock.CheckInviteLimit. %v %v", ctx, userID) + return +} + +// CheckInviteLimitAfterCounter returns a count of finished UserRepositoryMock.CheckInviteLimit invocations +func (mmCheckInviteLimit *UserRepositoryMock) CheckInviteLimitAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmCheckInviteLimit.afterCheckInviteLimitCounter) +} + +// CheckInviteLimitBeforeCounter returns a count of UserRepositoryMock.CheckInviteLimit invocations +func (mmCheckInviteLimit *UserRepositoryMock) CheckInviteLimitBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmCheckInviteLimit.beforeCheckInviteLimitCounter) +} + +// Calls returns a list of arguments used in each call to UserRepositoryMock.CheckInviteLimit. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmCheckInviteLimit *mUserRepositoryMockCheckInviteLimit) Calls() []*UserRepositoryMockCheckInviteLimitParams { + mmCheckInviteLimit.mutex.RLock() + + argCopy := make([]*UserRepositoryMockCheckInviteLimitParams, len(mmCheckInviteLimit.callArgs)) + copy(argCopy, mmCheckInviteLimit.callArgs) + + mmCheckInviteLimit.mutex.RUnlock() + + return argCopy +} + +// MinimockCheckInviteLimitDone returns true if the count of the CheckInviteLimit invocations corresponds +// the number of defined expectations +func (m *UserRepositoryMock) MinimockCheckInviteLimitDone() bool { + if m.CheckInviteLimitMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.CheckInviteLimitMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.CheckInviteLimitMock.invocationsDone() +} + +// MinimockCheckInviteLimitInspect logs each unmet expectation +func (m *UserRepositoryMock) MinimockCheckInviteLimitInspect() { + for _, e := range m.CheckInviteLimitMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to UserRepositoryMock.CheckInviteLimit at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterCheckInviteLimitCounter := mm_atomic.LoadUint64(&m.afterCheckInviteLimitCounter) + // if default expectation was set then invocations count should be greater than zero + if m.CheckInviteLimitMock.defaultExpectation != nil && afterCheckInviteLimitCounter < 1 { + if m.CheckInviteLimitMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to UserRepositoryMock.CheckInviteLimit at\n%s", m.CheckInviteLimitMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to UserRepositoryMock.CheckInviteLimit at\n%s with params: %#v", m.CheckInviteLimitMock.defaultExpectation.expectationOrigins.origin, *m.CheckInviteLimitMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcCheckInviteLimit != nil && afterCheckInviteLimitCounter < 1 { + m.t.Errorf("Expected call to UserRepositoryMock.CheckInviteLimit at\n%s", m.funcCheckInviteLimitOrigin) + } + + if !m.CheckInviteLimitMock.invocationsDone() && afterCheckInviteLimitCounter > 0 { + m.t.Errorf("Expected %d calls to UserRepositoryMock.CheckInviteLimit at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.CheckInviteLimitMock.expectedInvocations), m.CheckInviteLimitMock.expectedInvocationsOrigin, afterCheckInviteLimitCounter) + } +} + +type mUserRepositoryMockCreate struct { + optional bool + mock *UserRepositoryMock + defaultExpectation *UserRepositoryMockCreateExpectation + expectations []*UserRepositoryMockCreateExpectation + + callArgs []*UserRepositoryMockCreateParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// UserRepositoryMockCreateExpectation specifies expectation struct of the UserRepository.Create +type UserRepositoryMockCreateExpectation struct { + mock *UserRepositoryMock + params *UserRepositoryMockCreateParams + paramPtrs *UserRepositoryMockCreateParamPtrs + expectationOrigins UserRepositoryMockCreateExpectationOrigins + results *UserRepositoryMockCreateResults + returnOrigin string + Counter uint64 +} + +// UserRepositoryMockCreateParams contains parameters of the UserRepository.Create +type UserRepositoryMockCreateParams struct { + ctx context.Context + user *model.User +} + +// UserRepositoryMockCreateParamPtrs contains pointers to parameters of the UserRepository.Create +type UserRepositoryMockCreateParamPtrs struct { + ctx *context.Context + user **model.User +} + +// UserRepositoryMockCreateResults contains results of the UserRepository.Create +type UserRepositoryMockCreateResults struct { + err error +} + +// UserRepositoryMockCreateOrigins contains origins of expectations of the UserRepository.Create +type UserRepositoryMockCreateExpectationOrigins struct { + origin string + originCtx string + originUser string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmCreate *mUserRepositoryMockCreate) Optional() *mUserRepositoryMockCreate { + mmCreate.optional = true + return mmCreate +} + +// Expect sets up expected params for UserRepository.Create +func (mmCreate *mUserRepositoryMockCreate) Expect(ctx context.Context, user *model.User) *mUserRepositoryMockCreate { + if mmCreate.mock.funcCreate != nil { + mmCreate.mock.t.Fatalf("UserRepositoryMock.Create mock is already set by Set") + } + + if mmCreate.defaultExpectation == nil { + mmCreate.defaultExpectation = &UserRepositoryMockCreateExpectation{} + } + + if mmCreate.defaultExpectation.paramPtrs != nil { + mmCreate.mock.t.Fatalf("UserRepositoryMock.Create mock is already set by ExpectParams functions") + } + + mmCreate.defaultExpectation.params = &UserRepositoryMockCreateParams{ctx, user} + mmCreate.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmCreate.expectations { + if minimock.Equal(e.params, mmCreate.defaultExpectation.params) { + mmCreate.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmCreate.defaultExpectation.params) + } + } + + return mmCreate +} + +// ExpectCtxParam1 sets up expected param ctx for UserRepository.Create +func (mmCreate *mUserRepositoryMockCreate) ExpectCtxParam1(ctx context.Context) *mUserRepositoryMockCreate { + if mmCreate.mock.funcCreate != nil { + mmCreate.mock.t.Fatalf("UserRepositoryMock.Create mock is already set by Set") + } + + if mmCreate.defaultExpectation == nil { + mmCreate.defaultExpectation = &UserRepositoryMockCreateExpectation{} + } + + if mmCreate.defaultExpectation.params != nil { + mmCreate.mock.t.Fatalf("UserRepositoryMock.Create mock is already set by Expect") + } + + if mmCreate.defaultExpectation.paramPtrs == nil { + mmCreate.defaultExpectation.paramPtrs = &UserRepositoryMockCreateParamPtrs{} + } + mmCreate.defaultExpectation.paramPtrs.ctx = &ctx + mmCreate.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmCreate +} + +// ExpectUserParam2 sets up expected param user for UserRepository.Create +func (mmCreate *mUserRepositoryMockCreate) ExpectUserParam2(user *model.User) *mUserRepositoryMockCreate { + if mmCreate.mock.funcCreate != nil { + mmCreate.mock.t.Fatalf("UserRepositoryMock.Create mock is already set by Set") + } + + if mmCreate.defaultExpectation == nil { + mmCreate.defaultExpectation = &UserRepositoryMockCreateExpectation{} + } + + if mmCreate.defaultExpectation.params != nil { + mmCreate.mock.t.Fatalf("UserRepositoryMock.Create mock is already set by Expect") + } + + if mmCreate.defaultExpectation.paramPtrs == nil { + mmCreate.defaultExpectation.paramPtrs = &UserRepositoryMockCreateParamPtrs{} + } + mmCreate.defaultExpectation.paramPtrs.user = &user + mmCreate.defaultExpectation.expectationOrigins.originUser = minimock.CallerInfo(1) + + return mmCreate +} + +// Inspect accepts an inspector function that has same arguments as the UserRepository.Create +func (mmCreate *mUserRepositoryMockCreate) Inspect(f func(ctx context.Context, user *model.User)) *mUserRepositoryMockCreate { + if mmCreate.mock.inspectFuncCreate != nil { + mmCreate.mock.t.Fatalf("Inspect function is already set for UserRepositoryMock.Create") + } + + mmCreate.mock.inspectFuncCreate = f + + return mmCreate +} + +// Return sets up results that will be returned by UserRepository.Create +func (mmCreate *mUserRepositoryMockCreate) Return(err error) *UserRepositoryMock { + if mmCreate.mock.funcCreate != nil { + mmCreate.mock.t.Fatalf("UserRepositoryMock.Create mock is already set by Set") + } + + if mmCreate.defaultExpectation == nil { + mmCreate.defaultExpectation = &UserRepositoryMockCreateExpectation{mock: mmCreate.mock} + } + mmCreate.defaultExpectation.results = &UserRepositoryMockCreateResults{err} + mmCreate.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmCreate.mock +} + +// Set uses given function f to mock the UserRepository.Create method +func (mmCreate *mUserRepositoryMockCreate) Set(f func(ctx context.Context, user *model.User) (err error)) *UserRepositoryMock { + if mmCreate.defaultExpectation != nil { + mmCreate.mock.t.Fatalf("Default expectation is already set for the UserRepository.Create method") + } + + if len(mmCreate.expectations) > 0 { + mmCreate.mock.t.Fatalf("Some expectations are already set for the UserRepository.Create method") + } + + mmCreate.mock.funcCreate = f + mmCreate.mock.funcCreateOrigin = minimock.CallerInfo(1) + return mmCreate.mock +} + +// When sets expectation for the UserRepository.Create which will trigger the result defined by the following +// Then helper +func (mmCreate *mUserRepositoryMockCreate) When(ctx context.Context, user *model.User) *UserRepositoryMockCreateExpectation { + if mmCreate.mock.funcCreate != nil { + mmCreate.mock.t.Fatalf("UserRepositoryMock.Create mock is already set by Set") + } + + expectation := &UserRepositoryMockCreateExpectation{ + mock: mmCreate.mock, + params: &UserRepositoryMockCreateParams{ctx, user}, + expectationOrigins: UserRepositoryMockCreateExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmCreate.expectations = append(mmCreate.expectations, expectation) + return expectation +} + +// Then sets up UserRepository.Create return parameters for the expectation previously defined by the When method +func (e *UserRepositoryMockCreateExpectation) Then(err error) *UserRepositoryMock { + e.results = &UserRepositoryMockCreateResults{err} + return e.mock +} + +// Times sets number of times UserRepository.Create should be invoked +func (mmCreate *mUserRepositoryMockCreate) Times(n uint64) *mUserRepositoryMockCreate { + if n == 0 { + mmCreate.mock.t.Fatalf("Times of UserRepositoryMock.Create mock can not be zero") + } + mm_atomic.StoreUint64(&mmCreate.expectedInvocations, n) + mmCreate.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmCreate +} + +func (mmCreate *mUserRepositoryMockCreate) invocationsDone() bool { + if len(mmCreate.expectations) == 0 && mmCreate.defaultExpectation == nil && mmCreate.mock.funcCreate == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmCreate.mock.afterCreateCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmCreate.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// Create implements mm_repository.UserRepository +func (mmCreate *UserRepositoryMock) Create(ctx context.Context, user *model.User) (err error) { + mm_atomic.AddUint64(&mmCreate.beforeCreateCounter, 1) + defer mm_atomic.AddUint64(&mmCreate.afterCreateCounter, 1) + + mmCreate.t.Helper() + + if mmCreate.inspectFuncCreate != nil { + mmCreate.inspectFuncCreate(ctx, user) + } + + mm_params := UserRepositoryMockCreateParams{ctx, user} + + // Record call args + mmCreate.CreateMock.mutex.Lock() + mmCreate.CreateMock.callArgs = append(mmCreate.CreateMock.callArgs, &mm_params) + mmCreate.CreateMock.mutex.Unlock() + + for _, e := range mmCreate.CreateMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.err + } + } + + if mmCreate.CreateMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmCreate.CreateMock.defaultExpectation.Counter, 1) + mm_want := mmCreate.CreateMock.defaultExpectation.params + mm_want_ptrs := mmCreate.CreateMock.defaultExpectation.paramPtrs + + mm_got := UserRepositoryMockCreateParams{ctx, user} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmCreate.t.Errorf("UserRepositoryMock.Create got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmCreate.CreateMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.user != nil && !minimock.Equal(*mm_want_ptrs.user, mm_got.user) { + mmCreate.t.Errorf("UserRepositoryMock.Create got unexpected parameter user, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmCreate.CreateMock.defaultExpectation.expectationOrigins.originUser, *mm_want_ptrs.user, mm_got.user, minimock.Diff(*mm_want_ptrs.user, mm_got.user)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmCreate.t.Errorf("UserRepositoryMock.Create got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmCreate.CreateMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmCreate.CreateMock.defaultExpectation.results + if mm_results == nil { + mmCreate.t.Fatal("No results are set for the UserRepositoryMock.Create") + } + return (*mm_results).err + } + if mmCreate.funcCreate != nil { + return mmCreate.funcCreate(ctx, user) + } + mmCreate.t.Fatalf("Unexpected call to UserRepositoryMock.Create. %v %v", ctx, user) + return +} + +// CreateAfterCounter returns a count of finished UserRepositoryMock.Create invocations +func (mmCreate *UserRepositoryMock) CreateAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmCreate.afterCreateCounter) +} + +// CreateBeforeCounter returns a count of UserRepositoryMock.Create invocations +func (mmCreate *UserRepositoryMock) CreateBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmCreate.beforeCreateCounter) +} + +// Calls returns a list of arguments used in each call to UserRepositoryMock.Create. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmCreate *mUserRepositoryMockCreate) Calls() []*UserRepositoryMockCreateParams { + mmCreate.mutex.RLock() + + argCopy := make([]*UserRepositoryMockCreateParams, len(mmCreate.callArgs)) + copy(argCopy, mmCreate.callArgs) + + mmCreate.mutex.RUnlock() + + return argCopy +} + +// MinimockCreateDone returns true if the count of the Create invocations corresponds +// the number of defined expectations +func (m *UserRepositoryMock) MinimockCreateDone() bool { + if m.CreateMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.CreateMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.CreateMock.invocationsDone() +} + +// MinimockCreateInspect logs each unmet expectation +func (m *UserRepositoryMock) MinimockCreateInspect() { + for _, e := range m.CreateMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to UserRepositoryMock.Create at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterCreateCounter := mm_atomic.LoadUint64(&m.afterCreateCounter) + // if default expectation was set then invocations count should be greater than zero + if m.CreateMock.defaultExpectation != nil && afterCreateCounter < 1 { + if m.CreateMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to UserRepositoryMock.Create at\n%s", m.CreateMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to UserRepositoryMock.Create at\n%s with params: %#v", m.CreateMock.defaultExpectation.expectationOrigins.origin, *m.CreateMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcCreate != nil && afterCreateCounter < 1 { + m.t.Errorf("Expected call to UserRepositoryMock.Create at\n%s", m.funcCreateOrigin) + } + + if !m.CreateMock.invocationsDone() && afterCreateCounter > 0 { + m.t.Errorf("Expected %d calls to UserRepositoryMock.Create at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.CreateMock.expectedInvocations), m.CreateMock.expectedInvocationsOrigin, afterCreateCounter) + } +} + +type mUserRepositoryMockFindByEmailHash struct { + optional bool + mock *UserRepositoryMock + defaultExpectation *UserRepositoryMockFindByEmailHashExpectation + expectations []*UserRepositoryMockFindByEmailHashExpectation + + callArgs []*UserRepositoryMockFindByEmailHashParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// UserRepositoryMockFindByEmailHashExpectation specifies expectation struct of the UserRepository.FindByEmailHash +type UserRepositoryMockFindByEmailHashExpectation struct { + mock *UserRepositoryMock + params *UserRepositoryMockFindByEmailHashParams + paramPtrs *UserRepositoryMockFindByEmailHashParamPtrs + expectationOrigins UserRepositoryMockFindByEmailHashExpectationOrigins + results *UserRepositoryMockFindByEmailHashResults + returnOrigin string + Counter uint64 +} + +// UserRepositoryMockFindByEmailHashParams contains parameters of the UserRepository.FindByEmailHash +type UserRepositoryMockFindByEmailHashParams struct { + ctx context.Context + emailHash string +} + +// UserRepositoryMockFindByEmailHashParamPtrs contains pointers to parameters of the UserRepository.FindByEmailHash +type UserRepositoryMockFindByEmailHashParamPtrs struct { + ctx *context.Context + emailHash *string +} + +// UserRepositoryMockFindByEmailHashResults contains results of the UserRepository.FindByEmailHash +type UserRepositoryMockFindByEmailHashResults struct { + up1 *model.User + err error +} + +// UserRepositoryMockFindByEmailHashOrigins contains origins of expectations of the UserRepository.FindByEmailHash +type UserRepositoryMockFindByEmailHashExpectationOrigins struct { + origin string + originCtx string + originEmailHash string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmFindByEmailHash *mUserRepositoryMockFindByEmailHash) Optional() *mUserRepositoryMockFindByEmailHash { + mmFindByEmailHash.optional = true + return mmFindByEmailHash +} + +// Expect sets up expected params for UserRepository.FindByEmailHash +func (mmFindByEmailHash *mUserRepositoryMockFindByEmailHash) Expect(ctx context.Context, emailHash string) *mUserRepositoryMockFindByEmailHash { + if mmFindByEmailHash.mock.funcFindByEmailHash != nil { + mmFindByEmailHash.mock.t.Fatalf("UserRepositoryMock.FindByEmailHash mock is already set by Set") + } + + if mmFindByEmailHash.defaultExpectation == nil { + mmFindByEmailHash.defaultExpectation = &UserRepositoryMockFindByEmailHashExpectation{} + } + + if mmFindByEmailHash.defaultExpectation.paramPtrs != nil { + mmFindByEmailHash.mock.t.Fatalf("UserRepositoryMock.FindByEmailHash mock is already set by ExpectParams functions") + } + + mmFindByEmailHash.defaultExpectation.params = &UserRepositoryMockFindByEmailHashParams{ctx, emailHash} + mmFindByEmailHash.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmFindByEmailHash.expectations { + if minimock.Equal(e.params, mmFindByEmailHash.defaultExpectation.params) { + mmFindByEmailHash.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmFindByEmailHash.defaultExpectation.params) + } + } + + return mmFindByEmailHash +} + +// ExpectCtxParam1 sets up expected param ctx for UserRepository.FindByEmailHash +func (mmFindByEmailHash *mUserRepositoryMockFindByEmailHash) ExpectCtxParam1(ctx context.Context) *mUserRepositoryMockFindByEmailHash { + if mmFindByEmailHash.mock.funcFindByEmailHash != nil { + mmFindByEmailHash.mock.t.Fatalf("UserRepositoryMock.FindByEmailHash mock is already set by Set") + } + + if mmFindByEmailHash.defaultExpectation == nil { + mmFindByEmailHash.defaultExpectation = &UserRepositoryMockFindByEmailHashExpectation{} + } + + if mmFindByEmailHash.defaultExpectation.params != nil { + mmFindByEmailHash.mock.t.Fatalf("UserRepositoryMock.FindByEmailHash mock is already set by Expect") + } + + if mmFindByEmailHash.defaultExpectation.paramPtrs == nil { + mmFindByEmailHash.defaultExpectation.paramPtrs = &UserRepositoryMockFindByEmailHashParamPtrs{} + } + mmFindByEmailHash.defaultExpectation.paramPtrs.ctx = &ctx + mmFindByEmailHash.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmFindByEmailHash +} + +// ExpectEmailHashParam2 sets up expected param emailHash for UserRepository.FindByEmailHash +func (mmFindByEmailHash *mUserRepositoryMockFindByEmailHash) ExpectEmailHashParam2(emailHash string) *mUserRepositoryMockFindByEmailHash { + if mmFindByEmailHash.mock.funcFindByEmailHash != nil { + mmFindByEmailHash.mock.t.Fatalf("UserRepositoryMock.FindByEmailHash mock is already set by Set") + } + + if mmFindByEmailHash.defaultExpectation == nil { + mmFindByEmailHash.defaultExpectation = &UserRepositoryMockFindByEmailHashExpectation{} + } + + if mmFindByEmailHash.defaultExpectation.params != nil { + mmFindByEmailHash.mock.t.Fatalf("UserRepositoryMock.FindByEmailHash mock is already set by Expect") + } + + if mmFindByEmailHash.defaultExpectation.paramPtrs == nil { + mmFindByEmailHash.defaultExpectation.paramPtrs = &UserRepositoryMockFindByEmailHashParamPtrs{} + } + mmFindByEmailHash.defaultExpectation.paramPtrs.emailHash = &emailHash + mmFindByEmailHash.defaultExpectation.expectationOrigins.originEmailHash = minimock.CallerInfo(1) + + return mmFindByEmailHash +} + +// Inspect accepts an inspector function that has same arguments as the UserRepository.FindByEmailHash +func (mmFindByEmailHash *mUserRepositoryMockFindByEmailHash) Inspect(f func(ctx context.Context, emailHash string)) *mUserRepositoryMockFindByEmailHash { + if mmFindByEmailHash.mock.inspectFuncFindByEmailHash != nil { + mmFindByEmailHash.mock.t.Fatalf("Inspect function is already set for UserRepositoryMock.FindByEmailHash") + } + + mmFindByEmailHash.mock.inspectFuncFindByEmailHash = f + + return mmFindByEmailHash +} + +// Return sets up results that will be returned by UserRepository.FindByEmailHash +func (mmFindByEmailHash *mUserRepositoryMockFindByEmailHash) Return(up1 *model.User, err error) *UserRepositoryMock { + if mmFindByEmailHash.mock.funcFindByEmailHash != nil { + mmFindByEmailHash.mock.t.Fatalf("UserRepositoryMock.FindByEmailHash mock is already set by Set") + } + + if mmFindByEmailHash.defaultExpectation == nil { + mmFindByEmailHash.defaultExpectation = &UserRepositoryMockFindByEmailHashExpectation{mock: mmFindByEmailHash.mock} + } + mmFindByEmailHash.defaultExpectation.results = &UserRepositoryMockFindByEmailHashResults{up1, err} + mmFindByEmailHash.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmFindByEmailHash.mock +} + +// Set uses given function f to mock the UserRepository.FindByEmailHash method +func (mmFindByEmailHash *mUserRepositoryMockFindByEmailHash) Set(f func(ctx context.Context, emailHash string) (up1 *model.User, err error)) *UserRepositoryMock { + if mmFindByEmailHash.defaultExpectation != nil { + mmFindByEmailHash.mock.t.Fatalf("Default expectation is already set for the UserRepository.FindByEmailHash method") + } + + if len(mmFindByEmailHash.expectations) > 0 { + mmFindByEmailHash.mock.t.Fatalf("Some expectations are already set for the UserRepository.FindByEmailHash method") + } + + mmFindByEmailHash.mock.funcFindByEmailHash = f + mmFindByEmailHash.mock.funcFindByEmailHashOrigin = minimock.CallerInfo(1) + return mmFindByEmailHash.mock +} + +// When sets expectation for the UserRepository.FindByEmailHash which will trigger the result defined by the following +// Then helper +func (mmFindByEmailHash *mUserRepositoryMockFindByEmailHash) When(ctx context.Context, emailHash string) *UserRepositoryMockFindByEmailHashExpectation { + if mmFindByEmailHash.mock.funcFindByEmailHash != nil { + mmFindByEmailHash.mock.t.Fatalf("UserRepositoryMock.FindByEmailHash mock is already set by Set") + } + + expectation := &UserRepositoryMockFindByEmailHashExpectation{ + mock: mmFindByEmailHash.mock, + params: &UserRepositoryMockFindByEmailHashParams{ctx, emailHash}, + expectationOrigins: UserRepositoryMockFindByEmailHashExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmFindByEmailHash.expectations = append(mmFindByEmailHash.expectations, expectation) + return expectation +} + +// Then sets up UserRepository.FindByEmailHash return parameters for the expectation previously defined by the When method +func (e *UserRepositoryMockFindByEmailHashExpectation) Then(up1 *model.User, err error) *UserRepositoryMock { + e.results = &UserRepositoryMockFindByEmailHashResults{up1, err} + return e.mock +} + +// Times sets number of times UserRepository.FindByEmailHash should be invoked +func (mmFindByEmailHash *mUserRepositoryMockFindByEmailHash) Times(n uint64) *mUserRepositoryMockFindByEmailHash { + if n == 0 { + mmFindByEmailHash.mock.t.Fatalf("Times of UserRepositoryMock.FindByEmailHash mock can not be zero") + } + mm_atomic.StoreUint64(&mmFindByEmailHash.expectedInvocations, n) + mmFindByEmailHash.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmFindByEmailHash +} + +func (mmFindByEmailHash *mUserRepositoryMockFindByEmailHash) invocationsDone() bool { + if len(mmFindByEmailHash.expectations) == 0 && mmFindByEmailHash.defaultExpectation == nil && mmFindByEmailHash.mock.funcFindByEmailHash == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmFindByEmailHash.mock.afterFindByEmailHashCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmFindByEmailHash.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// FindByEmailHash implements mm_repository.UserRepository +func (mmFindByEmailHash *UserRepositoryMock) FindByEmailHash(ctx context.Context, emailHash string) (up1 *model.User, err error) { + mm_atomic.AddUint64(&mmFindByEmailHash.beforeFindByEmailHashCounter, 1) + defer mm_atomic.AddUint64(&mmFindByEmailHash.afterFindByEmailHashCounter, 1) + + mmFindByEmailHash.t.Helper() + + if mmFindByEmailHash.inspectFuncFindByEmailHash != nil { + mmFindByEmailHash.inspectFuncFindByEmailHash(ctx, emailHash) + } + + mm_params := UserRepositoryMockFindByEmailHashParams{ctx, emailHash} + + // Record call args + mmFindByEmailHash.FindByEmailHashMock.mutex.Lock() + mmFindByEmailHash.FindByEmailHashMock.callArgs = append(mmFindByEmailHash.FindByEmailHashMock.callArgs, &mm_params) + mmFindByEmailHash.FindByEmailHashMock.mutex.Unlock() + + for _, e := range mmFindByEmailHash.FindByEmailHashMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.up1, e.results.err + } + } + + if mmFindByEmailHash.FindByEmailHashMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmFindByEmailHash.FindByEmailHashMock.defaultExpectation.Counter, 1) + mm_want := mmFindByEmailHash.FindByEmailHashMock.defaultExpectation.params + mm_want_ptrs := mmFindByEmailHash.FindByEmailHashMock.defaultExpectation.paramPtrs + + mm_got := UserRepositoryMockFindByEmailHashParams{ctx, emailHash} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmFindByEmailHash.t.Errorf("UserRepositoryMock.FindByEmailHash got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmFindByEmailHash.FindByEmailHashMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.emailHash != nil && !minimock.Equal(*mm_want_ptrs.emailHash, mm_got.emailHash) { + mmFindByEmailHash.t.Errorf("UserRepositoryMock.FindByEmailHash got unexpected parameter emailHash, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmFindByEmailHash.FindByEmailHashMock.defaultExpectation.expectationOrigins.originEmailHash, *mm_want_ptrs.emailHash, mm_got.emailHash, minimock.Diff(*mm_want_ptrs.emailHash, mm_got.emailHash)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmFindByEmailHash.t.Errorf("UserRepositoryMock.FindByEmailHash got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmFindByEmailHash.FindByEmailHashMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmFindByEmailHash.FindByEmailHashMock.defaultExpectation.results + if mm_results == nil { + mmFindByEmailHash.t.Fatal("No results are set for the UserRepositoryMock.FindByEmailHash") + } + return (*mm_results).up1, (*mm_results).err + } + if mmFindByEmailHash.funcFindByEmailHash != nil { + return mmFindByEmailHash.funcFindByEmailHash(ctx, emailHash) + } + mmFindByEmailHash.t.Fatalf("Unexpected call to UserRepositoryMock.FindByEmailHash. %v %v", ctx, emailHash) + return +} + +// FindByEmailHashAfterCounter returns a count of finished UserRepositoryMock.FindByEmailHash invocations +func (mmFindByEmailHash *UserRepositoryMock) FindByEmailHashAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmFindByEmailHash.afterFindByEmailHashCounter) +} + +// FindByEmailHashBeforeCounter returns a count of UserRepositoryMock.FindByEmailHash invocations +func (mmFindByEmailHash *UserRepositoryMock) FindByEmailHashBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmFindByEmailHash.beforeFindByEmailHashCounter) +} + +// Calls returns a list of arguments used in each call to UserRepositoryMock.FindByEmailHash. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmFindByEmailHash *mUserRepositoryMockFindByEmailHash) Calls() []*UserRepositoryMockFindByEmailHashParams { + mmFindByEmailHash.mutex.RLock() + + argCopy := make([]*UserRepositoryMockFindByEmailHashParams, len(mmFindByEmailHash.callArgs)) + copy(argCopy, mmFindByEmailHash.callArgs) + + mmFindByEmailHash.mutex.RUnlock() + + return argCopy +} + +// MinimockFindByEmailHashDone returns true if the count of the FindByEmailHash invocations corresponds +// the number of defined expectations +func (m *UserRepositoryMock) MinimockFindByEmailHashDone() bool { + if m.FindByEmailHashMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.FindByEmailHashMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.FindByEmailHashMock.invocationsDone() +} + +// MinimockFindByEmailHashInspect logs each unmet expectation +func (m *UserRepositoryMock) MinimockFindByEmailHashInspect() { + for _, e := range m.FindByEmailHashMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to UserRepositoryMock.FindByEmailHash at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterFindByEmailHashCounter := mm_atomic.LoadUint64(&m.afterFindByEmailHashCounter) + // if default expectation was set then invocations count should be greater than zero + if m.FindByEmailHashMock.defaultExpectation != nil && afterFindByEmailHashCounter < 1 { + if m.FindByEmailHashMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to UserRepositoryMock.FindByEmailHash at\n%s", m.FindByEmailHashMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to UserRepositoryMock.FindByEmailHash at\n%s with params: %#v", m.FindByEmailHashMock.defaultExpectation.expectationOrigins.origin, *m.FindByEmailHashMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcFindByEmailHash != nil && afterFindByEmailHashCounter < 1 { + m.t.Errorf("Expected call to UserRepositoryMock.FindByEmailHash at\n%s", m.funcFindByEmailHashOrigin) + } + + if !m.FindByEmailHashMock.invocationsDone() && afterFindByEmailHashCounter > 0 { + m.t.Errorf("Expected %d calls to UserRepositoryMock.FindByEmailHash at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.FindByEmailHashMock.expectedInvocations), m.FindByEmailHashMock.expectedInvocationsOrigin, afterFindByEmailHashCounter) + } +} + +type mUserRepositoryMockFindByID struct { + optional bool + mock *UserRepositoryMock + defaultExpectation *UserRepositoryMockFindByIDExpectation + expectations []*UserRepositoryMockFindByIDExpectation + + callArgs []*UserRepositoryMockFindByIDParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// UserRepositoryMockFindByIDExpectation specifies expectation struct of the UserRepository.FindByID +type UserRepositoryMockFindByIDExpectation struct { + mock *UserRepositoryMock + params *UserRepositoryMockFindByIDParams + paramPtrs *UserRepositoryMockFindByIDParamPtrs + expectationOrigins UserRepositoryMockFindByIDExpectationOrigins + results *UserRepositoryMockFindByIDResults + returnOrigin string + Counter uint64 +} + +// UserRepositoryMockFindByIDParams contains parameters of the UserRepository.FindByID +type UserRepositoryMockFindByIDParams struct { + ctx context.Context + userID int +} + +// UserRepositoryMockFindByIDParamPtrs contains pointers to parameters of the UserRepository.FindByID +type UserRepositoryMockFindByIDParamPtrs struct { + ctx *context.Context + userID *int +} + +// UserRepositoryMockFindByIDResults contains results of the UserRepository.FindByID +type UserRepositoryMockFindByIDResults struct { + up1 *model.User + err error +} + +// UserRepositoryMockFindByIDOrigins contains origins of expectations of the UserRepository.FindByID +type UserRepositoryMockFindByIDExpectationOrigins struct { + origin string + originCtx string + originUserID string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmFindByID *mUserRepositoryMockFindByID) Optional() *mUserRepositoryMockFindByID { + mmFindByID.optional = true + return mmFindByID +} + +// Expect sets up expected params for UserRepository.FindByID +func (mmFindByID *mUserRepositoryMockFindByID) Expect(ctx context.Context, userID int) *mUserRepositoryMockFindByID { + if mmFindByID.mock.funcFindByID != nil { + mmFindByID.mock.t.Fatalf("UserRepositoryMock.FindByID mock is already set by Set") + } + + if mmFindByID.defaultExpectation == nil { + mmFindByID.defaultExpectation = &UserRepositoryMockFindByIDExpectation{} + } + + if mmFindByID.defaultExpectation.paramPtrs != nil { + mmFindByID.mock.t.Fatalf("UserRepositoryMock.FindByID mock is already set by ExpectParams functions") + } + + mmFindByID.defaultExpectation.params = &UserRepositoryMockFindByIDParams{ctx, userID} + mmFindByID.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmFindByID.expectations { + if minimock.Equal(e.params, mmFindByID.defaultExpectation.params) { + mmFindByID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmFindByID.defaultExpectation.params) + } + } + + return mmFindByID +} + +// ExpectCtxParam1 sets up expected param ctx for UserRepository.FindByID +func (mmFindByID *mUserRepositoryMockFindByID) ExpectCtxParam1(ctx context.Context) *mUserRepositoryMockFindByID { + if mmFindByID.mock.funcFindByID != nil { + mmFindByID.mock.t.Fatalf("UserRepositoryMock.FindByID mock is already set by Set") + } + + if mmFindByID.defaultExpectation == nil { + mmFindByID.defaultExpectation = &UserRepositoryMockFindByIDExpectation{} + } + + if mmFindByID.defaultExpectation.params != nil { + mmFindByID.mock.t.Fatalf("UserRepositoryMock.FindByID mock is already set by Expect") + } + + if mmFindByID.defaultExpectation.paramPtrs == nil { + mmFindByID.defaultExpectation.paramPtrs = &UserRepositoryMockFindByIDParamPtrs{} + } + mmFindByID.defaultExpectation.paramPtrs.ctx = &ctx + mmFindByID.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmFindByID +} + +// ExpectUserIDParam2 sets up expected param userID for UserRepository.FindByID +func (mmFindByID *mUserRepositoryMockFindByID) ExpectUserIDParam2(userID int) *mUserRepositoryMockFindByID { + if mmFindByID.mock.funcFindByID != nil { + mmFindByID.mock.t.Fatalf("UserRepositoryMock.FindByID mock is already set by Set") + } + + if mmFindByID.defaultExpectation == nil { + mmFindByID.defaultExpectation = &UserRepositoryMockFindByIDExpectation{} + } + + if mmFindByID.defaultExpectation.params != nil { + mmFindByID.mock.t.Fatalf("UserRepositoryMock.FindByID mock is already set by Expect") + } + + if mmFindByID.defaultExpectation.paramPtrs == nil { + mmFindByID.defaultExpectation.paramPtrs = &UserRepositoryMockFindByIDParamPtrs{} + } + mmFindByID.defaultExpectation.paramPtrs.userID = &userID + mmFindByID.defaultExpectation.expectationOrigins.originUserID = minimock.CallerInfo(1) + + return mmFindByID +} + +// Inspect accepts an inspector function that has same arguments as the UserRepository.FindByID +func (mmFindByID *mUserRepositoryMockFindByID) Inspect(f func(ctx context.Context, userID int)) *mUserRepositoryMockFindByID { + if mmFindByID.mock.inspectFuncFindByID != nil { + mmFindByID.mock.t.Fatalf("Inspect function is already set for UserRepositoryMock.FindByID") + } + + mmFindByID.mock.inspectFuncFindByID = f + + return mmFindByID +} + +// Return sets up results that will be returned by UserRepository.FindByID +func (mmFindByID *mUserRepositoryMockFindByID) Return(up1 *model.User, err error) *UserRepositoryMock { + if mmFindByID.mock.funcFindByID != nil { + mmFindByID.mock.t.Fatalf("UserRepositoryMock.FindByID mock is already set by Set") + } + + if mmFindByID.defaultExpectation == nil { + mmFindByID.defaultExpectation = &UserRepositoryMockFindByIDExpectation{mock: mmFindByID.mock} + } + mmFindByID.defaultExpectation.results = &UserRepositoryMockFindByIDResults{up1, err} + mmFindByID.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmFindByID.mock +} + +// Set uses given function f to mock the UserRepository.FindByID method +func (mmFindByID *mUserRepositoryMockFindByID) Set(f func(ctx context.Context, userID int) (up1 *model.User, err error)) *UserRepositoryMock { + if mmFindByID.defaultExpectation != nil { + mmFindByID.mock.t.Fatalf("Default expectation is already set for the UserRepository.FindByID method") + } + + if len(mmFindByID.expectations) > 0 { + mmFindByID.mock.t.Fatalf("Some expectations are already set for the UserRepository.FindByID method") + } + + mmFindByID.mock.funcFindByID = f + mmFindByID.mock.funcFindByIDOrigin = minimock.CallerInfo(1) + return mmFindByID.mock +} + +// When sets expectation for the UserRepository.FindByID which will trigger the result defined by the following +// Then helper +func (mmFindByID *mUserRepositoryMockFindByID) When(ctx context.Context, userID int) *UserRepositoryMockFindByIDExpectation { + if mmFindByID.mock.funcFindByID != nil { + mmFindByID.mock.t.Fatalf("UserRepositoryMock.FindByID mock is already set by Set") + } + + expectation := &UserRepositoryMockFindByIDExpectation{ + mock: mmFindByID.mock, + params: &UserRepositoryMockFindByIDParams{ctx, userID}, + expectationOrigins: UserRepositoryMockFindByIDExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmFindByID.expectations = append(mmFindByID.expectations, expectation) + return expectation +} + +// Then sets up UserRepository.FindByID return parameters for the expectation previously defined by the When method +func (e *UserRepositoryMockFindByIDExpectation) Then(up1 *model.User, err error) *UserRepositoryMock { + e.results = &UserRepositoryMockFindByIDResults{up1, err} + return e.mock +} + +// Times sets number of times UserRepository.FindByID should be invoked +func (mmFindByID *mUserRepositoryMockFindByID) Times(n uint64) *mUserRepositoryMockFindByID { + if n == 0 { + mmFindByID.mock.t.Fatalf("Times of UserRepositoryMock.FindByID mock can not be zero") + } + mm_atomic.StoreUint64(&mmFindByID.expectedInvocations, n) + mmFindByID.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmFindByID +} + +func (mmFindByID *mUserRepositoryMockFindByID) invocationsDone() bool { + if len(mmFindByID.expectations) == 0 && mmFindByID.defaultExpectation == nil && mmFindByID.mock.funcFindByID == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmFindByID.mock.afterFindByIDCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmFindByID.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// FindByID implements mm_repository.UserRepository +func (mmFindByID *UserRepositoryMock) FindByID(ctx context.Context, userID int) (up1 *model.User, err error) { + mm_atomic.AddUint64(&mmFindByID.beforeFindByIDCounter, 1) + defer mm_atomic.AddUint64(&mmFindByID.afterFindByIDCounter, 1) + + mmFindByID.t.Helper() + + if mmFindByID.inspectFuncFindByID != nil { + mmFindByID.inspectFuncFindByID(ctx, userID) + } + + mm_params := UserRepositoryMockFindByIDParams{ctx, userID} + + // Record call args + mmFindByID.FindByIDMock.mutex.Lock() + mmFindByID.FindByIDMock.callArgs = append(mmFindByID.FindByIDMock.callArgs, &mm_params) + mmFindByID.FindByIDMock.mutex.Unlock() + + for _, e := range mmFindByID.FindByIDMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.up1, e.results.err + } + } + + if mmFindByID.FindByIDMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmFindByID.FindByIDMock.defaultExpectation.Counter, 1) + mm_want := mmFindByID.FindByIDMock.defaultExpectation.params + mm_want_ptrs := mmFindByID.FindByIDMock.defaultExpectation.paramPtrs + + mm_got := UserRepositoryMockFindByIDParams{ctx, userID} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmFindByID.t.Errorf("UserRepositoryMock.FindByID got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmFindByID.FindByIDMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.userID != nil && !minimock.Equal(*mm_want_ptrs.userID, mm_got.userID) { + mmFindByID.t.Errorf("UserRepositoryMock.FindByID got unexpected parameter userID, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmFindByID.FindByIDMock.defaultExpectation.expectationOrigins.originUserID, *mm_want_ptrs.userID, mm_got.userID, minimock.Diff(*mm_want_ptrs.userID, mm_got.userID)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmFindByID.t.Errorf("UserRepositoryMock.FindByID got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmFindByID.FindByIDMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmFindByID.FindByIDMock.defaultExpectation.results + if mm_results == nil { + mmFindByID.t.Fatal("No results are set for the UserRepositoryMock.FindByID") + } + return (*mm_results).up1, (*mm_results).err + } + if mmFindByID.funcFindByID != nil { + return mmFindByID.funcFindByID(ctx, userID) + } + mmFindByID.t.Fatalf("Unexpected call to UserRepositoryMock.FindByID. %v %v", ctx, userID) + return +} + +// FindByIDAfterCounter returns a count of finished UserRepositoryMock.FindByID invocations +func (mmFindByID *UserRepositoryMock) FindByIDAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmFindByID.afterFindByIDCounter) +} + +// FindByIDBeforeCounter returns a count of UserRepositoryMock.FindByID invocations +func (mmFindByID *UserRepositoryMock) FindByIDBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmFindByID.beforeFindByIDCounter) +} + +// Calls returns a list of arguments used in each call to UserRepositoryMock.FindByID. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmFindByID *mUserRepositoryMockFindByID) Calls() []*UserRepositoryMockFindByIDParams { + mmFindByID.mutex.RLock() + + argCopy := make([]*UserRepositoryMockFindByIDParams, len(mmFindByID.callArgs)) + copy(argCopy, mmFindByID.callArgs) + + mmFindByID.mutex.RUnlock() + + return argCopy +} + +// MinimockFindByIDDone returns true if the count of the FindByID invocations corresponds +// the number of defined expectations +func (m *UserRepositoryMock) MinimockFindByIDDone() bool { + if m.FindByIDMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.FindByIDMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.FindByIDMock.invocationsDone() +} + +// MinimockFindByIDInspect logs each unmet expectation +func (m *UserRepositoryMock) MinimockFindByIDInspect() { + for _, e := range m.FindByIDMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to UserRepositoryMock.FindByID at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterFindByIDCounter := mm_atomic.LoadUint64(&m.afterFindByIDCounter) + // if default expectation was set then invocations count should be greater than zero + if m.FindByIDMock.defaultExpectation != nil && afterFindByIDCounter < 1 { + if m.FindByIDMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to UserRepositoryMock.FindByID at\n%s", m.FindByIDMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to UserRepositoryMock.FindByID at\n%s with params: %#v", m.FindByIDMock.defaultExpectation.expectationOrigins.origin, *m.FindByIDMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcFindByID != nil && afterFindByIDCounter < 1 { + m.t.Errorf("Expected call to UserRepositoryMock.FindByID at\n%s", m.funcFindByIDOrigin) + } + + if !m.FindByIDMock.invocationsDone() && afterFindByIDCounter > 0 { + m.t.Errorf("Expected %d calls to UserRepositoryMock.FindByID at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.FindByIDMock.expectedInvocations), m.FindByIDMock.expectedInvocationsOrigin, afterFindByIDCounter) + } +} + +type mUserRepositoryMockGetBalance struct { + optional bool + mock *UserRepositoryMock + defaultExpectation *UserRepositoryMockGetBalanceExpectation + expectations []*UserRepositoryMockGetBalanceExpectation + + callArgs []*UserRepositoryMockGetBalanceParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// UserRepositoryMockGetBalanceExpectation specifies expectation struct of the UserRepository.GetBalance +type UserRepositoryMockGetBalanceExpectation struct { + mock *UserRepositoryMock + params *UserRepositoryMockGetBalanceParams + paramPtrs *UserRepositoryMockGetBalanceParamPtrs + expectationOrigins UserRepositoryMockGetBalanceExpectationOrigins + results *UserRepositoryMockGetBalanceResults + returnOrigin string + Counter uint64 +} + +// UserRepositoryMockGetBalanceParams contains parameters of the UserRepository.GetBalance +type UserRepositoryMockGetBalanceParams struct { + ctx context.Context + userID int +} + +// UserRepositoryMockGetBalanceParamPtrs contains pointers to parameters of the UserRepository.GetBalance +type UserRepositoryMockGetBalanceParamPtrs struct { + ctx *context.Context + userID *int +} + +// UserRepositoryMockGetBalanceResults contains results of the UserRepository.GetBalance +type UserRepositoryMockGetBalanceResults struct { + f1 float64 + err error +} + +// UserRepositoryMockGetBalanceOrigins contains origins of expectations of the UserRepository.GetBalance +type UserRepositoryMockGetBalanceExpectationOrigins struct { + origin string + originCtx string + originUserID string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmGetBalance *mUserRepositoryMockGetBalance) Optional() *mUserRepositoryMockGetBalance { + mmGetBalance.optional = true + return mmGetBalance +} + +// Expect sets up expected params for UserRepository.GetBalance +func (mmGetBalance *mUserRepositoryMockGetBalance) Expect(ctx context.Context, userID int) *mUserRepositoryMockGetBalance { + if mmGetBalance.mock.funcGetBalance != nil { + mmGetBalance.mock.t.Fatalf("UserRepositoryMock.GetBalance mock is already set by Set") + } + + if mmGetBalance.defaultExpectation == nil { + mmGetBalance.defaultExpectation = &UserRepositoryMockGetBalanceExpectation{} + } + + if mmGetBalance.defaultExpectation.paramPtrs != nil { + mmGetBalance.mock.t.Fatalf("UserRepositoryMock.GetBalance mock is already set by ExpectParams functions") + } + + mmGetBalance.defaultExpectation.params = &UserRepositoryMockGetBalanceParams{ctx, userID} + mmGetBalance.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmGetBalance.expectations { + if minimock.Equal(e.params, mmGetBalance.defaultExpectation.params) { + mmGetBalance.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetBalance.defaultExpectation.params) + } + } + + return mmGetBalance +} + +// ExpectCtxParam1 sets up expected param ctx for UserRepository.GetBalance +func (mmGetBalance *mUserRepositoryMockGetBalance) ExpectCtxParam1(ctx context.Context) *mUserRepositoryMockGetBalance { + if mmGetBalance.mock.funcGetBalance != nil { + mmGetBalance.mock.t.Fatalf("UserRepositoryMock.GetBalance mock is already set by Set") + } + + if mmGetBalance.defaultExpectation == nil { + mmGetBalance.defaultExpectation = &UserRepositoryMockGetBalanceExpectation{} + } + + if mmGetBalance.defaultExpectation.params != nil { + mmGetBalance.mock.t.Fatalf("UserRepositoryMock.GetBalance mock is already set by Expect") + } + + if mmGetBalance.defaultExpectation.paramPtrs == nil { + mmGetBalance.defaultExpectation.paramPtrs = &UserRepositoryMockGetBalanceParamPtrs{} + } + mmGetBalance.defaultExpectation.paramPtrs.ctx = &ctx + mmGetBalance.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmGetBalance +} + +// ExpectUserIDParam2 sets up expected param userID for UserRepository.GetBalance +func (mmGetBalance *mUserRepositoryMockGetBalance) ExpectUserIDParam2(userID int) *mUserRepositoryMockGetBalance { + if mmGetBalance.mock.funcGetBalance != nil { + mmGetBalance.mock.t.Fatalf("UserRepositoryMock.GetBalance mock is already set by Set") + } + + if mmGetBalance.defaultExpectation == nil { + mmGetBalance.defaultExpectation = &UserRepositoryMockGetBalanceExpectation{} + } + + if mmGetBalance.defaultExpectation.params != nil { + mmGetBalance.mock.t.Fatalf("UserRepositoryMock.GetBalance mock is already set by Expect") + } + + if mmGetBalance.defaultExpectation.paramPtrs == nil { + mmGetBalance.defaultExpectation.paramPtrs = &UserRepositoryMockGetBalanceParamPtrs{} + } + mmGetBalance.defaultExpectation.paramPtrs.userID = &userID + mmGetBalance.defaultExpectation.expectationOrigins.originUserID = minimock.CallerInfo(1) + + return mmGetBalance +} + +// Inspect accepts an inspector function that has same arguments as the UserRepository.GetBalance +func (mmGetBalance *mUserRepositoryMockGetBalance) Inspect(f func(ctx context.Context, userID int)) *mUserRepositoryMockGetBalance { + if mmGetBalance.mock.inspectFuncGetBalance != nil { + mmGetBalance.mock.t.Fatalf("Inspect function is already set for UserRepositoryMock.GetBalance") + } + + mmGetBalance.mock.inspectFuncGetBalance = f + + return mmGetBalance +} + +// Return sets up results that will be returned by UserRepository.GetBalance +func (mmGetBalance *mUserRepositoryMockGetBalance) Return(f1 float64, err error) *UserRepositoryMock { + if mmGetBalance.mock.funcGetBalance != nil { + mmGetBalance.mock.t.Fatalf("UserRepositoryMock.GetBalance mock is already set by Set") + } + + if mmGetBalance.defaultExpectation == nil { + mmGetBalance.defaultExpectation = &UserRepositoryMockGetBalanceExpectation{mock: mmGetBalance.mock} + } + mmGetBalance.defaultExpectation.results = &UserRepositoryMockGetBalanceResults{f1, err} + mmGetBalance.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmGetBalance.mock +} + +// Set uses given function f to mock the UserRepository.GetBalance method +func (mmGetBalance *mUserRepositoryMockGetBalance) Set(f func(ctx context.Context, userID int) (f1 float64, err error)) *UserRepositoryMock { + if mmGetBalance.defaultExpectation != nil { + mmGetBalance.mock.t.Fatalf("Default expectation is already set for the UserRepository.GetBalance method") + } + + if len(mmGetBalance.expectations) > 0 { + mmGetBalance.mock.t.Fatalf("Some expectations are already set for the UserRepository.GetBalance method") + } + + mmGetBalance.mock.funcGetBalance = f + mmGetBalance.mock.funcGetBalanceOrigin = minimock.CallerInfo(1) + return mmGetBalance.mock +} + +// When sets expectation for the UserRepository.GetBalance which will trigger the result defined by the following +// Then helper +func (mmGetBalance *mUserRepositoryMockGetBalance) When(ctx context.Context, userID int) *UserRepositoryMockGetBalanceExpectation { + if mmGetBalance.mock.funcGetBalance != nil { + mmGetBalance.mock.t.Fatalf("UserRepositoryMock.GetBalance mock is already set by Set") + } + + expectation := &UserRepositoryMockGetBalanceExpectation{ + mock: mmGetBalance.mock, + params: &UserRepositoryMockGetBalanceParams{ctx, userID}, + expectationOrigins: UserRepositoryMockGetBalanceExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmGetBalance.expectations = append(mmGetBalance.expectations, expectation) + return expectation +} + +// Then sets up UserRepository.GetBalance return parameters for the expectation previously defined by the When method +func (e *UserRepositoryMockGetBalanceExpectation) Then(f1 float64, err error) *UserRepositoryMock { + e.results = &UserRepositoryMockGetBalanceResults{f1, err} + return e.mock +} + +// Times sets number of times UserRepository.GetBalance should be invoked +func (mmGetBalance *mUserRepositoryMockGetBalance) Times(n uint64) *mUserRepositoryMockGetBalance { + if n == 0 { + mmGetBalance.mock.t.Fatalf("Times of UserRepositoryMock.GetBalance mock can not be zero") + } + mm_atomic.StoreUint64(&mmGetBalance.expectedInvocations, n) + mmGetBalance.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmGetBalance +} + +func (mmGetBalance *mUserRepositoryMockGetBalance) invocationsDone() bool { + if len(mmGetBalance.expectations) == 0 && mmGetBalance.defaultExpectation == nil && mmGetBalance.mock.funcGetBalance == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmGetBalance.mock.afterGetBalanceCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmGetBalance.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// GetBalance implements mm_repository.UserRepository +func (mmGetBalance *UserRepositoryMock) GetBalance(ctx context.Context, userID int) (f1 float64, err error) { + mm_atomic.AddUint64(&mmGetBalance.beforeGetBalanceCounter, 1) + defer mm_atomic.AddUint64(&mmGetBalance.afterGetBalanceCounter, 1) + + mmGetBalance.t.Helper() + + if mmGetBalance.inspectFuncGetBalance != nil { + mmGetBalance.inspectFuncGetBalance(ctx, userID) + } + + mm_params := UserRepositoryMockGetBalanceParams{ctx, userID} + + // Record call args + mmGetBalance.GetBalanceMock.mutex.Lock() + mmGetBalance.GetBalanceMock.callArgs = append(mmGetBalance.GetBalanceMock.callArgs, &mm_params) + mmGetBalance.GetBalanceMock.mutex.Unlock() + + for _, e := range mmGetBalance.GetBalanceMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.f1, e.results.err + } + } + + if mmGetBalance.GetBalanceMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmGetBalance.GetBalanceMock.defaultExpectation.Counter, 1) + mm_want := mmGetBalance.GetBalanceMock.defaultExpectation.params + mm_want_ptrs := mmGetBalance.GetBalanceMock.defaultExpectation.paramPtrs + + mm_got := UserRepositoryMockGetBalanceParams{ctx, userID} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmGetBalance.t.Errorf("UserRepositoryMock.GetBalance got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetBalance.GetBalanceMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.userID != nil && !minimock.Equal(*mm_want_ptrs.userID, mm_got.userID) { + mmGetBalance.t.Errorf("UserRepositoryMock.GetBalance got unexpected parameter userID, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetBalance.GetBalanceMock.defaultExpectation.expectationOrigins.originUserID, *mm_want_ptrs.userID, mm_got.userID, minimock.Diff(*mm_want_ptrs.userID, mm_got.userID)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmGetBalance.t.Errorf("UserRepositoryMock.GetBalance got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetBalance.GetBalanceMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmGetBalance.GetBalanceMock.defaultExpectation.results + if mm_results == nil { + mmGetBalance.t.Fatal("No results are set for the UserRepositoryMock.GetBalance") + } + return (*mm_results).f1, (*mm_results).err + } + if mmGetBalance.funcGetBalance != nil { + return mmGetBalance.funcGetBalance(ctx, userID) + } + mmGetBalance.t.Fatalf("Unexpected call to UserRepositoryMock.GetBalance. %v %v", ctx, userID) + return +} + +// GetBalanceAfterCounter returns a count of finished UserRepositoryMock.GetBalance invocations +func (mmGetBalance *UserRepositoryMock) GetBalanceAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetBalance.afterGetBalanceCounter) +} + +// GetBalanceBeforeCounter returns a count of UserRepositoryMock.GetBalance invocations +func (mmGetBalance *UserRepositoryMock) GetBalanceBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetBalance.beforeGetBalanceCounter) +} + +// Calls returns a list of arguments used in each call to UserRepositoryMock.GetBalance. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmGetBalance *mUserRepositoryMockGetBalance) Calls() []*UserRepositoryMockGetBalanceParams { + mmGetBalance.mutex.RLock() + + argCopy := make([]*UserRepositoryMockGetBalanceParams, len(mmGetBalance.callArgs)) + copy(argCopy, mmGetBalance.callArgs) + + mmGetBalance.mutex.RUnlock() + + return argCopy +} + +// MinimockGetBalanceDone returns true if the count of the GetBalance invocations corresponds +// the number of defined expectations +func (m *UserRepositoryMock) MinimockGetBalanceDone() bool { + if m.GetBalanceMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.GetBalanceMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.GetBalanceMock.invocationsDone() +} + +// MinimockGetBalanceInspect logs each unmet expectation +func (m *UserRepositoryMock) MinimockGetBalanceInspect() { + for _, e := range m.GetBalanceMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to UserRepositoryMock.GetBalance at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterGetBalanceCounter := mm_atomic.LoadUint64(&m.afterGetBalanceCounter) + // if default expectation was set then invocations count should be greater than zero + if m.GetBalanceMock.defaultExpectation != nil && afterGetBalanceCounter < 1 { + if m.GetBalanceMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to UserRepositoryMock.GetBalance at\n%s", m.GetBalanceMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to UserRepositoryMock.GetBalance at\n%s with params: %#v", m.GetBalanceMock.defaultExpectation.expectationOrigins.origin, *m.GetBalanceMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcGetBalance != nil && afterGetBalanceCounter < 1 { + m.t.Errorf("Expected call to UserRepositoryMock.GetBalance at\n%s", m.funcGetBalanceOrigin) + } + + if !m.GetBalanceMock.invocationsDone() && afterGetBalanceCounter > 0 { + m.t.Errorf("Expected %d calls to UserRepositoryMock.GetBalance at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.GetBalanceMock.expectedInvocations), m.GetBalanceMock.expectedInvocationsOrigin, afterGetBalanceCounter) + } +} + +type mUserRepositoryMockIncrementInvitesIssued struct { + optional bool + mock *UserRepositoryMock + defaultExpectation *UserRepositoryMockIncrementInvitesIssuedExpectation + expectations []*UserRepositoryMockIncrementInvitesIssuedExpectation + + callArgs []*UserRepositoryMockIncrementInvitesIssuedParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// UserRepositoryMockIncrementInvitesIssuedExpectation specifies expectation struct of the UserRepository.IncrementInvitesIssued +type UserRepositoryMockIncrementInvitesIssuedExpectation struct { + mock *UserRepositoryMock + params *UserRepositoryMockIncrementInvitesIssuedParams + paramPtrs *UserRepositoryMockIncrementInvitesIssuedParamPtrs + expectationOrigins UserRepositoryMockIncrementInvitesIssuedExpectationOrigins + results *UserRepositoryMockIncrementInvitesIssuedResults + returnOrigin string + Counter uint64 +} + +// UserRepositoryMockIncrementInvitesIssuedParams contains parameters of the UserRepository.IncrementInvitesIssued +type UserRepositoryMockIncrementInvitesIssuedParams struct { + ctx context.Context + userID int +} + +// UserRepositoryMockIncrementInvitesIssuedParamPtrs contains pointers to parameters of the UserRepository.IncrementInvitesIssued +type UserRepositoryMockIncrementInvitesIssuedParamPtrs struct { + ctx *context.Context + userID *int +} + +// UserRepositoryMockIncrementInvitesIssuedResults contains results of the UserRepository.IncrementInvitesIssued +type UserRepositoryMockIncrementInvitesIssuedResults struct { + err error +} + +// UserRepositoryMockIncrementInvitesIssuedOrigins contains origins of expectations of the UserRepository.IncrementInvitesIssued +type UserRepositoryMockIncrementInvitesIssuedExpectationOrigins struct { + origin string + originCtx string + originUserID string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmIncrementInvitesIssued *mUserRepositoryMockIncrementInvitesIssued) Optional() *mUserRepositoryMockIncrementInvitesIssued { + mmIncrementInvitesIssued.optional = true + return mmIncrementInvitesIssued +} + +// Expect sets up expected params for UserRepository.IncrementInvitesIssued +func (mmIncrementInvitesIssued *mUserRepositoryMockIncrementInvitesIssued) Expect(ctx context.Context, userID int) *mUserRepositoryMockIncrementInvitesIssued { + if mmIncrementInvitesIssued.mock.funcIncrementInvitesIssued != nil { + mmIncrementInvitesIssued.mock.t.Fatalf("UserRepositoryMock.IncrementInvitesIssued mock is already set by Set") + } + + if mmIncrementInvitesIssued.defaultExpectation == nil { + mmIncrementInvitesIssued.defaultExpectation = &UserRepositoryMockIncrementInvitesIssuedExpectation{} + } + + if mmIncrementInvitesIssued.defaultExpectation.paramPtrs != nil { + mmIncrementInvitesIssued.mock.t.Fatalf("UserRepositoryMock.IncrementInvitesIssued mock is already set by ExpectParams functions") + } + + mmIncrementInvitesIssued.defaultExpectation.params = &UserRepositoryMockIncrementInvitesIssuedParams{ctx, userID} + mmIncrementInvitesIssued.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmIncrementInvitesIssued.expectations { + if minimock.Equal(e.params, mmIncrementInvitesIssued.defaultExpectation.params) { + mmIncrementInvitesIssued.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmIncrementInvitesIssued.defaultExpectation.params) + } + } + + return mmIncrementInvitesIssued +} + +// ExpectCtxParam1 sets up expected param ctx for UserRepository.IncrementInvitesIssued +func (mmIncrementInvitesIssued *mUserRepositoryMockIncrementInvitesIssued) ExpectCtxParam1(ctx context.Context) *mUserRepositoryMockIncrementInvitesIssued { + if mmIncrementInvitesIssued.mock.funcIncrementInvitesIssued != nil { + mmIncrementInvitesIssued.mock.t.Fatalf("UserRepositoryMock.IncrementInvitesIssued mock is already set by Set") + } + + if mmIncrementInvitesIssued.defaultExpectation == nil { + mmIncrementInvitesIssued.defaultExpectation = &UserRepositoryMockIncrementInvitesIssuedExpectation{} + } + + if mmIncrementInvitesIssued.defaultExpectation.params != nil { + mmIncrementInvitesIssued.mock.t.Fatalf("UserRepositoryMock.IncrementInvitesIssued mock is already set by Expect") + } + + if mmIncrementInvitesIssued.defaultExpectation.paramPtrs == nil { + mmIncrementInvitesIssued.defaultExpectation.paramPtrs = &UserRepositoryMockIncrementInvitesIssuedParamPtrs{} + } + mmIncrementInvitesIssued.defaultExpectation.paramPtrs.ctx = &ctx + mmIncrementInvitesIssued.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmIncrementInvitesIssued +} + +// ExpectUserIDParam2 sets up expected param userID for UserRepository.IncrementInvitesIssued +func (mmIncrementInvitesIssued *mUserRepositoryMockIncrementInvitesIssued) ExpectUserIDParam2(userID int) *mUserRepositoryMockIncrementInvitesIssued { + if mmIncrementInvitesIssued.mock.funcIncrementInvitesIssued != nil { + mmIncrementInvitesIssued.mock.t.Fatalf("UserRepositoryMock.IncrementInvitesIssued mock is already set by Set") + } + + if mmIncrementInvitesIssued.defaultExpectation == nil { + mmIncrementInvitesIssued.defaultExpectation = &UserRepositoryMockIncrementInvitesIssuedExpectation{} + } + + if mmIncrementInvitesIssued.defaultExpectation.params != nil { + mmIncrementInvitesIssued.mock.t.Fatalf("UserRepositoryMock.IncrementInvitesIssued mock is already set by Expect") + } + + if mmIncrementInvitesIssued.defaultExpectation.paramPtrs == nil { + mmIncrementInvitesIssued.defaultExpectation.paramPtrs = &UserRepositoryMockIncrementInvitesIssuedParamPtrs{} + } + mmIncrementInvitesIssued.defaultExpectation.paramPtrs.userID = &userID + mmIncrementInvitesIssued.defaultExpectation.expectationOrigins.originUserID = minimock.CallerInfo(1) + + return mmIncrementInvitesIssued +} + +// Inspect accepts an inspector function that has same arguments as the UserRepository.IncrementInvitesIssued +func (mmIncrementInvitesIssued *mUserRepositoryMockIncrementInvitesIssued) Inspect(f func(ctx context.Context, userID int)) *mUserRepositoryMockIncrementInvitesIssued { + if mmIncrementInvitesIssued.mock.inspectFuncIncrementInvitesIssued != nil { + mmIncrementInvitesIssued.mock.t.Fatalf("Inspect function is already set for UserRepositoryMock.IncrementInvitesIssued") + } + + mmIncrementInvitesIssued.mock.inspectFuncIncrementInvitesIssued = f + + return mmIncrementInvitesIssued +} + +// Return sets up results that will be returned by UserRepository.IncrementInvitesIssued +func (mmIncrementInvitesIssued *mUserRepositoryMockIncrementInvitesIssued) Return(err error) *UserRepositoryMock { + if mmIncrementInvitesIssued.mock.funcIncrementInvitesIssued != nil { + mmIncrementInvitesIssued.mock.t.Fatalf("UserRepositoryMock.IncrementInvitesIssued mock is already set by Set") + } + + if mmIncrementInvitesIssued.defaultExpectation == nil { + mmIncrementInvitesIssued.defaultExpectation = &UserRepositoryMockIncrementInvitesIssuedExpectation{mock: mmIncrementInvitesIssued.mock} + } + mmIncrementInvitesIssued.defaultExpectation.results = &UserRepositoryMockIncrementInvitesIssuedResults{err} + mmIncrementInvitesIssued.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmIncrementInvitesIssued.mock +} + +// Set uses given function f to mock the UserRepository.IncrementInvitesIssued method +func (mmIncrementInvitesIssued *mUserRepositoryMockIncrementInvitesIssued) Set(f func(ctx context.Context, userID int) (err error)) *UserRepositoryMock { + if mmIncrementInvitesIssued.defaultExpectation != nil { + mmIncrementInvitesIssued.mock.t.Fatalf("Default expectation is already set for the UserRepository.IncrementInvitesIssued method") + } + + if len(mmIncrementInvitesIssued.expectations) > 0 { + mmIncrementInvitesIssued.mock.t.Fatalf("Some expectations are already set for the UserRepository.IncrementInvitesIssued method") + } + + mmIncrementInvitesIssued.mock.funcIncrementInvitesIssued = f + mmIncrementInvitesIssued.mock.funcIncrementInvitesIssuedOrigin = minimock.CallerInfo(1) + return mmIncrementInvitesIssued.mock +} + +// When sets expectation for the UserRepository.IncrementInvitesIssued which will trigger the result defined by the following +// Then helper +func (mmIncrementInvitesIssued *mUserRepositoryMockIncrementInvitesIssued) When(ctx context.Context, userID int) *UserRepositoryMockIncrementInvitesIssuedExpectation { + if mmIncrementInvitesIssued.mock.funcIncrementInvitesIssued != nil { + mmIncrementInvitesIssued.mock.t.Fatalf("UserRepositoryMock.IncrementInvitesIssued mock is already set by Set") + } + + expectation := &UserRepositoryMockIncrementInvitesIssuedExpectation{ + mock: mmIncrementInvitesIssued.mock, + params: &UserRepositoryMockIncrementInvitesIssuedParams{ctx, userID}, + expectationOrigins: UserRepositoryMockIncrementInvitesIssuedExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmIncrementInvitesIssued.expectations = append(mmIncrementInvitesIssued.expectations, expectation) + return expectation +} + +// Then sets up UserRepository.IncrementInvitesIssued return parameters for the expectation previously defined by the When method +func (e *UserRepositoryMockIncrementInvitesIssuedExpectation) Then(err error) *UserRepositoryMock { + e.results = &UserRepositoryMockIncrementInvitesIssuedResults{err} + return e.mock +} + +// Times sets number of times UserRepository.IncrementInvitesIssued should be invoked +func (mmIncrementInvitesIssued *mUserRepositoryMockIncrementInvitesIssued) Times(n uint64) *mUserRepositoryMockIncrementInvitesIssued { + if n == 0 { + mmIncrementInvitesIssued.mock.t.Fatalf("Times of UserRepositoryMock.IncrementInvitesIssued mock can not be zero") + } + mm_atomic.StoreUint64(&mmIncrementInvitesIssued.expectedInvocations, n) + mmIncrementInvitesIssued.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmIncrementInvitesIssued +} + +func (mmIncrementInvitesIssued *mUserRepositoryMockIncrementInvitesIssued) invocationsDone() bool { + if len(mmIncrementInvitesIssued.expectations) == 0 && mmIncrementInvitesIssued.defaultExpectation == nil && mmIncrementInvitesIssued.mock.funcIncrementInvitesIssued == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmIncrementInvitesIssued.mock.afterIncrementInvitesIssuedCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmIncrementInvitesIssued.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// IncrementInvitesIssued implements mm_repository.UserRepository +func (mmIncrementInvitesIssued *UserRepositoryMock) IncrementInvitesIssued(ctx context.Context, userID int) (err error) { + mm_atomic.AddUint64(&mmIncrementInvitesIssued.beforeIncrementInvitesIssuedCounter, 1) + defer mm_atomic.AddUint64(&mmIncrementInvitesIssued.afterIncrementInvitesIssuedCounter, 1) + + mmIncrementInvitesIssued.t.Helper() + + if mmIncrementInvitesIssued.inspectFuncIncrementInvitesIssued != nil { + mmIncrementInvitesIssued.inspectFuncIncrementInvitesIssued(ctx, userID) + } + + mm_params := UserRepositoryMockIncrementInvitesIssuedParams{ctx, userID} + + // Record call args + mmIncrementInvitesIssued.IncrementInvitesIssuedMock.mutex.Lock() + mmIncrementInvitesIssued.IncrementInvitesIssuedMock.callArgs = append(mmIncrementInvitesIssued.IncrementInvitesIssuedMock.callArgs, &mm_params) + mmIncrementInvitesIssued.IncrementInvitesIssuedMock.mutex.Unlock() + + for _, e := range mmIncrementInvitesIssued.IncrementInvitesIssuedMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.err + } + } + + if mmIncrementInvitesIssued.IncrementInvitesIssuedMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmIncrementInvitesIssued.IncrementInvitesIssuedMock.defaultExpectation.Counter, 1) + mm_want := mmIncrementInvitesIssued.IncrementInvitesIssuedMock.defaultExpectation.params + mm_want_ptrs := mmIncrementInvitesIssued.IncrementInvitesIssuedMock.defaultExpectation.paramPtrs + + mm_got := UserRepositoryMockIncrementInvitesIssuedParams{ctx, userID} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmIncrementInvitesIssued.t.Errorf("UserRepositoryMock.IncrementInvitesIssued got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmIncrementInvitesIssued.IncrementInvitesIssuedMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.userID != nil && !minimock.Equal(*mm_want_ptrs.userID, mm_got.userID) { + mmIncrementInvitesIssued.t.Errorf("UserRepositoryMock.IncrementInvitesIssued got unexpected parameter userID, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmIncrementInvitesIssued.IncrementInvitesIssuedMock.defaultExpectation.expectationOrigins.originUserID, *mm_want_ptrs.userID, mm_got.userID, minimock.Diff(*mm_want_ptrs.userID, mm_got.userID)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmIncrementInvitesIssued.t.Errorf("UserRepositoryMock.IncrementInvitesIssued got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmIncrementInvitesIssued.IncrementInvitesIssuedMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmIncrementInvitesIssued.IncrementInvitesIssuedMock.defaultExpectation.results + if mm_results == nil { + mmIncrementInvitesIssued.t.Fatal("No results are set for the UserRepositoryMock.IncrementInvitesIssued") + } + return (*mm_results).err + } + if mmIncrementInvitesIssued.funcIncrementInvitesIssued != nil { + return mmIncrementInvitesIssued.funcIncrementInvitesIssued(ctx, userID) + } + mmIncrementInvitesIssued.t.Fatalf("Unexpected call to UserRepositoryMock.IncrementInvitesIssued. %v %v", ctx, userID) + return +} + +// IncrementInvitesIssuedAfterCounter returns a count of finished UserRepositoryMock.IncrementInvitesIssued invocations +func (mmIncrementInvitesIssued *UserRepositoryMock) IncrementInvitesIssuedAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmIncrementInvitesIssued.afterIncrementInvitesIssuedCounter) +} + +// IncrementInvitesIssuedBeforeCounter returns a count of UserRepositoryMock.IncrementInvitesIssued invocations +func (mmIncrementInvitesIssued *UserRepositoryMock) IncrementInvitesIssuedBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmIncrementInvitesIssued.beforeIncrementInvitesIssuedCounter) +} + +// Calls returns a list of arguments used in each call to UserRepositoryMock.IncrementInvitesIssued. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmIncrementInvitesIssued *mUserRepositoryMockIncrementInvitesIssued) Calls() []*UserRepositoryMockIncrementInvitesIssuedParams { + mmIncrementInvitesIssued.mutex.RLock() + + argCopy := make([]*UserRepositoryMockIncrementInvitesIssuedParams, len(mmIncrementInvitesIssued.callArgs)) + copy(argCopy, mmIncrementInvitesIssued.callArgs) + + mmIncrementInvitesIssued.mutex.RUnlock() + + return argCopy +} + +// MinimockIncrementInvitesIssuedDone returns true if the count of the IncrementInvitesIssued invocations corresponds +// the number of defined expectations +func (m *UserRepositoryMock) MinimockIncrementInvitesIssuedDone() bool { + if m.IncrementInvitesIssuedMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.IncrementInvitesIssuedMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.IncrementInvitesIssuedMock.invocationsDone() +} + +// MinimockIncrementInvitesIssuedInspect logs each unmet expectation +func (m *UserRepositoryMock) MinimockIncrementInvitesIssuedInspect() { + for _, e := range m.IncrementInvitesIssuedMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to UserRepositoryMock.IncrementInvitesIssued at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterIncrementInvitesIssuedCounter := mm_atomic.LoadUint64(&m.afterIncrementInvitesIssuedCounter) + // if default expectation was set then invocations count should be greater than zero + if m.IncrementInvitesIssuedMock.defaultExpectation != nil && afterIncrementInvitesIssuedCounter < 1 { + if m.IncrementInvitesIssuedMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to UserRepositoryMock.IncrementInvitesIssued at\n%s", m.IncrementInvitesIssuedMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to UserRepositoryMock.IncrementInvitesIssued at\n%s with params: %#v", m.IncrementInvitesIssuedMock.defaultExpectation.expectationOrigins.origin, *m.IncrementInvitesIssuedMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcIncrementInvitesIssued != nil && afterIncrementInvitesIssuedCounter < 1 { + m.t.Errorf("Expected call to UserRepositoryMock.IncrementInvitesIssued at\n%s", m.funcIncrementInvitesIssuedOrigin) + } + + if !m.IncrementInvitesIssuedMock.invocationsDone() && afterIncrementInvitesIssuedCounter > 0 { + m.t.Errorf("Expected %d calls to UserRepositoryMock.IncrementInvitesIssued at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.IncrementInvitesIssuedMock.expectedInvocations), m.IncrementInvitesIssuedMock.expectedInvocationsOrigin, afterIncrementInvitesIssuedCounter) + } +} + +type mUserRepositoryMockUpdateBalance struct { + optional bool + mock *UserRepositoryMock + defaultExpectation *UserRepositoryMockUpdateBalanceExpectation + expectations []*UserRepositoryMockUpdateBalanceExpectation + + callArgs []*UserRepositoryMockUpdateBalanceParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// UserRepositoryMockUpdateBalanceExpectation specifies expectation struct of the UserRepository.UpdateBalance +type UserRepositoryMockUpdateBalanceExpectation struct { + mock *UserRepositoryMock + params *UserRepositoryMockUpdateBalanceParams + paramPtrs *UserRepositoryMockUpdateBalanceParamPtrs + expectationOrigins UserRepositoryMockUpdateBalanceExpectationOrigins + results *UserRepositoryMockUpdateBalanceResults + returnOrigin string + Counter uint64 +} + +// UserRepositoryMockUpdateBalanceParams contains parameters of the UserRepository.UpdateBalance +type UserRepositoryMockUpdateBalanceParams struct { + ctx context.Context + userID int + delta float64 +} + +// UserRepositoryMockUpdateBalanceParamPtrs contains pointers to parameters of the UserRepository.UpdateBalance +type UserRepositoryMockUpdateBalanceParamPtrs struct { + ctx *context.Context + userID *int + delta *float64 +} + +// UserRepositoryMockUpdateBalanceResults contains results of the UserRepository.UpdateBalance +type UserRepositoryMockUpdateBalanceResults struct { + err error +} + +// UserRepositoryMockUpdateBalanceOrigins contains origins of expectations of the UserRepository.UpdateBalance +type UserRepositoryMockUpdateBalanceExpectationOrigins struct { + origin string + originCtx string + originUserID string + originDelta string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmUpdateBalance *mUserRepositoryMockUpdateBalance) Optional() *mUserRepositoryMockUpdateBalance { + mmUpdateBalance.optional = true + return mmUpdateBalance +} + +// Expect sets up expected params for UserRepository.UpdateBalance +func (mmUpdateBalance *mUserRepositoryMockUpdateBalance) Expect(ctx context.Context, userID int, delta float64) *mUserRepositoryMockUpdateBalance { + if mmUpdateBalance.mock.funcUpdateBalance != nil { + mmUpdateBalance.mock.t.Fatalf("UserRepositoryMock.UpdateBalance mock is already set by Set") + } + + if mmUpdateBalance.defaultExpectation == nil { + mmUpdateBalance.defaultExpectation = &UserRepositoryMockUpdateBalanceExpectation{} + } + + if mmUpdateBalance.defaultExpectation.paramPtrs != nil { + mmUpdateBalance.mock.t.Fatalf("UserRepositoryMock.UpdateBalance mock is already set by ExpectParams functions") + } + + mmUpdateBalance.defaultExpectation.params = &UserRepositoryMockUpdateBalanceParams{ctx, userID, delta} + mmUpdateBalance.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmUpdateBalance.expectations { + if minimock.Equal(e.params, mmUpdateBalance.defaultExpectation.params) { + mmUpdateBalance.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmUpdateBalance.defaultExpectation.params) + } + } + + return mmUpdateBalance +} + +// ExpectCtxParam1 sets up expected param ctx for UserRepository.UpdateBalance +func (mmUpdateBalance *mUserRepositoryMockUpdateBalance) ExpectCtxParam1(ctx context.Context) *mUserRepositoryMockUpdateBalance { + if mmUpdateBalance.mock.funcUpdateBalance != nil { + mmUpdateBalance.mock.t.Fatalf("UserRepositoryMock.UpdateBalance mock is already set by Set") + } + + if mmUpdateBalance.defaultExpectation == nil { + mmUpdateBalance.defaultExpectation = &UserRepositoryMockUpdateBalanceExpectation{} + } + + if mmUpdateBalance.defaultExpectation.params != nil { + mmUpdateBalance.mock.t.Fatalf("UserRepositoryMock.UpdateBalance mock is already set by Expect") + } + + if mmUpdateBalance.defaultExpectation.paramPtrs == nil { + mmUpdateBalance.defaultExpectation.paramPtrs = &UserRepositoryMockUpdateBalanceParamPtrs{} + } + mmUpdateBalance.defaultExpectation.paramPtrs.ctx = &ctx + mmUpdateBalance.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmUpdateBalance +} + +// ExpectUserIDParam2 sets up expected param userID for UserRepository.UpdateBalance +func (mmUpdateBalance *mUserRepositoryMockUpdateBalance) ExpectUserIDParam2(userID int) *mUserRepositoryMockUpdateBalance { + if mmUpdateBalance.mock.funcUpdateBalance != nil { + mmUpdateBalance.mock.t.Fatalf("UserRepositoryMock.UpdateBalance mock is already set by Set") + } + + if mmUpdateBalance.defaultExpectation == nil { + mmUpdateBalance.defaultExpectation = &UserRepositoryMockUpdateBalanceExpectation{} + } + + if mmUpdateBalance.defaultExpectation.params != nil { + mmUpdateBalance.mock.t.Fatalf("UserRepositoryMock.UpdateBalance mock is already set by Expect") + } + + if mmUpdateBalance.defaultExpectation.paramPtrs == nil { + mmUpdateBalance.defaultExpectation.paramPtrs = &UserRepositoryMockUpdateBalanceParamPtrs{} + } + mmUpdateBalance.defaultExpectation.paramPtrs.userID = &userID + mmUpdateBalance.defaultExpectation.expectationOrigins.originUserID = minimock.CallerInfo(1) + + return mmUpdateBalance +} + +// ExpectDeltaParam3 sets up expected param delta for UserRepository.UpdateBalance +func (mmUpdateBalance *mUserRepositoryMockUpdateBalance) ExpectDeltaParam3(delta float64) *mUserRepositoryMockUpdateBalance { + if mmUpdateBalance.mock.funcUpdateBalance != nil { + mmUpdateBalance.mock.t.Fatalf("UserRepositoryMock.UpdateBalance mock is already set by Set") + } + + if mmUpdateBalance.defaultExpectation == nil { + mmUpdateBalance.defaultExpectation = &UserRepositoryMockUpdateBalanceExpectation{} + } + + if mmUpdateBalance.defaultExpectation.params != nil { + mmUpdateBalance.mock.t.Fatalf("UserRepositoryMock.UpdateBalance mock is already set by Expect") + } + + if mmUpdateBalance.defaultExpectation.paramPtrs == nil { + mmUpdateBalance.defaultExpectation.paramPtrs = &UserRepositoryMockUpdateBalanceParamPtrs{} + } + mmUpdateBalance.defaultExpectation.paramPtrs.delta = &delta + mmUpdateBalance.defaultExpectation.expectationOrigins.originDelta = minimock.CallerInfo(1) + + return mmUpdateBalance +} + +// Inspect accepts an inspector function that has same arguments as the UserRepository.UpdateBalance +func (mmUpdateBalance *mUserRepositoryMockUpdateBalance) Inspect(f func(ctx context.Context, userID int, delta float64)) *mUserRepositoryMockUpdateBalance { + if mmUpdateBalance.mock.inspectFuncUpdateBalance != nil { + mmUpdateBalance.mock.t.Fatalf("Inspect function is already set for UserRepositoryMock.UpdateBalance") + } + + mmUpdateBalance.mock.inspectFuncUpdateBalance = f + + return mmUpdateBalance +} + +// Return sets up results that will be returned by UserRepository.UpdateBalance +func (mmUpdateBalance *mUserRepositoryMockUpdateBalance) Return(err error) *UserRepositoryMock { + if mmUpdateBalance.mock.funcUpdateBalance != nil { + mmUpdateBalance.mock.t.Fatalf("UserRepositoryMock.UpdateBalance mock is already set by Set") + } + + if mmUpdateBalance.defaultExpectation == nil { + mmUpdateBalance.defaultExpectation = &UserRepositoryMockUpdateBalanceExpectation{mock: mmUpdateBalance.mock} + } + mmUpdateBalance.defaultExpectation.results = &UserRepositoryMockUpdateBalanceResults{err} + mmUpdateBalance.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmUpdateBalance.mock +} + +// Set uses given function f to mock the UserRepository.UpdateBalance method +func (mmUpdateBalance *mUserRepositoryMockUpdateBalance) Set(f func(ctx context.Context, userID int, delta float64) (err error)) *UserRepositoryMock { + if mmUpdateBalance.defaultExpectation != nil { + mmUpdateBalance.mock.t.Fatalf("Default expectation is already set for the UserRepository.UpdateBalance method") + } + + if len(mmUpdateBalance.expectations) > 0 { + mmUpdateBalance.mock.t.Fatalf("Some expectations are already set for the UserRepository.UpdateBalance method") + } + + mmUpdateBalance.mock.funcUpdateBalance = f + mmUpdateBalance.mock.funcUpdateBalanceOrigin = minimock.CallerInfo(1) + return mmUpdateBalance.mock +} + +// When sets expectation for the UserRepository.UpdateBalance which will trigger the result defined by the following +// Then helper +func (mmUpdateBalance *mUserRepositoryMockUpdateBalance) When(ctx context.Context, userID int, delta float64) *UserRepositoryMockUpdateBalanceExpectation { + if mmUpdateBalance.mock.funcUpdateBalance != nil { + mmUpdateBalance.mock.t.Fatalf("UserRepositoryMock.UpdateBalance mock is already set by Set") + } + + expectation := &UserRepositoryMockUpdateBalanceExpectation{ + mock: mmUpdateBalance.mock, + params: &UserRepositoryMockUpdateBalanceParams{ctx, userID, delta}, + expectationOrigins: UserRepositoryMockUpdateBalanceExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmUpdateBalance.expectations = append(mmUpdateBalance.expectations, expectation) + return expectation +} + +// Then sets up UserRepository.UpdateBalance return parameters for the expectation previously defined by the When method +func (e *UserRepositoryMockUpdateBalanceExpectation) Then(err error) *UserRepositoryMock { + e.results = &UserRepositoryMockUpdateBalanceResults{err} + return e.mock +} + +// Times sets number of times UserRepository.UpdateBalance should be invoked +func (mmUpdateBalance *mUserRepositoryMockUpdateBalance) Times(n uint64) *mUserRepositoryMockUpdateBalance { + if n == 0 { + mmUpdateBalance.mock.t.Fatalf("Times of UserRepositoryMock.UpdateBalance mock can not be zero") + } + mm_atomic.StoreUint64(&mmUpdateBalance.expectedInvocations, n) + mmUpdateBalance.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmUpdateBalance +} + +func (mmUpdateBalance *mUserRepositoryMockUpdateBalance) invocationsDone() bool { + if len(mmUpdateBalance.expectations) == 0 && mmUpdateBalance.defaultExpectation == nil && mmUpdateBalance.mock.funcUpdateBalance == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmUpdateBalance.mock.afterUpdateBalanceCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmUpdateBalance.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// UpdateBalance implements mm_repository.UserRepository +func (mmUpdateBalance *UserRepositoryMock) UpdateBalance(ctx context.Context, userID int, delta float64) (err error) { + mm_atomic.AddUint64(&mmUpdateBalance.beforeUpdateBalanceCounter, 1) + defer mm_atomic.AddUint64(&mmUpdateBalance.afterUpdateBalanceCounter, 1) + + mmUpdateBalance.t.Helper() + + if mmUpdateBalance.inspectFuncUpdateBalance != nil { + mmUpdateBalance.inspectFuncUpdateBalance(ctx, userID, delta) + } + + mm_params := UserRepositoryMockUpdateBalanceParams{ctx, userID, delta} + + // Record call args + mmUpdateBalance.UpdateBalanceMock.mutex.Lock() + mmUpdateBalance.UpdateBalanceMock.callArgs = append(mmUpdateBalance.UpdateBalanceMock.callArgs, &mm_params) + mmUpdateBalance.UpdateBalanceMock.mutex.Unlock() + + for _, e := range mmUpdateBalance.UpdateBalanceMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.err + } + } + + if mmUpdateBalance.UpdateBalanceMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmUpdateBalance.UpdateBalanceMock.defaultExpectation.Counter, 1) + mm_want := mmUpdateBalance.UpdateBalanceMock.defaultExpectation.params + mm_want_ptrs := mmUpdateBalance.UpdateBalanceMock.defaultExpectation.paramPtrs + + mm_got := UserRepositoryMockUpdateBalanceParams{ctx, userID, delta} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmUpdateBalance.t.Errorf("UserRepositoryMock.UpdateBalance got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmUpdateBalance.UpdateBalanceMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.userID != nil && !minimock.Equal(*mm_want_ptrs.userID, mm_got.userID) { + mmUpdateBalance.t.Errorf("UserRepositoryMock.UpdateBalance got unexpected parameter userID, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmUpdateBalance.UpdateBalanceMock.defaultExpectation.expectationOrigins.originUserID, *mm_want_ptrs.userID, mm_got.userID, minimock.Diff(*mm_want_ptrs.userID, mm_got.userID)) + } + + if mm_want_ptrs.delta != nil && !minimock.Equal(*mm_want_ptrs.delta, mm_got.delta) { + mmUpdateBalance.t.Errorf("UserRepositoryMock.UpdateBalance got unexpected parameter delta, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmUpdateBalance.UpdateBalanceMock.defaultExpectation.expectationOrigins.originDelta, *mm_want_ptrs.delta, mm_got.delta, minimock.Diff(*mm_want_ptrs.delta, mm_got.delta)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmUpdateBalance.t.Errorf("UserRepositoryMock.UpdateBalance got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmUpdateBalance.UpdateBalanceMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmUpdateBalance.UpdateBalanceMock.defaultExpectation.results + if mm_results == nil { + mmUpdateBalance.t.Fatal("No results are set for the UserRepositoryMock.UpdateBalance") + } + return (*mm_results).err + } + if mmUpdateBalance.funcUpdateBalance != nil { + return mmUpdateBalance.funcUpdateBalance(ctx, userID, delta) + } + mmUpdateBalance.t.Fatalf("Unexpected call to UserRepositoryMock.UpdateBalance. %v %v %v", ctx, userID, delta) + return +} + +// UpdateBalanceAfterCounter returns a count of finished UserRepositoryMock.UpdateBalance invocations +func (mmUpdateBalance *UserRepositoryMock) UpdateBalanceAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmUpdateBalance.afterUpdateBalanceCounter) +} + +// UpdateBalanceBeforeCounter returns a count of UserRepositoryMock.UpdateBalance invocations +func (mmUpdateBalance *UserRepositoryMock) UpdateBalanceBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmUpdateBalance.beforeUpdateBalanceCounter) +} + +// Calls returns a list of arguments used in each call to UserRepositoryMock.UpdateBalance. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmUpdateBalance *mUserRepositoryMockUpdateBalance) Calls() []*UserRepositoryMockUpdateBalanceParams { + mmUpdateBalance.mutex.RLock() + + argCopy := make([]*UserRepositoryMockUpdateBalanceParams, len(mmUpdateBalance.callArgs)) + copy(argCopy, mmUpdateBalance.callArgs) + + mmUpdateBalance.mutex.RUnlock() + + return argCopy +} + +// MinimockUpdateBalanceDone returns true if the count of the UpdateBalance invocations corresponds +// the number of defined expectations +func (m *UserRepositoryMock) MinimockUpdateBalanceDone() bool { + if m.UpdateBalanceMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.UpdateBalanceMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.UpdateBalanceMock.invocationsDone() +} + +// MinimockUpdateBalanceInspect logs each unmet expectation +func (m *UserRepositoryMock) MinimockUpdateBalanceInspect() { + for _, e := range m.UpdateBalanceMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to UserRepositoryMock.UpdateBalance at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterUpdateBalanceCounter := mm_atomic.LoadUint64(&m.afterUpdateBalanceCounter) + // if default expectation was set then invocations count should be greater than zero + if m.UpdateBalanceMock.defaultExpectation != nil && afterUpdateBalanceCounter < 1 { + if m.UpdateBalanceMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to UserRepositoryMock.UpdateBalance at\n%s", m.UpdateBalanceMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to UserRepositoryMock.UpdateBalance at\n%s with params: %#v", m.UpdateBalanceMock.defaultExpectation.expectationOrigins.origin, *m.UpdateBalanceMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcUpdateBalance != nil && afterUpdateBalanceCounter < 1 { + m.t.Errorf("Expected call to UserRepositoryMock.UpdateBalance at\n%s", m.funcUpdateBalanceOrigin) + } + + if !m.UpdateBalanceMock.invocationsDone() && afterUpdateBalanceCounter > 0 { + m.t.Errorf("Expected %d calls to UserRepositoryMock.UpdateBalance at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.UpdateBalanceMock.expectedInvocations), m.UpdateBalanceMock.expectedInvocationsOrigin, afterUpdateBalanceCounter) + } +} + +// MinimockFinish checks that all mocked methods have been called the expected number of times +func (m *UserRepositoryMock) MinimockFinish() { + m.finishOnce.Do(func() { + if !m.minimockDone() { + m.MinimockCheckInviteLimitInspect() + + m.MinimockCreateInspect() + + m.MinimockFindByEmailHashInspect() + + m.MinimockFindByIDInspect() + + m.MinimockGetBalanceInspect() + + m.MinimockIncrementInvitesIssuedInspect() + + m.MinimockUpdateBalanceInspect() + } + }) +} + +// MinimockWait waits for all mocked methods to be called the expected number of times +func (m *UserRepositoryMock) MinimockWait(timeout mm_time.Duration) { + timeoutCh := mm_time.After(timeout) + for { + if m.minimockDone() { + return + } + select { + case <-timeoutCh: + m.MinimockFinish() + return + case <-mm_time.After(10 * mm_time.Millisecond): + } + } +} + +func (m *UserRepositoryMock) minimockDone() bool { + done := true + return done && + m.MinimockCheckInviteLimitDone() && + m.MinimockCreateDone() && + m.MinimockFindByEmailHashDone() && + m.MinimockFindByIDDone() && + m.MinimockGetBalanceDone() && + m.MinimockIncrementInvitesIssuedDone() && + m.MinimockUpdateBalanceDone() +} diff --git a/internal/mocks/user_service_mock.go b/internal/mocks/user_service_mock.go new file mode 100644 index 0000000..ed99151 --- /dev/null +++ b/internal/mocks/user_service_mock.go @@ -0,0 +1,1130 @@ +// Code generated by http://github.com/gojuno/minimock (v3.4.7). DO NOT EDIT. + +package mocks + +//go:generate minimock -i smart-search-back/internal/service.UserService -o user_service_mock.go -n UserServiceMock -p mocks + +import ( + "context" + mm_service "smart-search-back/internal/service" + "sync" + mm_atomic "sync/atomic" + mm_time "time" + + "github.com/gojuno/minimock/v3" +) + +// UserServiceMock implements mm_service.UserService +type UserServiceMock struct { + t minimock.Tester + finishOnce sync.Once + + funcGetBalance func(ctx context.Context, userID int) (f1 float64, err error) + funcGetBalanceOrigin string + inspectFuncGetBalance func(ctx context.Context, userID int) + afterGetBalanceCounter uint64 + beforeGetBalanceCounter uint64 + GetBalanceMock mUserServiceMockGetBalance + + funcGetInfo func(ctx context.Context, userID int) (up1 *mm_service.UserInfo, err error) + funcGetInfoOrigin string + inspectFuncGetInfo func(ctx context.Context, userID int) + afterGetInfoCounter uint64 + beforeGetInfoCounter uint64 + GetInfoMock mUserServiceMockGetInfo + + funcGetStatistics func(ctx context.Context, userID int) (sp1 *mm_service.Statistics, err error) + funcGetStatisticsOrigin string + inspectFuncGetStatistics func(ctx context.Context, userID int) + afterGetStatisticsCounter uint64 + beforeGetStatisticsCounter uint64 + GetStatisticsMock mUserServiceMockGetStatistics +} + +// NewUserServiceMock returns a mock for mm_service.UserService +func NewUserServiceMock(t minimock.Tester) *UserServiceMock { + m := &UserServiceMock{t: t} + + if controller, ok := t.(minimock.MockController); ok { + controller.RegisterMocker(m) + } + + m.GetBalanceMock = mUserServiceMockGetBalance{mock: m} + m.GetBalanceMock.callArgs = []*UserServiceMockGetBalanceParams{} + + m.GetInfoMock = mUserServiceMockGetInfo{mock: m} + m.GetInfoMock.callArgs = []*UserServiceMockGetInfoParams{} + + m.GetStatisticsMock = mUserServiceMockGetStatistics{mock: m} + m.GetStatisticsMock.callArgs = []*UserServiceMockGetStatisticsParams{} + + t.Cleanup(m.MinimockFinish) + + return m +} + +type mUserServiceMockGetBalance struct { + optional bool + mock *UserServiceMock + defaultExpectation *UserServiceMockGetBalanceExpectation + expectations []*UserServiceMockGetBalanceExpectation + + callArgs []*UserServiceMockGetBalanceParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// UserServiceMockGetBalanceExpectation specifies expectation struct of the UserService.GetBalance +type UserServiceMockGetBalanceExpectation struct { + mock *UserServiceMock + params *UserServiceMockGetBalanceParams + paramPtrs *UserServiceMockGetBalanceParamPtrs + expectationOrigins UserServiceMockGetBalanceExpectationOrigins + results *UserServiceMockGetBalanceResults + returnOrigin string + Counter uint64 +} + +// UserServiceMockGetBalanceParams contains parameters of the UserService.GetBalance +type UserServiceMockGetBalanceParams struct { + ctx context.Context + userID int +} + +// UserServiceMockGetBalanceParamPtrs contains pointers to parameters of the UserService.GetBalance +type UserServiceMockGetBalanceParamPtrs struct { + ctx *context.Context + userID *int +} + +// UserServiceMockGetBalanceResults contains results of the UserService.GetBalance +type UserServiceMockGetBalanceResults struct { + f1 float64 + err error +} + +// UserServiceMockGetBalanceOrigins contains origins of expectations of the UserService.GetBalance +type UserServiceMockGetBalanceExpectationOrigins struct { + origin string + originCtx string + originUserID string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmGetBalance *mUserServiceMockGetBalance) Optional() *mUserServiceMockGetBalance { + mmGetBalance.optional = true + return mmGetBalance +} + +// Expect sets up expected params for UserService.GetBalance +func (mmGetBalance *mUserServiceMockGetBalance) Expect(ctx context.Context, userID int) *mUserServiceMockGetBalance { + if mmGetBalance.mock.funcGetBalance != nil { + mmGetBalance.mock.t.Fatalf("UserServiceMock.GetBalance mock is already set by Set") + } + + if mmGetBalance.defaultExpectation == nil { + mmGetBalance.defaultExpectation = &UserServiceMockGetBalanceExpectation{} + } + + if mmGetBalance.defaultExpectation.paramPtrs != nil { + mmGetBalance.mock.t.Fatalf("UserServiceMock.GetBalance mock is already set by ExpectParams functions") + } + + mmGetBalance.defaultExpectation.params = &UserServiceMockGetBalanceParams{ctx, userID} + mmGetBalance.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmGetBalance.expectations { + if minimock.Equal(e.params, mmGetBalance.defaultExpectation.params) { + mmGetBalance.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetBalance.defaultExpectation.params) + } + } + + return mmGetBalance +} + +// ExpectCtxParam1 sets up expected param ctx for UserService.GetBalance +func (mmGetBalance *mUserServiceMockGetBalance) ExpectCtxParam1(ctx context.Context) *mUserServiceMockGetBalance { + if mmGetBalance.mock.funcGetBalance != nil { + mmGetBalance.mock.t.Fatalf("UserServiceMock.GetBalance mock is already set by Set") + } + + if mmGetBalance.defaultExpectation == nil { + mmGetBalance.defaultExpectation = &UserServiceMockGetBalanceExpectation{} + } + + if mmGetBalance.defaultExpectation.params != nil { + mmGetBalance.mock.t.Fatalf("UserServiceMock.GetBalance mock is already set by Expect") + } + + if mmGetBalance.defaultExpectation.paramPtrs == nil { + mmGetBalance.defaultExpectation.paramPtrs = &UserServiceMockGetBalanceParamPtrs{} + } + mmGetBalance.defaultExpectation.paramPtrs.ctx = &ctx + mmGetBalance.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmGetBalance +} + +// ExpectUserIDParam2 sets up expected param userID for UserService.GetBalance +func (mmGetBalance *mUserServiceMockGetBalance) ExpectUserIDParam2(userID int) *mUserServiceMockGetBalance { + if mmGetBalance.mock.funcGetBalance != nil { + mmGetBalance.mock.t.Fatalf("UserServiceMock.GetBalance mock is already set by Set") + } + + if mmGetBalance.defaultExpectation == nil { + mmGetBalance.defaultExpectation = &UserServiceMockGetBalanceExpectation{} + } + + if mmGetBalance.defaultExpectation.params != nil { + mmGetBalance.mock.t.Fatalf("UserServiceMock.GetBalance mock is already set by Expect") + } + + if mmGetBalance.defaultExpectation.paramPtrs == nil { + mmGetBalance.defaultExpectation.paramPtrs = &UserServiceMockGetBalanceParamPtrs{} + } + mmGetBalance.defaultExpectation.paramPtrs.userID = &userID + mmGetBalance.defaultExpectation.expectationOrigins.originUserID = minimock.CallerInfo(1) + + return mmGetBalance +} + +// Inspect accepts an inspector function that has same arguments as the UserService.GetBalance +func (mmGetBalance *mUserServiceMockGetBalance) Inspect(f func(ctx context.Context, userID int)) *mUserServiceMockGetBalance { + if mmGetBalance.mock.inspectFuncGetBalance != nil { + mmGetBalance.mock.t.Fatalf("Inspect function is already set for UserServiceMock.GetBalance") + } + + mmGetBalance.mock.inspectFuncGetBalance = f + + return mmGetBalance +} + +// Return sets up results that will be returned by UserService.GetBalance +func (mmGetBalance *mUserServiceMockGetBalance) Return(f1 float64, err error) *UserServiceMock { + if mmGetBalance.mock.funcGetBalance != nil { + mmGetBalance.mock.t.Fatalf("UserServiceMock.GetBalance mock is already set by Set") + } + + if mmGetBalance.defaultExpectation == nil { + mmGetBalance.defaultExpectation = &UserServiceMockGetBalanceExpectation{mock: mmGetBalance.mock} + } + mmGetBalance.defaultExpectation.results = &UserServiceMockGetBalanceResults{f1, err} + mmGetBalance.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmGetBalance.mock +} + +// Set uses given function f to mock the UserService.GetBalance method +func (mmGetBalance *mUserServiceMockGetBalance) Set(f func(ctx context.Context, userID int) (f1 float64, err error)) *UserServiceMock { + if mmGetBalance.defaultExpectation != nil { + mmGetBalance.mock.t.Fatalf("Default expectation is already set for the UserService.GetBalance method") + } + + if len(mmGetBalance.expectations) > 0 { + mmGetBalance.mock.t.Fatalf("Some expectations are already set for the UserService.GetBalance method") + } + + mmGetBalance.mock.funcGetBalance = f + mmGetBalance.mock.funcGetBalanceOrigin = minimock.CallerInfo(1) + return mmGetBalance.mock +} + +// When sets expectation for the UserService.GetBalance which will trigger the result defined by the following +// Then helper +func (mmGetBalance *mUserServiceMockGetBalance) When(ctx context.Context, userID int) *UserServiceMockGetBalanceExpectation { + if mmGetBalance.mock.funcGetBalance != nil { + mmGetBalance.mock.t.Fatalf("UserServiceMock.GetBalance mock is already set by Set") + } + + expectation := &UserServiceMockGetBalanceExpectation{ + mock: mmGetBalance.mock, + params: &UserServiceMockGetBalanceParams{ctx, userID}, + expectationOrigins: UserServiceMockGetBalanceExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmGetBalance.expectations = append(mmGetBalance.expectations, expectation) + return expectation +} + +// Then sets up UserService.GetBalance return parameters for the expectation previously defined by the When method +func (e *UserServiceMockGetBalanceExpectation) Then(f1 float64, err error) *UserServiceMock { + e.results = &UserServiceMockGetBalanceResults{f1, err} + return e.mock +} + +// Times sets number of times UserService.GetBalance should be invoked +func (mmGetBalance *mUserServiceMockGetBalance) Times(n uint64) *mUserServiceMockGetBalance { + if n == 0 { + mmGetBalance.mock.t.Fatalf("Times of UserServiceMock.GetBalance mock can not be zero") + } + mm_atomic.StoreUint64(&mmGetBalance.expectedInvocations, n) + mmGetBalance.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmGetBalance +} + +func (mmGetBalance *mUserServiceMockGetBalance) invocationsDone() bool { + if len(mmGetBalance.expectations) == 0 && mmGetBalance.defaultExpectation == nil && mmGetBalance.mock.funcGetBalance == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmGetBalance.mock.afterGetBalanceCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmGetBalance.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// GetBalance implements mm_service.UserService +func (mmGetBalance *UserServiceMock) GetBalance(ctx context.Context, userID int) (f1 float64, err error) { + mm_atomic.AddUint64(&mmGetBalance.beforeGetBalanceCounter, 1) + defer mm_atomic.AddUint64(&mmGetBalance.afterGetBalanceCounter, 1) + + mmGetBalance.t.Helper() + + if mmGetBalance.inspectFuncGetBalance != nil { + mmGetBalance.inspectFuncGetBalance(ctx, userID) + } + + mm_params := UserServiceMockGetBalanceParams{ctx, userID} + + // Record call args + mmGetBalance.GetBalanceMock.mutex.Lock() + mmGetBalance.GetBalanceMock.callArgs = append(mmGetBalance.GetBalanceMock.callArgs, &mm_params) + mmGetBalance.GetBalanceMock.mutex.Unlock() + + for _, e := range mmGetBalance.GetBalanceMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.f1, e.results.err + } + } + + if mmGetBalance.GetBalanceMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmGetBalance.GetBalanceMock.defaultExpectation.Counter, 1) + mm_want := mmGetBalance.GetBalanceMock.defaultExpectation.params + mm_want_ptrs := mmGetBalance.GetBalanceMock.defaultExpectation.paramPtrs + + mm_got := UserServiceMockGetBalanceParams{ctx, userID} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmGetBalance.t.Errorf("UserServiceMock.GetBalance got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetBalance.GetBalanceMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.userID != nil && !minimock.Equal(*mm_want_ptrs.userID, mm_got.userID) { + mmGetBalance.t.Errorf("UserServiceMock.GetBalance got unexpected parameter userID, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetBalance.GetBalanceMock.defaultExpectation.expectationOrigins.originUserID, *mm_want_ptrs.userID, mm_got.userID, minimock.Diff(*mm_want_ptrs.userID, mm_got.userID)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmGetBalance.t.Errorf("UserServiceMock.GetBalance got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetBalance.GetBalanceMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmGetBalance.GetBalanceMock.defaultExpectation.results + if mm_results == nil { + mmGetBalance.t.Fatal("No results are set for the UserServiceMock.GetBalance") + } + return (*mm_results).f1, (*mm_results).err + } + if mmGetBalance.funcGetBalance != nil { + return mmGetBalance.funcGetBalance(ctx, userID) + } + mmGetBalance.t.Fatalf("Unexpected call to UserServiceMock.GetBalance. %v %v", ctx, userID) + return +} + +// GetBalanceAfterCounter returns a count of finished UserServiceMock.GetBalance invocations +func (mmGetBalance *UserServiceMock) GetBalanceAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetBalance.afterGetBalanceCounter) +} + +// GetBalanceBeforeCounter returns a count of UserServiceMock.GetBalance invocations +func (mmGetBalance *UserServiceMock) GetBalanceBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetBalance.beforeGetBalanceCounter) +} + +// Calls returns a list of arguments used in each call to UserServiceMock.GetBalance. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmGetBalance *mUserServiceMockGetBalance) Calls() []*UserServiceMockGetBalanceParams { + mmGetBalance.mutex.RLock() + + argCopy := make([]*UserServiceMockGetBalanceParams, len(mmGetBalance.callArgs)) + copy(argCopy, mmGetBalance.callArgs) + + mmGetBalance.mutex.RUnlock() + + return argCopy +} + +// MinimockGetBalanceDone returns true if the count of the GetBalance invocations corresponds +// the number of defined expectations +func (m *UserServiceMock) MinimockGetBalanceDone() bool { + if m.GetBalanceMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.GetBalanceMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.GetBalanceMock.invocationsDone() +} + +// MinimockGetBalanceInspect logs each unmet expectation +func (m *UserServiceMock) MinimockGetBalanceInspect() { + for _, e := range m.GetBalanceMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to UserServiceMock.GetBalance at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterGetBalanceCounter := mm_atomic.LoadUint64(&m.afterGetBalanceCounter) + // if default expectation was set then invocations count should be greater than zero + if m.GetBalanceMock.defaultExpectation != nil && afterGetBalanceCounter < 1 { + if m.GetBalanceMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to UserServiceMock.GetBalance at\n%s", m.GetBalanceMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to UserServiceMock.GetBalance at\n%s with params: %#v", m.GetBalanceMock.defaultExpectation.expectationOrigins.origin, *m.GetBalanceMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcGetBalance != nil && afterGetBalanceCounter < 1 { + m.t.Errorf("Expected call to UserServiceMock.GetBalance at\n%s", m.funcGetBalanceOrigin) + } + + if !m.GetBalanceMock.invocationsDone() && afterGetBalanceCounter > 0 { + m.t.Errorf("Expected %d calls to UserServiceMock.GetBalance at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.GetBalanceMock.expectedInvocations), m.GetBalanceMock.expectedInvocationsOrigin, afterGetBalanceCounter) + } +} + +type mUserServiceMockGetInfo struct { + optional bool + mock *UserServiceMock + defaultExpectation *UserServiceMockGetInfoExpectation + expectations []*UserServiceMockGetInfoExpectation + + callArgs []*UserServiceMockGetInfoParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// UserServiceMockGetInfoExpectation specifies expectation struct of the UserService.GetInfo +type UserServiceMockGetInfoExpectation struct { + mock *UserServiceMock + params *UserServiceMockGetInfoParams + paramPtrs *UserServiceMockGetInfoParamPtrs + expectationOrigins UserServiceMockGetInfoExpectationOrigins + results *UserServiceMockGetInfoResults + returnOrigin string + Counter uint64 +} + +// UserServiceMockGetInfoParams contains parameters of the UserService.GetInfo +type UserServiceMockGetInfoParams struct { + ctx context.Context + userID int +} + +// UserServiceMockGetInfoParamPtrs contains pointers to parameters of the UserService.GetInfo +type UserServiceMockGetInfoParamPtrs struct { + ctx *context.Context + userID *int +} + +// UserServiceMockGetInfoResults contains results of the UserService.GetInfo +type UserServiceMockGetInfoResults struct { + up1 *mm_service.UserInfo + err error +} + +// UserServiceMockGetInfoOrigins contains origins of expectations of the UserService.GetInfo +type UserServiceMockGetInfoExpectationOrigins struct { + origin string + originCtx string + originUserID string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmGetInfo *mUserServiceMockGetInfo) Optional() *mUserServiceMockGetInfo { + mmGetInfo.optional = true + return mmGetInfo +} + +// Expect sets up expected params for UserService.GetInfo +func (mmGetInfo *mUserServiceMockGetInfo) Expect(ctx context.Context, userID int) *mUserServiceMockGetInfo { + if mmGetInfo.mock.funcGetInfo != nil { + mmGetInfo.mock.t.Fatalf("UserServiceMock.GetInfo mock is already set by Set") + } + + if mmGetInfo.defaultExpectation == nil { + mmGetInfo.defaultExpectation = &UserServiceMockGetInfoExpectation{} + } + + if mmGetInfo.defaultExpectation.paramPtrs != nil { + mmGetInfo.mock.t.Fatalf("UserServiceMock.GetInfo mock is already set by ExpectParams functions") + } + + mmGetInfo.defaultExpectation.params = &UserServiceMockGetInfoParams{ctx, userID} + mmGetInfo.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmGetInfo.expectations { + if minimock.Equal(e.params, mmGetInfo.defaultExpectation.params) { + mmGetInfo.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetInfo.defaultExpectation.params) + } + } + + return mmGetInfo +} + +// ExpectCtxParam1 sets up expected param ctx for UserService.GetInfo +func (mmGetInfo *mUserServiceMockGetInfo) ExpectCtxParam1(ctx context.Context) *mUserServiceMockGetInfo { + if mmGetInfo.mock.funcGetInfo != nil { + mmGetInfo.mock.t.Fatalf("UserServiceMock.GetInfo mock is already set by Set") + } + + if mmGetInfo.defaultExpectation == nil { + mmGetInfo.defaultExpectation = &UserServiceMockGetInfoExpectation{} + } + + if mmGetInfo.defaultExpectation.params != nil { + mmGetInfo.mock.t.Fatalf("UserServiceMock.GetInfo mock is already set by Expect") + } + + if mmGetInfo.defaultExpectation.paramPtrs == nil { + mmGetInfo.defaultExpectation.paramPtrs = &UserServiceMockGetInfoParamPtrs{} + } + mmGetInfo.defaultExpectation.paramPtrs.ctx = &ctx + mmGetInfo.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmGetInfo +} + +// ExpectUserIDParam2 sets up expected param userID for UserService.GetInfo +func (mmGetInfo *mUserServiceMockGetInfo) ExpectUserIDParam2(userID int) *mUserServiceMockGetInfo { + if mmGetInfo.mock.funcGetInfo != nil { + mmGetInfo.mock.t.Fatalf("UserServiceMock.GetInfo mock is already set by Set") + } + + if mmGetInfo.defaultExpectation == nil { + mmGetInfo.defaultExpectation = &UserServiceMockGetInfoExpectation{} + } + + if mmGetInfo.defaultExpectation.params != nil { + mmGetInfo.mock.t.Fatalf("UserServiceMock.GetInfo mock is already set by Expect") + } + + if mmGetInfo.defaultExpectation.paramPtrs == nil { + mmGetInfo.defaultExpectation.paramPtrs = &UserServiceMockGetInfoParamPtrs{} + } + mmGetInfo.defaultExpectation.paramPtrs.userID = &userID + mmGetInfo.defaultExpectation.expectationOrigins.originUserID = minimock.CallerInfo(1) + + return mmGetInfo +} + +// Inspect accepts an inspector function that has same arguments as the UserService.GetInfo +func (mmGetInfo *mUserServiceMockGetInfo) Inspect(f func(ctx context.Context, userID int)) *mUserServiceMockGetInfo { + if mmGetInfo.mock.inspectFuncGetInfo != nil { + mmGetInfo.mock.t.Fatalf("Inspect function is already set for UserServiceMock.GetInfo") + } + + mmGetInfo.mock.inspectFuncGetInfo = f + + return mmGetInfo +} + +// Return sets up results that will be returned by UserService.GetInfo +func (mmGetInfo *mUserServiceMockGetInfo) Return(up1 *mm_service.UserInfo, err error) *UserServiceMock { + if mmGetInfo.mock.funcGetInfo != nil { + mmGetInfo.mock.t.Fatalf("UserServiceMock.GetInfo mock is already set by Set") + } + + if mmGetInfo.defaultExpectation == nil { + mmGetInfo.defaultExpectation = &UserServiceMockGetInfoExpectation{mock: mmGetInfo.mock} + } + mmGetInfo.defaultExpectation.results = &UserServiceMockGetInfoResults{up1, err} + mmGetInfo.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmGetInfo.mock +} + +// Set uses given function f to mock the UserService.GetInfo method +func (mmGetInfo *mUserServiceMockGetInfo) Set(f func(ctx context.Context, userID int) (up1 *mm_service.UserInfo, err error)) *UserServiceMock { + if mmGetInfo.defaultExpectation != nil { + mmGetInfo.mock.t.Fatalf("Default expectation is already set for the UserService.GetInfo method") + } + + if len(mmGetInfo.expectations) > 0 { + mmGetInfo.mock.t.Fatalf("Some expectations are already set for the UserService.GetInfo method") + } + + mmGetInfo.mock.funcGetInfo = f + mmGetInfo.mock.funcGetInfoOrigin = minimock.CallerInfo(1) + return mmGetInfo.mock +} + +// When sets expectation for the UserService.GetInfo which will trigger the result defined by the following +// Then helper +func (mmGetInfo *mUserServiceMockGetInfo) When(ctx context.Context, userID int) *UserServiceMockGetInfoExpectation { + if mmGetInfo.mock.funcGetInfo != nil { + mmGetInfo.mock.t.Fatalf("UserServiceMock.GetInfo mock is already set by Set") + } + + expectation := &UserServiceMockGetInfoExpectation{ + mock: mmGetInfo.mock, + params: &UserServiceMockGetInfoParams{ctx, userID}, + expectationOrigins: UserServiceMockGetInfoExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmGetInfo.expectations = append(mmGetInfo.expectations, expectation) + return expectation +} + +// Then sets up UserService.GetInfo return parameters for the expectation previously defined by the When method +func (e *UserServiceMockGetInfoExpectation) Then(up1 *mm_service.UserInfo, err error) *UserServiceMock { + e.results = &UserServiceMockGetInfoResults{up1, err} + return e.mock +} + +// Times sets number of times UserService.GetInfo should be invoked +func (mmGetInfo *mUserServiceMockGetInfo) Times(n uint64) *mUserServiceMockGetInfo { + if n == 0 { + mmGetInfo.mock.t.Fatalf("Times of UserServiceMock.GetInfo mock can not be zero") + } + mm_atomic.StoreUint64(&mmGetInfo.expectedInvocations, n) + mmGetInfo.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmGetInfo +} + +func (mmGetInfo *mUserServiceMockGetInfo) invocationsDone() bool { + if len(mmGetInfo.expectations) == 0 && mmGetInfo.defaultExpectation == nil && mmGetInfo.mock.funcGetInfo == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmGetInfo.mock.afterGetInfoCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmGetInfo.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// GetInfo implements mm_service.UserService +func (mmGetInfo *UserServiceMock) GetInfo(ctx context.Context, userID int) (up1 *mm_service.UserInfo, err error) { + mm_atomic.AddUint64(&mmGetInfo.beforeGetInfoCounter, 1) + defer mm_atomic.AddUint64(&mmGetInfo.afterGetInfoCounter, 1) + + mmGetInfo.t.Helper() + + if mmGetInfo.inspectFuncGetInfo != nil { + mmGetInfo.inspectFuncGetInfo(ctx, userID) + } + + mm_params := UserServiceMockGetInfoParams{ctx, userID} + + // Record call args + mmGetInfo.GetInfoMock.mutex.Lock() + mmGetInfo.GetInfoMock.callArgs = append(mmGetInfo.GetInfoMock.callArgs, &mm_params) + mmGetInfo.GetInfoMock.mutex.Unlock() + + for _, e := range mmGetInfo.GetInfoMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.up1, e.results.err + } + } + + if mmGetInfo.GetInfoMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmGetInfo.GetInfoMock.defaultExpectation.Counter, 1) + mm_want := mmGetInfo.GetInfoMock.defaultExpectation.params + mm_want_ptrs := mmGetInfo.GetInfoMock.defaultExpectation.paramPtrs + + mm_got := UserServiceMockGetInfoParams{ctx, userID} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmGetInfo.t.Errorf("UserServiceMock.GetInfo got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetInfo.GetInfoMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.userID != nil && !minimock.Equal(*mm_want_ptrs.userID, mm_got.userID) { + mmGetInfo.t.Errorf("UserServiceMock.GetInfo got unexpected parameter userID, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetInfo.GetInfoMock.defaultExpectation.expectationOrigins.originUserID, *mm_want_ptrs.userID, mm_got.userID, minimock.Diff(*mm_want_ptrs.userID, mm_got.userID)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmGetInfo.t.Errorf("UserServiceMock.GetInfo got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetInfo.GetInfoMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmGetInfo.GetInfoMock.defaultExpectation.results + if mm_results == nil { + mmGetInfo.t.Fatal("No results are set for the UserServiceMock.GetInfo") + } + return (*mm_results).up1, (*mm_results).err + } + if mmGetInfo.funcGetInfo != nil { + return mmGetInfo.funcGetInfo(ctx, userID) + } + mmGetInfo.t.Fatalf("Unexpected call to UserServiceMock.GetInfo. %v %v", ctx, userID) + return +} + +// GetInfoAfterCounter returns a count of finished UserServiceMock.GetInfo invocations +func (mmGetInfo *UserServiceMock) GetInfoAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetInfo.afterGetInfoCounter) +} + +// GetInfoBeforeCounter returns a count of UserServiceMock.GetInfo invocations +func (mmGetInfo *UserServiceMock) GetInfoBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetInfo.beforeGetInfoCounter) +} + +// Calls returns a list of arguments used in each call to UserServiceMock.GetInfo. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmGetInfo *mUserServiceMockGetInfo) Calls() []*UserServiceMockGetInfoParams { + mmGetInfo.mutex.RLock() + + argCopy := make([]*UserServiceMockGetInfoParams, len(mmGetInfo.callArgs)) + copy(argCopy, mmGetInfo.callArgs) + + mmGetInfo.mutex.RUnlock() + + return argCopy +} + +// MinimockGetInfoDone returns true if the count of the GetInfo invocations corresponds +// the number of defined expectations +func (m *UserServiceMock) MinimockGetInfoDone() bool { + if m.GetInfoMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.GetInfoMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.GetInfoMock.invocationsDone() +} + +// MinimockGetInfoInspect logs each unmet expectation +func (m *UserServiceMock) MinimockGetInfoInspect() { + for _, e := range m.GetInfoMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to UserServiceMock.GetInfo at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterGetInfoCounter := mm_atomic.LoadUint64(&m.afterGetInfoCounter) + // if default expectation was set then invocations count should be greater than zero + if m.GetInfoMock.defaultExpectation != nil && afterGetInfoCounter < 1 { + if m.GetInfoMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to UserServiceMock.GetInfo at\n%s", m.GetInfoMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to UserServiceMock.GetInfo at\n%s with params: %#v", m.GetInfoMock.defaultExpectation.expectationOrigins.origin, *m.GetInfoMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcGetInfo != nil && afterGetInfoCounter < 1 { + m.t.Errorf("Expected call to UserServiceMock.GetInfo at\n%s", m.funcGetInfoOrigin) + } + + if !m.GetInfoMock.invocationsDone() && afterGetInfoCounter > 0 { + m.t.Errorf("Expected %d calls to UserServiceMock.GetInfo at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.GetInfoMock.expectedInvocations), m.GetInfoMock.expectedInvocationsOrigin, afterGetInfoCounter) + } +} + +type mUserServiceMockGetStatistics struct { + optional bool + mock *UserServiceMock + defaultExpectation *UserServiceMockGetStatisticsExpectation + expectations []*UserServiceMockGetStatisticsExpectation + + callArgs []*UserServiceMockGetStatisticsParams + mutex sync.RWMutex + + expectedInvocations uint64 + expectedInvocationsOrigin string +} + +// UserServiceMockGetStatisticsExpectation specifies expectation struct of the UserService.GetStatistics +type UserServiceMockGetStatisticsExpectation struct { + mock *UserServiceMock + params *UserServiceMockGetStatisticsParams + paramPtrs *UserServiceMockGetStatisticsParamPtrs + expectationOrigins UserServiceMockGetStatisticsExpectationOrigins + results *UserServiceMockGetStatisticsResults + returnOrigin string + Counter uint64 +} + +// UserServiceMockGetStatisticsParams contains parameters of the UserService.GetStatistics +type UserServiceMockGetStatisticsParams struct { + ctx context.Context + userID int +} + +// UserServiceMockGetStatisticsParamPtrs contains pointers to parameters of the UserService.GetStatistics +type UserServiceMockGetStatisticsParamPtrs struct { + ctx *context.Context + userID *int +} + +// UserServiceMockGetStatisticsResults contains results of the UserService.GetStatistics +type UserServiceMockGetStatisticsResults struct { + sp1 *mm_service.Statistics + err error +} + +// UserServiceMockGetStatisticsOrigins contains origins of expectations of the UserService.GetStatistics +type UserServiceMockGetStatisticsExpectationOrigins struct { + origin string + originCtx string + originUserID string +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmGetStatistics *mUserServiceMockGetStatistics) Optional() *mUserServiceMockGetStatistics { + mmGetStatistics.optional = true + return mmGetStatistics +} + +// Expect sets up expected params for UserService.GetStatistics +func (mmGetStatistics *mUserServiceMockGetStatistics) Expect(ctx context.Context, userID int) *mUserServiceMockGetStatistics { + if mmGetStatistics.mock.funcGetStatistics != nil { + mmGetStatistics.mock.t.Fatalf("UserServiceMock.GetStatistics mock is already set by Set") + } + + if mmGetStatistics.defaultExpectation == nil { + mmGetStatistics.defaultExpectation = &UserServiceMockGetStatisticsExpectation{} + } + + if mmGetStatistics.defaultExpectation.paramPtrs != nil { + mmGetStatistics.mock.t.Fatalf("UserServiceMock.GetStatistics mock is already set by ExpectParams functions") + } + + mmGetStatistics.defaultExpectation.params = &UserServiceMockGetStatisticsParams{ctx, userID} + mmGetStatistics.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1) + for _, e := range mmGetStatistics.expectations { + if minimock.Equal(e.params, mmGetStatistics.defaultExpectation.params) { + mmGetStatistics.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetStatistics.defaultExpectation.params) + } + } + + return mmGetStatistics +} + +// ExpectCtxParam1 sets up expected param ctx for UserService.GetStatistics +func (mmGetStatistics *mUserServiceMockGetStatistics) ExpectCtxParam1(ctx context.Context) *mUserServiceMockGetStatistics { + if mmGetStatistics.mock.funcGetStatistics != nil { + mmGetStatistics.mock.t.Fatalf("UserServiceMock.GetStatistics mock is already set by Set") + } + + if mmGetStatistics.defaultExpectation == nil { + mmGetStatistics.defaultExpectation = &UserServiceMockGetStatisticsExpectation{} + } + + if mmGetStatistics.defaultExpectation.params != nil { + mmGetStatistics.mock.t.Fatalf("UserServiceMock.GetStatistics mock is already set by Expect") + } + + if mmGetStatistics.defaultExpectation.paramPtrs == nil { + mmGetStatistics.defaultExpectation.paramPtrs = &UserServiceMockGetStatisticsParamPtrs{} + } + mmGetStatistics.defaultExpectation.paramPtrs.ctx = &ctx + mmGetStatistics.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1) + + return mmGetStatistics +} + +// ExpectUserIDParam2 sets up expected param userID for UserService.GetStatistics +func (mmGetStatistics *mUserServiceMockGetStatistics) ExpectUserIDParam2(userID int) *mUserServiceMockGetStatistics { + if mmGetStatistics.mock.funcGetStatistics != nil { + mmGetStatistics.mock.t.Fatalf("UserServiceMock.GetStatistics mock is already set by Set") + } + + if mmGetStatistics.defaultExpectation == nil { + mmGetStatistics.defaultExpectation = &UserServiceMockGetStatisticsExpectation{} + } + + if mmGetStatistics.defaultExpectation.params != nil { + mmGetStatistics.mock.t.Fatalf("UserServiceMock.GetStatistics mock is already set by Expect") + } + + if mmGetStatistics.defaultExpectation.paramPtrs == nil { + mmGetStatistics.defaultExpectation.paramPtrs = &UserServiceMockGetStatisticsParamPtrs{} + } + mmGetStatistics.defaultExpectation.paramPtrs.userID = &userID + mmGetStatistics.defaultExpectation.expectationOrigins.originUserID = minimock.CallerInfo(1) + + return mmGetStatistics +} + +// Inspect accepts an inspector function that has same arguments as the UserService.GetStatistics +func (mmGetStatistics *mUserServiceMockGetStatistics) Inspect(f func(ctx context.Context, userID int)) *mUserServiceMockGetStatistics { + if mmGetStatistics.mock.inspectFuncGetStatistics != nil { + mmGetStatistics.mock.t.Fatalf("Inspect function is already set for UserServiceMock.GetStatistics") + } + + mmGetStatistics.mock.inspectFuncGetStatistics = f + + return mmGetStatistics +} + +// Return sets up results that will be returned by UserService.GetStatistics +func (mmGetStatistics *mUserServiceMockGetStatistics) Return(sp1 *mm_service.Statistics, err error) *UserServiceMock { + if mmGetStatistics.mock.funcGetStatistics != nil { + mmGetStatistics.mock.t.Fatalf("UserServiceMock.GetStatistics mock is already set by Set") + } + + if mmGetStatistics.defaultExpectation == nil { + mmGetStatistics.defaultExpectation = &UserServiceMockGetStatisticsExpectation{mock: mmGetStatistics.mock} + } + mmGetStatistics.defaultExpectation.results = &UserServiceMockGetStatisticsResults{sp1, err} + mmGetStatistics.defaultExpectation.returnOrigin = minimock.CallerInfo(1) + return mmGetStatistics.mock +} + +// Set uses given function f to mock the UserService.GetStatistics method +func (mmGetStatistics *mUserServiceMockGetStatistics) Set(f func(ctx context.Context, userID int) (sp1 *mm_service.Statistics, err error)) *UserServiceMock { + if mmGetStatistics.defaultExpectation != nil { + mmGetStatistics.mock.t.Fatalf("Default expectation is already set for the UserService.GetStatistics method") + } + + if len(mmGetStatistics.expectations) > 0 { + mmGetStatistics.mock.t.Fatalf("Some expectations are already set for the UserService.GetStatistics method") + } + + mmGetStatistics.mock.funcGetStatistics = f + mmGetStatistics.mock.funcGetStatisticsOrigin = minimock.CallerInfo(1) + return mmGetStatistics.mock +} + +// When sets expectation for the UserService.GetStatistics which will trigger the result defined by the following +// Then helper +func (mmGetStatistics *mUserServiceMockGetStatistics) When(ctx context.Context, userID int) *UserServiceMockGetStatisticsExpectation { + if mmGetStatistics.mock.funcGetStatistics != nil { + mmGetStatistics.mock.t.Fatalf("UserServiceMock.GetStatistics mock is already set by Set") + } + + expectation := &UserServiceMockGetStatisticsExpectation{ + mock: mmGetStatistics.mock, + params: &UserServiceMockGetStatisticsParams{ctx, userID}, + expectationOrigins: UserServiceMockGetStatisticsExpectationOrigins{origin: minimock.CallerInfo(1)}, + } + mmGetStatistics.expectations = append(mmGetStatistics.expectations, expectation) + return expectation +} + +// Then sets up UserService.GetStatistics return parameters for the expectation previously defined by the When method +func (e *UserServiceMockGetStatisticsExpectation) Then(sp1 *mm_service.Statistics, err error) *UserServiceMock { + e.results = &UserServiceMockGetStatisticsResults{sp1, err} + return e.mock +} + +// Times sets number of times UserService.GetStatistics should be invoked +func (mmGetStatistics *mUserServiceMockGetStatistics) Times(n uint64) *mUserServiceMockGetStatistics { + if n == 0 { + mmGetStatistics.mock.t.Fatalf("Times of UserServiceMock.GetStatistics mock can not be zero") + } + mm_atomic.StoreUint64(&mmGetStatistics.expectedInvocations, n) + mmGetStatistics.expectedInvocationsOrigin = minimock.CallerInfo(1) + return mmGetStatistics +} + +func (mmGetStatistics *mUserServiceMockGetStatistics) invocationsDone() bool { + if len(mmGetStatistics.expectations) == 0 && mmGetStatistics.defaultExpectation == nil && mmGetStatistics.mock.funcGetStatistics == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmGetStatistics.mock.afterGetStatisticsCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmGetStatistics.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// GetStatistics implements mm_service.UserService +func (mmGetStatistics *UserServiceMock) GetStatistics(ctx context.Context, userID int) (sp1 *mm_service.Statistics, err error) { + mm_atomic.AddUint64(&mmGetStatistics.beforeGetStatisticsCounter, 1) + defer mm_atomic.AddUint64(&mmGetStatistics.afterGetStatisticsCounter, 1) + + mmGetStatistics.t.Helper() + + if mmGetStatistics.inspectFuncGetStatistics != nil { + mmGetStatistics.inspectFuncGetStatistics(ctx, userID) + } + + mm_params := UserServiceMockGetStatisticsParams{ctx, userID} + + // Record call args + mmGetStatistics.GetStatisticsMock.mutex.Lock() + mmGetStatistics.GetStatisticsMock.callArgs = append(mmGetStatistics.GetStatisticsMock.callArgs, &mm_params) + mmGetStatistics.GetStatisticsMock.mutex.Unlock() + + for _, e := range mmGetStatistics.GetStatisticsMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.sp1, e.results.err + } + } + + if mmGetStatistics.GetStatisticsMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmGetStatistics.GetStatisticsMock.defaultExpectation.Counter, 1) + mm_want := mmGetStatistics.GetStatisticsMock.defaultExpectation.params + mm_want_ptrs := mmGetStatistics.GetStatisticsMock.defaultExpectation.paramPtrs + + mm_got := UserServiceMockGetStatisticsParams{ctx, userID} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) { + mmGetStatistics.t.Errorf("UserServiceMock.GetStatistics got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetStatistics.GetStatisticsMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx)) + } + + if mm_want_ptrs.userID != nil && !minimock.Equal(*mm_want_ptrs.userID, mm_got.userID) { + mmGetStatistics.t.Errorf("UserServiceMock.GetStatistics got unexpected parameter userID, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetStatistics.GetStatisticsMock.defaultExpectation.expectationOrigins.originUserID, *mm_want_ptrs.userID, mm_got.userID, minimock.Diff(*mm_want_ptrs.userID, mm_got.userID)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmGetStatistics.t.Errorf("UserServiceMock.GetStatistics got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n", + mmGetStatistics.GetStatisticsMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmGetStatistics.GetStatisticsMock.defaultExpectation.results + if mm_results == nil { + mmGetStatistics.t.Fatal("No results are set for the UserServiceMock.GetStatistics") + } + return (*mm_results).sp1, (*mm_results).err + } + if mmGetStatistics.funcGetStatistics != nil { + return mmGetStatistics.funcGetStatistics(ctx, userID) + } + mmGetStatistics.t.Fatalf("Unexpected call to UserServiceMock.GetStatistics. %v %v", ctx, userID) + return +} + +// GetStatisticsAfterCounter returns a count of finished UserServiceMock.GetStatistics invocations +func (mmGetStatistics *UserServiceMock) GetStatisticsAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetStatistics.afterGetStatisticsCounter) +} + +// GetStatisticsBeforeCounter returns a count of UserServiceMock.GetStatistics invocations +func (mmGetStatistics *UserServiceMock) GetStatisticsBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetStatistics.beforeGetStatisticsCounter) +} + +// Calls returns a list of arguments used in each call to UserServiceMock.GetStatistics. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmGetStatistics *mUserServiceMockGetStatistics) Calls() []*UserServiceMockGetStatisticsParams { + mmGetStatistics.mutex.RLock() + + argCopy := make([]*UserServiceMockGetStatisticsParams, len(mmGetStatistics.callArgs)) + copy(argCopy, mmGetStatistics.callArgs) + + mmGetStatistics.mutex.RUnlock() + + return argCopy +} + +// MinimockGetStatisticsDone returns true if the count of the GetStatistics invocations corresponds +// the number of defined expectations +func (m *UserServiceMock) MinimockGetStatisticsDone() bool { + if m.GetStatisticsMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.GetStatisticsMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.GetStatisticsMock.invocationsDone() +} + +// MinimockGetStatisticsInspect logs each unmet expectation +func (m *UserServiceMock) MinimockGetStatisticsInspect() { + for _, e := range m.GetStatisticsMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to UserServiceMock.GetStatistics at\n%s with params: %#v", e.expectationOrigins.origin, *e.params) + } + } + + afterGetStatisticsCounter := mm_atomic.LoadUint64(&m.afterGetStatisticsCounter) + // if default expectation was set then invocations count should be greater than zero + if m.GetStatisticsMock.defaultExpectation != nil && afterGetStatisticsCounter < 1 { + if m.GetStatisticsMock.defaultExpectation.params == nil { + m.t.Errorf("Expected call to UserServiceMock.GetStatistics at\n%s", m.GetStatisticsMock.defaultExpectation.returnOrigin) + } else { + m.t.Errorf("Expected call to UserServiceMock.GetStatistics at\n%s with params: %#v", m.GetStatisticsMock.defaultExpectation.expectationOrigins.origin, *m.GetStatisticsMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcGetStatistics != nil && afterGetStatisticsCounter < 1 { + m.t.Errorf("Expected call to UserServiceMock.GetStatistics at\n%s", m.funcGetStatisticsOrigin) + } + + if !m.GetStatisticsMock.invocationsDone() && afterGetStatisticsCounter > 0 { + m.t.Errorf("Expected %d calls to UserServiceMock.GetStatistics at\n%s but found %d calls", + mm_atomic.LoadUint64(&m.GetStatisticsMock.expectedInvocations), m.GetStatisticsMock.expectedInvocationsOrigin, afterGetStatisticsCounter) + } +} + +// MinimockFinish checks that all mocked methods have been called the expected number of times +func (m *UserServiceMock) MinimockFinish() { + m.finishOnce.Do(func() { + if !m.minimockDone() { + m.MinimockGetBalanceInspect() + + m.MinimockGetInfoInspect() + + m.MinimockGetStatisticsInspect() + } + }) +} + +// MinimockWait waits for all mocked methods to be called the expected number of times +func (m *UserServiceMock) MinimockWait(timeout mm_time.Duration) { + timeoutCh := mm_time.After(timeout) + for { + if m.minimockDone() { + return + } + select { + case <-timeoutCh: + m.MinimockFinish() + return + case <-mm_time.After(10 * mm_time.Millisecond): + } + } +} + +func (m *UserServiceMock) minimockDone() bool { + done := true + return done && + m.MinimockGetBalanceDone() && + m.MinimockGetInfoDone() && + m.MinimockGetStatisticsDone() +} diff --git a/internal/model/invite.go b/internal/model/invite.go new file mode 100644 index 0000000..a15e84c --- /dev/null +++ b/internal/model/invite.go @@ -0,0 +1,14 @@ +package model + +import "time" + +type InviteCode struct { + ID int + UserID int + Code int64 + CanBeUsedCount int + UsedCount int + IsActive bool + CreatedAt time.Time + ExpiresAt time.Time +} diff --git a/internal/model/request.go b/internal/model/request.go new file mode 100644 index 0000000..ac7ff94 --- /dev/null +++ b/internal/model/request.go @@ -0,0 +1,40 @@ +package model + +import ( + "time" + + "github.com/google/uuid" +) + +type Request struct { + ID uuid.UUID + UserID int + RequestTxt string + GeneratedTZ bool + FinalTZ string + GeneratedFinalTZ bool + FinalUpdateTZ string + MailingStatusID int + MailingStatus string + CreatedAt time.Time +} + +type MailingStatus struct { + ID int + StatusName string +} + +type RequestDetail struct { + RequestID uuid.UUID + Title string + MailText string + Suppliers []SupplierInfo +} + +type SupplierInfo struct { + CompanyID int `json:"company_id"` + Email string `json:"email"` + Phone string `json:"phone"` + CompanyName string `json:"company_name"` + URL string `json:"url"` +} diff --git a/internal/model/session.go b/internal/model/session.go new file mode 100644 index 0000000..1dac095 --- /dev/null +++ b/internal/model/session.go @@ -0,0 +1,15 @@ +package model + +import "time" + +type Session struct { + ID int + UserID int + AccessToken string + RefreshToken string + IP string + UserAgent string + CreatedAt time.Time + ExpiresAt time.Time + RevokedAt *time.Time +} diff --git a/internal/model/supplier.go b/internal/model/supplier.go new file mode 100644 index 0000000..285c6a1 --- /dev/null +++ b/internal/model/supplier.go @@ -0,0 +1,28 @@ +package model + +import ( + "time" + + "github.com/google/uuid" +) + +type Supplier struct { + ID int + RequestID uuid.UUID + Name string + Email string + Phone string + Address string + URL string + CreatedAt time.Time +} + +type TokenUsage struct { + ID int + RequestID uuid.UUID + RequestTokenCount int + ResponseTokenCount int + TokenCost float64 + Type string + CreatedAt time.Time +} diff --git a/internal/model/user.go b/internal/model/user.go new file mode 100644 index 0000000..a41d07d --- /dev/null +++ b/internal/model/user.go @@ -0,0 +1,18 @@ +package model + +import "time" + +type User struct { + ID int + Email string + EmailHash string + PasswordHash string + Phone string + UserName string + CompanyName string + Balance float64 + PaymentStatus string + InvitesIssued int + InvitesLimit int + CreatedAt time.Time +} diff --git a/internal/repository/interfaces.go b/internal/repository/interfaces.go new file mode 100644 index 0000000..d69b2d1 --- /dev/null +++ b/internal/repository/interfaces.go @@ -0,0 +1,54 @@ +package repository + +import ( + "context" + + "github.com/google/uuid" + "smart-search-back/internal/model" +) + +type UserRepository interface { + FindByEmailHash(ctx context.Context, emailHash string) (*model.User, error) + FindByID(ctx context.Context, userID int) (*model.User, error) + Create(ctx context.Context, user *model.User) error + UpdateBalance(ctx context.Context, userID int, delta float64) error + GetBalance(ctx context.Context, userID int) (float64, error) + IncrementInvitesIssued(ctx context.Context, userID int) error + CheckInviteLimit(ctx context.Context, userID int) (bool, error) +} + +type SessionRepository interface { + Create(ctx context.Context, session *model.Session) error + FindByRefreshToken(ctx context.Context, token string) (*model.Session, error) + UpdateAccessToken(ctx context.Context, refreshToken, newAccessToken string) error + Revoke(ctx context.Context, refreshToken string) error + DeleteExpired(ctx context.Context) (int, error) +} + +type InviteRepository interface { + Create(ctx context.Context, invite *model.InviteCode) error + FindByCode(ctx context.Context, code int64) (*model.InviteCode, error) + IncrementUsedCount(ctx context.Context, code int64) error + DeactivateExpired(ctx context.Context) (int, error) + GetUserInvites(ctx context.Context, userID int) ([]*model.InviteCode, error) +} + +type RequestRepository interface { + Create(ctx context.Context, req *model.Request) error + UpdateWithTZ(ctx context.Context, id uuid.UUID, tz string, generated bool) error + UpdateFinalTZ(ctx context.Context, id uuid.UUID, finalTZ string) error + GetByUserID(ctx context.Context, userID int) ([]*model.Request, error) + GetByID(ctx context.Context, id uuid.UUID) (*model.Request, error) + GetDetailByID(ctx context.Context, id uuid.UUID) (*model.RequestDetail, error) + GetUserStatistics(ctx context.Context, userID int) (requestsCount, suppliersCount, createdTZ int, err error) +} + +type SupplierRepository interface { + BulkInsert(ctx context.Context, requestID uuid.UUID, suppliers []*model.Supplier) error + GetByRequestID(ctx context.Context, requestID uuid.UUID) ([]*model.Supplier, error) + DeleteByRequestID(ctx context.Context, requestID uuid.UUID) error +} + +type TokenUsageRepository interface { + Create(ctx context.Context, usage *model.TokenUsage) error +} diff --git a/internal/repository/invite.go b/internal/repository/invite.go new file mode 100644 index 0000000..3a96a80 --- /dev/null +++ b/internal/repository/invite.go @@ -0,0 +1,146 @@ +package repository + +import ( + "context" + "errors" + + "smart-search-back/internal/model" + errs "smart-search-back/pkg/errors" + + sq "github.com/Masterminds/squirrel" + "github.com/jackc/pgx/v5" + "github.com/jackc/pgx/v5/pgxpool" +) + +type inviteRepository struct { + pool *pgxpool.Pool + qb sq.StatementBuilderType +} + +func NewInviteRepository(pool *pgxpool.Pool) InviteRepository { + return &inviteRepository{ + pool: pool, + qb: sq.StatementBuilder.PlaceholderFormat(sq.Dollar), + } +} + +func (r *inviteRepository) Create(ctx context.Context, invite *model.InviteCode) error { + query := r.qb.Insert("invite_codes").Columns( + "user_id", "code", "can_be_used_count", "expires_at", + ).Values( + invite.UserID, invite.Code, invite.CanBeUsedCount, invite.ExpiresAt, + ).Suffix("RETURNING id, created_at") + + sqlQuery, args, err := query.ToSql() + if err != nil { + return errs.NewInternalError(errs.DatabaseError, "failed to build query", err) + } + + err = r.pool.QueryRow(ctx, sqlQuery, args...).Scan(&invite.ID, &invite.CreatedAt) + if err != nil { + return errs.NewInternalError(errs.DatabaseError, "failed to create invite code", err) + } + + return nil +} + +func (r *inviteRepository) FindByCode(ctx context.Context, code int64) (*model.InviteCode, error) { + query := r.qb.Select( + "id", "user_id", "code", "can_be_used_count", "used_count", + "is_active", "created_at", "expires_at", + ).From("invite_codes").Where(sq.Eq{"code": code}) + + sqlQuery, args, err := query.ToSql() + if err != nil { + return nil, errs.NewInternalError(errs.DatabaseError, "failed to build query", err) + } + + invite := &model.InviteCode{} + err = r.pool.QueryRow(ctx, sqlQuery, args...).Scan( + &invite.ID, &invite.UserID, &invite.Code, &invite.CanBeUsedCount, + &invite.UsedCount, &invite.IsActive, &invite.CreatedAt, &invite.ExpiresAt, + ) + + if errors.Is(err, pgx.ErrNoRows) { + return nil, errs.NewBusinessError(errs.UserNotFound, "invite code not found") + } + if err != nil { + return nil, errs.NewInternalError(errs.DatabaseError, "failed to find invite code", err) + } + + return invite, nil +} + +func (r *inviteRepository) IncrementUsedCount(ctx context.Context, code int64) error { + query := r.qb.Update("invite_codes"). + Set("used_count", sq.Expr("used_count + 1")). + Where(sq.Eq{"code": code}) + + sqlQuery, args, err := query.ToSql() + if err != nil { + return errs.NewInternalError(errs.DatabaseError, "failed to build query", err) + } + + _, err = r.pool.Exec(ctx, sqlQuery, args...) + if err != nil { + return errs.NewInternalError(errs.DatabaseError, "failed to increment used count", err) + } + + return nil +} + +func (r *inviteRepository) DeactivateExpired(ctx context.Context) (int, error) { + query := r.qb.Update("invite_codes"). + Set("is_active", false). + Where(sq.And{ + sq.Expr("expires_at < now()"), + sq.Eq{"is_active": true}, + }) + + sqlQuery, args, err := query.ToSql() + if err != nil { + return 0, errs.NewInternalError(errs.DatabaseError, "failed to build query", err) + } + + result, err := r.pool.Exec(ctx, sqlQuery, args...) + if err != nil { + return 0, errs.NewInternalError(errs.DatabaseError, "failed to deactivate expired invites", err) + } + + return int(result.RowsAffected()), nil +} + +func (r *inviteRepository) GetUserInvites(ctx context.Context, userID int) ([]*model.InviteCode, error) { + query := r.qb.Select( + "id", "user_id", "code", "can_be_used_count", "used_count", + "is_active", "created_at", "expires_at", + ).From("invite_codes"). + Where(sq.Eq{"user_id": userID}). + OrderBy("created_at DESC") + + sqlQuery, args, err := query.ToSql() + if err != nil { + return nil, errs.NewInternalError(errs.DatabaseError, "failed to build query", err) + } + + rows, err := r.pool.Query(ctx, sqlQuery, args...) + if err != nil { + return nil, errs.NewInternalError(errs.DatabaseError, "failed to get user invites", err) + } + defer rows.Close() + + var invites []*model.InviteCode + for rows.Next() { + invite := &model.InviteCode{} + err := rows.Scan( + &invite.ID, &invite.UserID, &invite.Code, &invite.CanBeUsedCount, + &invite.UsedCount, &invite.IsActive, &invite.CreatedAt, &invite.ExpiresAt, + ) + if err != nil { + return nil, errs.NewInternalError(errs.DatabaseError, "failed to scan invite", err) + } + invites = append(invites, invite) + } + + return invites, nil +} diff --git a/internal/repository/request.go b/internal/repository/request.go new file mode 100644 index 0000000..299b67d --- /dev/null +++ b/internal/repository/request.go @@ -0,0 +1,209 @@ +package repository + +import ( + "context" + "encoding/json" + "errors" + + "smart-search-back/internal/model" + errs "smart-search-back/pkg/errors" + + sq "github.com/Masterminds/squirrel" + "github.com/google/uuid" + "github.com/jackc/pgx/v5" + "github.com/jackc/pgx/v5/pgxpool" +) + +type requestRepository struct { + pool *pgxpool.Pool + qb sq.StatementBuilderType +} + +func NewRequestRepository(pool *pgxpool.Pool) RequestRepository { + return &requestRepository{ + pool: pool, + qb: sq.StatementBuilder.PlaceholderFormat(sq.Dollar), + } +} + +func (r *requestRepository) Create(ctx context.Context, req *model.Request) error { + query := r.qb.Insert("requests_for_suppliers").Columns( + "user_id", "request_txt", + ).Values( + req.UserID, req.RequestTxt, + ).Suffix("RETURNING id, created_at") + + sqlQuery, args, err := query.ToSql() + if err != nil { + return errs.NewInternalError(errs.DatabaseError, "failed to build query", err) + } + + err = r.pool.QueryRow(ctx, sqlQuery, args...).Scan(&req.ID, &req.CreatedAt) + if err != nil { + return errs.NewInternalError(errs.DatabaseError, "failed to create request", err) + } + + return nil +} + +func (r *requestRepository) UpdateWithTZ(ctx context.Context, id uuid.UUID, tz string, generated bool) error { + query := r.qb.Update("requests_for_suppliers"). + Set("final_tz", tz). + Set("generated_tz", generated). + Set("generated_final_tz", generated). + Where(sq.Eq{"id": id}) + + sqlQuery, args, err := query.ToSql() + if err != nil { + return errs.NewInternalError(errs.DatabaseError, "failed to build query", err) + } + + _, err = r.pool.Exec(ctx, sqlQuery, args...) + if err != nil { + return errs.NewInternalError(errs.DatabaseError, "failed to update request", err) + } + + return nil +} + +func (r *requestRepository) UpdateFinalTZ(ctx context.Context, id uuid.UUID, finalTZ string) error { + query := r.qb.Update("requests_for_suppliers"). + Set("final_update_tz", finalTZ). + Where(sq.Eq{"id": id}) + + sqlQuery, args, err := query.ToSql() + if err != nil { + return errs.NewInternalError(errs.DatabaseError, "failed to build query", err) + } + + _, err = r.pool.Exec(ctx, sqlQuery, args...) + if err != nil { + return errs.NewInternalError(errs.DatabaseError, "failed to update final TZ", err) + } + + return nil +} + +func (r *requestRepository) GetByUserID(ctx context.Context, userID int) ([]*model.Request, error) { + query := r.qb.Select( + "r.id", "r.request_txt", "ms.status_name as mailing_status", + ).From("requests_for_suppliers r"). + Join("mailing_status ms ON r.mailling_status_id = ms.id"). + Where(sq.Eq{"r.user_id": userID}). + OrderBy("r.created_at DESC") + + sqlQuery, args, err := query.ToSql() + if err != nil { + return nil, errs.NewInternalError(errs.DatabaseError, "failed to build query", err) + } + + rows, err := r.pool.Query(ctx, sqlQuery, args...) + if err != nil { + return nil, errs.NewInternalError(errs.DatabaseError, "failed to get requests", err) + } + defer rows.Close() + + var requests []*model.Request + for rows.Next() { + req := &model.Request{} + var statusName string + err := rows.Scan(&req.ID, &req.RequestTxt, &statusName) + if err != nil { + return nil, errs.NewInternalError(errs.DatabaseError, "failed to scan request", err) + } + requests = append(requests, req) + } + + return requests, nil +} + +func (r *requestRepository) GetByID(ctx context.Context, id uuid.UUID) (*model.Request, error) { + query := r.qb.Select( + "id", "user_id", "request_txt", "generated_tz", "final_tz", + "generated_final_tz", "final_update_tz", "mailling_status_id", "created_at", + ).From("requests_for_suppliers").Where(sq.Eq{"id": id}) + + sqlQuery, args, err := query.ToSql() + if err != nil { + return nil, errs.NewInternalError(errs.DatabaseError, "failed to build query", err) + } + + req := &model.Request{} + err = r.pool.QueryRow(ctx, sqlQuery, args...).Scan( + &req.ID, &req.UserID, &req.RequestTxt, &req.GeneratedTZ, + &req.FinalTZ, &req.GeneratedFinalTZ, &req.FinalUpdateTZ, + &req.MailingStatusID, &req.CreatedAt, + ) + + if errors.Is(err, pgx.ErrNoRows) { + return nil, errs.NewBusinessError(errs.RequestNotFound, "request not found") + } + if err != nil { + return nil, errs.NewInternalError(errs.DatabaseError, "failed to get request", err) + } + + return req, nil +} + +func (r *requestRepository) GetDetailByID(ctx context.Context, id uuid.UUID) (*model.RequestDetail, error) { + sqlQuery := ` + SELECT + r.id AS request_id, + r.request_txt AS title, + r.final_update_tz AS mail_text, + COALESCE(json_agg( + json_build_object( + 'email', COALESCE(s.email, ''), + 'phone', COALESCE(s.phone, ''), + 'company_name', COALESCE(s.name, ''), + 'company_id', s.id, + 'url', COALESCE(s.url, '') + ) + ) FILTER (WHERE s.id IS NOT NULL), '[]') AS suppliers + FROM requests_for_suppliers r + LEFT JOIN suppliers s ON s.request_id = r.id + WHERE r.id = $1 + GROUP BY r.id, r.request_txt, r.final_update_tz + ` + + detail := &model.RequestDetail{} + var suppliersJSON []byte + + err := r.pool.QueryRow(ctx, sqlQuery, id).Scan( + &detail.RequestID, &detail.Title, &detail.MailText, &suppliersJSON, + ) + + if err == pgx.ErrNoRows { + return nil, errs.NewBusinessError(errs.RequestNotFound, "request not found") + } + if err != nil { + return nil, errs.NewInternalError(errs.DatabaseError, "failed to get request detail", err) + } + + if len(suppliersJSON) > 0 && string(suppliersJSON) != "[]" { + if err := json.Unmarshal(suppliersJSON, &detail.Suppliers); err != nil { + return nil, errs.NewInternalError(errs.DatabaseError, "failed to parse suppliers", err) + } + } + + return detail, nil +} + +func (r *requestRepository) GetUserStatistics(ctx context.Context, userID int) (requestsCount, suppliersCount, createdTZ int, err error) { + sqlQuery := ` + SELECT + COUNT(DISTINCT r.id) AS requests_count, + COUNT(s.id) AS suppliers_count, + COUNT(r.request_txt) AS created_tz + FROM requests_for_suppliers r + LEFT JOIN suppliers s ON s.request_id = r.id + WHERE r.user_id = $1 + ` + + err = r.pool.QueryRow(ctx, sqlQuery, userID).Scan(&requestsCount, &suppliersCount, &createdTZ) + if err != nil { + return 0, 0, 0, errs.NewInternalError(errs.DatabaseError, "failed to get statistics", err) + } + + return requestsCount, suppliersCount, createdTZ, nil +} diff --git a/internal/repository/session.go b/internal/repository/session.go new file mode 100644 index 0000000..e3241b6 --- /dev/null +++ b/internal/repository/session.go @@ -0,0 +1,134 @@ +package repository + +import ( + "context" + "errors" + "time" + + "smart-search-back/internal/model" + errs "smart-search-back/pkg/errors" + + sq "github.com/Masterminds/squirrel" + "github.com/jackc/pgx/v5" + "github.com/jackc/pgx/v5/pgxpool" +) + +type sessionRepository struct { + pool *pgxpool.Pool + qb sq.StatementBuilderType +} + +func NewSessionRepository(pool *pgxpool.Pool) SessionRepository { + return &sessionRepository{ + pool: pool, + qb: sq.StatementBuilder.PlaceholderFormat(sq.Dollar), + } +} + +func (r *sessionRepository) Create(ctx context.Context, session *model.Session) error { + query := r.qb.Insert("sessions").Columns( + "user_id", "access_token", "refresh_token", "ip", "user_agent", "expires_at", + ).Values( + session.UserID, session.AccessToken, session.RefreshToken, + session.IP, session.UserAgent, session.ExpiresAt, + ).Suffix("RETURNING id") + + sqlQuery, args, err := query.ToSql() + if err != nil { + return errs.NewInternalError(errs.DatabaseError, "failed to build query", err) + } + + err = r.pool.QueryRow(ctx, sqlQuery, args...).Scan(&session.ID) + if err != nil { + return errs.NewInternalError(errs.DatabaseError, "failed to create session", err) + } + + return nil +} + +func (r *sessionRepository) FindByRefreshToken(ctx context.Context, token string) (*model.Session, error) { + query := r.qb.Select( + "id", "user_id", "access_token", "refresh_token", "ip", + "user_agent", "created_at", "expires_at", "revoked_at", + ).From("sessions").Where(sq.And{ + sq.Eq{"refresh_token": token}, + sq.Expr("revoked_at IS NULL"), + sq.Expr("expires_at > now()"), + }) + + sqlQuery, args, err := query.ToSql() + if err != nil { + return nil, errs.NewInternalError(errs.DatabaseError, "failed to build query", err) + } + + session := &model.Session{} + err = r.pool.QueryRow(ctx, sqlQuery, args...).Scan( + &session.ID, &session.UserID, &session.AccessToken, &session.RefreshToken, + &session.IP, &session.UserAgent, &session.CreatedAt, &session.ExpiresAt, + &session.RevokedAt, + ) + + if errors.Is(err, pgx.ErrNoRows) { + return nil, errs.NewBusinessError(errs.RefreshInvalid, "refresh token is invalid or expired") + } + if err != nil { + return nil, errs.NewInternalError(errs.DatabaseError, "failed to find session", err) + } + + return session, nil +} + +func (r *sessionRepository) UpdateAccessToken(ctx context.Context, refreshToken, newAccessToken string) error { + query := r.qb.Update("sessions"). + Set("access_token", newAccessToken). + Where(sq.Eq{"refresh_token": refreshToken}) + + sqlQuery, args, err := query.ToSql() + if err != nil { + return errs.NewInternalError(errs.DatabaseError, "failed to build query", err) + } + + _, err = r.pool.Exec(ctx, sqlQuery, args...) + if err != nil { + return errs.NewInternalError(errs.DatabaseError, "failed to update access token", err) + } + + return nil +} + +func (r *sessionRepository) Revoke(ctx context.Context, refreshToken string) error { + query := r.qb.Update("sessions"). + Set("revoked_at", time.Now()). + Where(sq.Eq{"refresh_token": refreshToken}) + + sqlQuery, args, err := query.ToSql() + if err != nil { + return errs.NewInternalError(errs.DatabaseError, "failed to build query", err) + } + + _, err = r.pool.Exec(ctx, sqlQuery, args...) + if err != nil { + return errs.NewInternalError(errs.DatabaseError, "failed to revoke session", err) + } + + return nil +} + +func (r *sessionRepository) DeleteExpired(ctx context.Context) (int, error) { + query := r.qb.Delete("sessions").Where(sq.Or{ + sq.Expr("expires_at < now()"), + sq.Expr("(revoked_at IS NOT NULL AND revoked_at < now() - interval '30 days')"), + }) + + sqlQuery, args, err := query.ToSql() + if err != nil { + return 0, errs.NewInternalError(errs.DatabaseError, "failed to build query", err) + } + + result, err := r.pool.Exec(ctx, sqlQuery, args...) + if err != nil { + return 0, errs.NewInternalError(errs.DatabaseError, "failed to delete expired sessions", err) + } + + return int(result.RowsAffected()), nil +} diff --git a/internal/repository/supplier.go b/internal/repository/supplier.go new file mode 100644 index 0000000..9a32a45 --- /dev/null +++ b/internal/repository/supplier.go @@ -0,0 +1,97 @@ +package repository + +import ( + "context" + + "smart-search-back/internal/model" + errs "smart-search-back/pkg/errors" + + sq "github.com/Masterminds/squirrel" + "github.com/google/uuid" + "github.com/jackc/pgx/v5/pgxpool" +) + +type supplierRepository struct { + pool *pgxpool.Pool + qb sq.StatementBuilderType +} + +func NewSupplierRepository(pool *pgxpool.Pool) SupplierRepository { + return &supplierRepository{ + pool: pool, + qb: sq.StatementBuilder.PlaceholderFormat(sq.Dollar), + } +} + +func (r *supplierRepository) BulkInsert(ctx context.Context, requestID uuid.UUID, suppliers []*model.Supplier) error { + if len(suppliers) == 0 { + return nil + } + + query := r.qb.Insert("suppliers").Columns( + "request_id", "name", "email", "phone", "adress", "url", + ) + + for _, s := range suppliers { + query = query.Values(requestID, s.Name, s.Email, s.Phone, s.Address, s.URL) + } + + sqlQuery, args, err := query.ToSql() + if err != nil { + return errs.NewInternalError(errs.DatabaseError, "failed to build query", err) + } + + _, err = r.pool.Exec(ctx, sqlQuery, args...) + if err != nil { + return errs.NewInternalError(errs.DatabaseError, "failed to bulk insert suppliers", err) + } + + return nil +} + +func (r *supplierRepository) GetByRequestID(ctx context.Context, requestID uuid.UUID) ([]*model.Supplier, error) { + query := r.qb.Select( + "id", "request_id", "name", "email", "phone", "adress", "url", "created_at", + ).From("suppliers").Where(sq.Eq{"request_id": requestID}).OrderBy("id") + + sqlQuery, args, err := query.ToSql() + if err != nil { + return nil, errs.NewInternalError(errs.DatabaseError, "failed to build query", err) + } + + rows, err := r.pool.Query(ctx, sqlQuery, args...) + if err != nil { + return nil, errs.NewInternalError(errs.DatabaseError, "failed to get suppliers", err) + } + defer rows.Close() + + var suppliers []*model.Supplier + for rows.Next() { + s := &model.Supplier{} + err := rows.Scan( + &s.ID, &s.RequestID, &s.Name, &s.Email, &s.Phone, &s.Address, &s.URL, &s.CreatedAt, + ) + if err != nil { + return nil, errs.NewInternalError(errs.DatabaseError, "failed to scan supplier", err) + } + suppliers = append(suppliers, s) + } + + return suppliers, nil +} + +func (r *supplierRepository) DeleteByRequestID(ctx context.Context, requestID uuid.UUID) error { + query := r.qb.Delete("suppliers").Where(sq.Eq{"request_id": requestID}) + + sqlQuery, args, err := query.ToSql() + if err != nil { + return errs.NewInternalError(errs.DatabaseError, "failed to build query", err) + } + + _, err = r.pool.Exec(ctx, sqlQuery, args...) + if err != nil { + return errs.NewInternalError(errs.DatabaseError, "failed to delete suppliers", err) + } + + return nil +} diff --git a/internal/repository/token_usage.go b/internal/repository/token_usage.go new file mode 100644 index 0000000..edb0619 --- /dev/null +++ b/internal/repository/token_usage.go @@ -0,0 +1,43 @@ +package repository + +import ( + "context" + + "smart-search-back/internal/model" + errs "smart-search-back/pkg/errors" + + sq "github.com/Masterminds/squirrel" + "github.com/jackc/pgx/v5/pgxpool" +) + +type tokenUsageRepository struct { + pool *pgxpool.Pool + qb sq.StatementBuilderType +} + +func NewTokenUsageRepository(pool *pgxpool.Pool) TokenUsageRepository { + return &tokenUsageRepository{ + pool: pool, + qb: sq.StatementBuilder.PlaceholderFormat(sq.Dollar), + } +} + +func (r *tokenUsageRepository) Create(ctx context.Context, usage *model.TokenUsage) error { + query := r.qb.Insert("request_token_usage").Columns( + "request_id", "request_token_count", "response_token_count", "token_cost", "type", + ).Values( + usage.RequestID, usage.RequestTokenCount, usage.ResponseTokenCount, usage.TokenCost, usage.Type, + ).Suffix("RETURNING id, created_at") + + sqlQuery, args, err := query.ToSql() + if err != nil { + return errs.NewInternalError(errs.DatabaseError, "failed to build query", err) + } + + err = r.pool.QueryRow(ctx, sqlQuery, args...).Scan(&usage.ID, &usage.CreatedAt) + if err != nil { + return errs.NewInternalError(errs.DatabaseError, "failed to create token usage", err) + } + + return nil +} diff --git a/internal/repository/user.go b/internal/repository/user.go new file mode 100644 index 0000000..45e4e6a --- /dev/null +++ b/internal/repository/user.go @@ -0,0 +1,199 @@ +package repository + +import ( + "context" + "errors" + + "smart-search-back/internal/model" + "smart-search-back/pkg/crypto" + errs "smart-search-back/pkg/errors" + + sq "github.com/Masterminds/squirrel" + "github.com/jackc/pgx/v5" + "github.com/jackc/pgx/v5/pgxpool" +) + +type userRepository struct { + pool *pgxpool.Pool + qb sq.StatementBuilderType + cryptoHelper *crypto.Crypto +} + +func NewUserRepository(pool *pgxpool.Pool, cryptoSecret string) UserRepository { + return &userRepository{ + pool: pool, + qb: sq.StatementBuilder.PlaceholderFormat(sq.Dollar), + cryptoHelper: crypto.NewCrypto(cryptoSecret), + } +} + +func (r *userRepository) FindByEmailHash(ctx context.Context, emailHash string) (*model.User, error) { + query := r.qb.Select( + "id", "email", "email_hash", "password_hash", "phone", + "user_name", "company_name", "balance", "payment_status", + "invites_issued", "invites_limit", "created_at", + ).From("users").Where(sq.Eq{"email_hash": emailHash}) + + sqlQuery, args, err := query.ToSql() + if err != nil { + return nil, errs.NewInternalError(errs.DatabaseError, "failed to build query", err) + } + + user := &model.User{} + err = r.pool.QueryRow(ctx, sqlQuery, args...).Scan( + &user.ID, &user.Email, &user.EmailHash, &user.PasswordHash, + &user.Phone, &user.UserName, &user.CompanyName, &user.Balance, + &user.PaymentStatus, &user.InvitesIssued, &user.InvitesLimit, &user.CreatedAt, + ) + + if errors.Is(err, pgx.ErrNoRows) { + return nil, errs.NewBusinessError(errs.UserNotFound, "user not found") + } + if err != nil { + return nil, errs.NewInternalError(errs.DatabaseError, "failed to find user", err) + } + + return user, nil +} + +func (r *userRepository) FindByID(ctx context.Context, userID int) (*model.User, error) { + query := r.qb.Select( + "id", "email", "email_hash", "password_hash", "phone", + "user_name", "company_name", "balance", "payment_status", + "invites_issued", "invites_limit", "created_at", + ).From("users").Where(sq.Eq{"id": userID}) + + sqlQuery, args, err := query.ToSql() + if err != nil { + return nil, errs.NewInternalError(errs.DatabaseError, "failed to build query", err) + } + + user := &model.User{} + err = r.pool.QueryRow(ctx, sqlQuery, args...).Scan( + &user.ID, &user.Email, &user.EmailHash, &user.PasswordHash, + &user.Phone, &user.UserName, &user.CompanyName, &user.Balance, + &user.PaymentStatus, &user.InvitesIssued, &user.InvitesLimit, &user.CreatedAt, + ) + + if errors.Is(err, pgx.ErrNoRows) { + return nil, errs.NewBusinessError(errs.UserNotFound, "user not found") + } + if err != nil { + return nil, errs.NewInternalError(errs.DatabaseError, "failed to find user", err) + } + + return user, nil +} + +func (r *userRepository) Create(ctx context.Context, user *model.User) error { + encryptedEmail, err := r.cryptoHelper.Encrypt(user.Email) + if err != nil { + return errs.NewInternalError(errs.EncryptionError, "failed to encrypt email", err) + } + + encryptedPhone, err := r.cryptoHelper.Encrypt(user.Phone) + if err != nil { + return errs.NewInternalError(errs.EncryptionError, "failed to encrypt phone", err) + } + + encryptedUserName, err := r.cryptoHelper.Encrypt(user.UserName) + if err != nil { + return errs.NewInternalError(errs.EncryptionError, "failed to encrypt user name", err) + } + + query := r.qb.Insert("users").Columns( + "email", "email_hash", "password_hash", "phone", "user_name", + "company_name", "balance", "payment_status", + ).Values( + encryptedEmail, user.EmailHash, user.PasswordHash, encryptedPhone, + encryptedUserName, user.CompanyName, user.Balance, user.PaymentStatus, + ).Suffix("RETURNING id") + + sqlQuery, args, err := query.ToSql() + if err != nil { + return errs.NewInternalError(errs.DatabaseError, "failed to build query", err) + } + + err = r.pool.QueryRow(ctx, sqlQuery, args...).Scan(&user.ID) + if err != nil { + return errs.NewInternalError(errs.DatabaseError, "failed to create user", err) + } + + return nil +} + +func (r *userRepository) UpdateBalance(ctx context.Context, userID int, delta float64) error { + query := r.qb.Update("users"). + Set("balance", sq.Expr("balance + ?", delta)). + Where(sq.Eq{"id": userID}) + + sqlQuery, args, err := query.ToSql() + if err != nil { + return errs.NewInternalError(errs.DatabaseError, "failed to build query", err) + } + + _, err = r.pool.Exec(ctx, sqlQuery, args...) + if err != nil { + return errs.NewInternalError(errs.DatabaseError, "failed to update balance", err) + } + + return nil +} + +func (r *userRepository) GetBalance(ctx context.Context, userID int) (float64, error) { + query := r.qb.Select("balance").From("users").Where(sq.Eq{"id": userID}) + + sqlQuery, args, err := query.ToSql() + if err != nil { + return 0, errs.NewInternalError(errs.DatabaseError, "failed to build query", err) + } + + var balance float64 + err = r.pool.QueryRow(ctx, sqlQuery, args...).Scan(&balance) + if errors.Is(err, pgx.ErrNoRows) { + return 0, errs.NewBusinessError(errs.UserNotFound, "user not found") + } + if err != nil { + return 0, errs.NewInternalError(errs.DatabaseError, "failed to get balance", err) + } + + return balance, nil +} + +func (r *userRepository) IncrementInvitesIssued(ctx context.Context, userID int) error { + query := r.qb.Update("users"). + Set("invites_issued", sq.Expr("invites_issued + 1")). + Where(sq.Eq{"id": userID}) + + sqlQuery, args, err := query.ToSql() + if err != nil { + return errs.NewInternalError(errs.DatabaseError, "failed to build query", err) + } + + _, err = r.pool.Exec(ctx, sqlQuery, args...) + if err != nil { + return errs.NewInternalError(errs.DatabaseError, "failed to increment invites issued", err) + } + + return nil +} + +func (r *userRepository) CheckInviteLimit(ctx context.Context, userID int) (bool, error) { + query := r.qb.Select("invites_issued", "invites_limit"). + From("users"). + Where(sq.Eq{"id": userID}). + Suffix("FOR UPDATE") + + sqlQuery, args, err := query.ToSql() + if err != nil { + return false, errs.NewInternalError(errs.DatabaseError, "failed to build query", err) + } + + var issued, limit int + err = r.pool.QueryRow(ctx, sqlQuery, args...).Scan(&issued, &limit) + if err != nil { + return false, errs.NewInternalError(errs.DatabaseError, "failed to check invite limit", err) + } + + return issued < limit, nil +} diff --git a/internal/service/auth.go b/internal/service/auth.go new file mode 100644 index 0000000..832b6cb --- /dev/null +++ b/internal/service/auth.go @@ -0,0 +1,107 @@ +package service + +import ( + "context" + "time" + + "smart-search-back/internal/model" + "smart-search-back/internal/repository" + "smart-search-back/pkg/crypto" + "smart-search-back/pkg/errors" + "smart-search-back/pkg/jwt" +) + +type authService struct { + userRepo repository.UserRepository + sessionRepo repository.SessionRepository + jwtSecret string + cryptoHelper *crypto.Crypto +} + +func NewAuthService(userRepo repository.UserRepository, sessionRepo repository.SessionRepository, jwtSecret, cryptoSecret string) AuthService { + return &authService{ + userRepo: userRepo, + sessionRepo: sessionRepo, + jwtSecret: jwtSecret, + cryptoHelper: crypto.NewCrypto(cryptoSecret), + } +} + +func (s *authService) Login(ctx context.Context, email, password, ip, userAgent string) (accessToken, refreshToken string, err error) { + emailHash := s.cryptoHelper.EmailHash(email) + + user, err := s.userRepo.FindByEmailHash(ctx, emailHash) + if err != nil { + return "", "", err + } + + passwordHash := crypto.PasswordHash(password) + if user.PasswordHash != passwordHash { + return "", "", errors.NewBusinessError(errors.AuthInvalidCredentials, "Invalid email or password") + } + + accessToken, err = jwt.GenerateAccessToken(user.ID, s.jwtSecret) + if err != nil { + return "", "", errors.NewInternalError(errors.InternalError, "failed to generate access token", err) + } + + refreshToken, err = jwt.GenerateRefreshToken(user.ID, s.jwtSecret) + if err != nil { + return "", "", errors.NewInternalError(errors.InternalError, "failed to generate refresh token", err) + } + + session := &model.Session{ + UserID: user.ID, + AccessToken: accessToken, + RefreshToken: refreshToken, + IP: ip, + UserAgent: userAgent, + ExpiresAt: time.Now().Add(30 * 24 * time.Hour), + } + + if err := s.sessionRepo.Create(ctx, session); err != nil { + return "", "", err + } + + return accessToken, refreshToken, nil +} + +func (s *authService) Refresh(ctx context.Context, refreshToken string) (string, error) { + session, err := s.sessionRepo.FindByRefreshToken(ctx, refreshToken) + if err != nil { + return "", err + } + + newAccessToken, err := jwt.GenerateAccessToken(session.UserID, s.jwtSecret) + if err != nil { + return "", errors.NewInternalError(errors.InternalError, "failed to generate access token", err) + } + + if err := s.sessionRepo.UpdateAccessToken(ctx, refreshToken, newAccessToken); err != nil { + return "", err + } + + return newAccessToken, nil +} + +func (s *authService) Validate(ctx context.Context, accessToken string) (int, error) { + claims, err := jwt.ValidateToken(accessToken, s.jwtSecret) + if err != nil { + return 0, errors.NewBusinessError(errors.AuthInvalidToken, "Invalid or expired token") + } + + if claims.Type != "access" { + return 0, errors.NewBusinessError(errors.AuthInvalidToken, "Token is not an access token") + } + + userID, err := jwt.GetUserIDFromToken(accessToken, s.jwtSecret) + if err != nil { + return 0, errors.NewBusinessError(errors.AuthInvalidToken, "Invalid user ID in token") + } + + return userID, nil +} + +func (s *authService) Logout(ctx context.Context, refreshToken string) error { + return s.sessionRepo.Revoke(ctx, refreshToken) +} diff --git a/internal/service/interfaces.go b/internal/service/interfaces.go new file mode 100644 index 0000000..401adc7 --- /dev/null +++ b/internal/service/interfaces.go @@ -0,0 +1,38 @@ +package service + +import ( + "context" + + "smart-search-back/internal/model" + + "github.com/google/uuid" +) + +type AuthService interface { + Login(ctx context.Context, email, password, ip, userAgent string) (accessToken, refreshToken string, err error) + Refresh(ctx context.Context, refreshToken string) (string, error) + Validate(ctx context.Context, accessToken string) (int, error) + Logout(ctx context.Context, refreshToken string) error +} + +type UserService interface { + GetInfo(ctx context.Context, userID int) (*UserInfo, error) + GetBalance(ctx context.Context, userID int) (float64, error) + GetStatistics(ctx context.Context, userID int) (*Statistics, error) +} + +type InviteService interface { + Generate(ctx context.Context, userID, maxUses, ttlDays int) (*model.InviteCode, error) + GetInfo(ctx context.Context, code int64) (*model.InviteCode, error) +} + +type RequestService interface { + CreateTZ(ctx context.Context, userID int, requestTxt string) (uuid.UUID, string, error) + ApproveTZ(ctx context.Context, requestID uuid.UUID, tzText string, userID int) ([]*model.Supplier, error) + GetMailingList(ctx context.Context, userID int) ([]*model.Request, error) + GetMailingListByID(ctx context.Context, requestID uuid.UUID) (*model.RequestDetail, error) +} + +type SupplierService interface { + ExportExcel(ctx context.Context, requestID uuid.UUID) ([]byte, error) +} diff --git a/internal/service/invite.go b/internal/service/invite.go new file mode 100644 index 0000000..e578f4f --- /dev/null +++ b/internal/service/invite.go @@ -0,0 +1,57 @@ +package service + +import ( + "context" + "math/rand" + "time" + + "smart-search-back/internal/model" + "smart-search-back/internal/repository" + "smart-search-back/pkg/errors" +) + +type inviteService struct { + inviteRepo repository.InviteRepository + userRepo repository.UserRepository +} + +func NewInviteService(inviteRepo repository.InviteRepository, userRepo repository.UserRepository) InviteService { + return &inviteService{ + inviteRepo: inviteRepo, + userRepo: userRepo, + } +} + +func (s *inviteService) Generate(ctx context.Context, userID, maxUses, ttlDays int) (*model.InviteCode, error) { + canIssue, err := s.userRepo.CheckInviteLimit(ctx, userID) + if err != nil { + return nil, err + } + + if !canIssue { + return nil, errors.NewBusinessError(errors.InviteLimitReached, "User reached maximum invite codes limit") + } + + code := rand.Int63n(90000000) + 10000000 + + invite := &model.InviteCode{ + UserID: userID, + Code: code, + CanBeUsedCount: maxUses, + ExpiresAt: time.Now().Add(time.Duration(ttlDays) * 24 * time.Hour), + } + + if err := s.inviteRepo.Create(ctx, invite); err != nil { + return nil, err + } + + if err := s.userRepo.IncrementInvitesIssued(ctx, userID); err != nil { + return nil, err + } + + return invite, nil +} + +func (s *inviteService) GetInfo(ctx context.Context, code int64) (*model.InviteCode, error) { + return s.inviteRepo.FindByCode(ctx, code) +} diff --git a/internal/service/request.go b/internal/service/request.go new file mode 100644 index 0000000..26e1a75 --- /dev/null +++ b/internal/service/request.go @@ -0,0 +1,154 @@ +package service + +import ( + "context" + "math" + + "github.com/google/uuid" + "smart-search-back/internal/ai" + "smart-search-back/internal/model" + "smart-search-back/internal/repository" + "smart-search-back/pkg/errors" +) + +type requestService struct { + requestRepo repository.RequestRepository + supplierRepo repository.SupplierRepository + tokenUsageRepo repository.TokenUsageRepository + userRepo repository.UserRepository + openAI *ai.OpenAIClient + perplexity *ai.PerplexityClient +} + +func NewRequestService( + requestRepo repository.RequestRepository, + supplierRepo repository.SupplierRepository, + tokenUsageRepo repository.TokenUsageRepository, + userRepo repository.UserRepository, + openAI *ai.OpenAIClient, + perplexity *ai.PerplexityClient, +) RequestService { + return &requestService{ + requestRepo: requestRepo, + supplierRepo: supplierRepo, + tokenUsageRepo: tokenUsageRepo, + userRepo: userRepo, + openAI: openAI, + perplexity: perplexity, + } +} + +func (s *requestService) CreateTZ(ctx context.Context, userID int, requestTxt string) (uuid.UUID, string, error) { + req := &model.Request{ + UserID: userID, + RequestTxt: requestTxt, + } + + if err := s.requestRepo.Create(ctx, req); err != nil { + return uuid.Nil, "", err + } + + if requestTxt == "" { + return req.ID, "", nil + } + + tzText, err := s.openAI.GenerateTZ(requestTxt) + if err != nil { + if err := s.requestRepo.UpdateWithTZ(ctx, req.ID, "", false); err != nil { + return req.ID, "", err + } + return req.ID, "", err + } + + inputLen := len(requestTxt) + outputLen := len(tzText) + promptTokens := 500 + + inputTokens := int(math.Ceil(float64(inputLen) / 2.0)) + outputTokens := int(math.Ceil(float64(outputLen) / 2.0)) + + totalTokens := inputTokens + outputTokens + promptTokens + tokenPrice := 25000.0 / 1000000.0 + cost := float64(totalTokens) * tokenPrice + + tokenUsage := &model.TokenUsage{ + RequestID: req.ID, + RequestTokenCount: inputTokens + promptTokens, + ResponseTokenCount: outputTokens, + TokenCost: cost, + Type: "tz", + } + + if err := s.tokenUsageRepo.Create(ctx, tokenUsage); err != nil { + return req.ID, "", err + } + + if err := s.userRepo.UpdateBalance(ctx, userID, -cost); err != nil { + return req.ID, "", err + } + + if err := s.requestRepo.UpdateWithTZ(ctx, req.ID, tzText, true); err != nil { + return req.ID, "", err + } + + return req.ID, tzText, nil +} + +func (s *requestService) ApproveTZ(ctx context.Context, requestID uuid.UUID, tzText string, userID int) ([]*model.Supplier, error) { + if err := s.requestRepo.UpdateFinalTZ(ctx, requestID, tzText); err != nil { + return nil, err + } + + var suppliers []*model.Supplier + var promptTokens, responseTokens int + var err error + + for attempt := 0; attempt < 3; attempt++ { + suppliers, promptTokens, responseTokens, err = s.perplexity.FindSuppliers(tzText) + if err == nil { + break + } + } + + if err != nil { + return nil, err + } + + if len(suppliers) == 0 { + return nil, errors.NewInternalError(errors.AIAPIError, "no suppliers found", nil) + } + + if err := s.supplierRepo.BulkInsert(ctx, requestID, suppliers); err != nil { + return nil, err + } + + tokenPrice := 25000.0 / 1000000.0 + totalTokens := promptTokens + responseTokens + cost := float64(totalTokens) * tokenPrice + + tokenUsage := &model.TokenUsage{ + RequestID: requestID, + RequestTokenCount: promptTokens, + ResponseTokenCount: responseTokens, + TokenCost: cost, + Type: "suppliers", + } + + if err := s.tokenUsageRepo.Create(ctx, tokenUsage); err != nil { + return nil, err + } + + if err := s.userRepo.UpdateBalance(ctx, userID, -cost); err != nil { + return nil, err + } + + return suppliers, nil +} + +func (s *requestService) GetMailingList(ctx context.Context, userID int) ([]*model.Request, error) { + return s.requestRepo.GetByUserID(ctx, userID) +} + +func (s *requestService) GetMailingListByID(ctx context.Context, requestID uuid.UUID) (*model.RequestDetail, error) { + return s.requestRepo.GetDetailByID(ctx, requestID) +} diff --git a/internal/service/supplier.go b/internal/service/supplier.go new file mode 100644 index 0000000..e420067 --- /dev/null +++ b/internal/service/supplier.go @@ -0,0 +1,75 @@ +package service + +import ( + "context" + "fmt" + + "github.com/google/uuid" + "github.com/xuri/excelize/v2" + "smart-search-back/internal/repository" +) + +type supplierService struct { + supplierRepo repository.SupplierRepository +} + +func NewSupplierService(supplierRepo repository.SupplierRepository) SupplierService { + return &supplierService{ + supplierRepo: supplierRepo, + } +} + +func (s *supplierService) ExportExcel(ctx context.Context, requestID uuid.UUID) ([]byte, error) { + suppliers, err := s.supplierRepo.GetByRequestID(ctx, requestID) + if err != nil { + return nil, err + } + + f := excelize.NewFile() + defer f.Close() + + sheetName := "Suppliers" + index, err := f.NewSheet(sheetName) + if err != nil { + return nil, err + } + + headers := []string{"Company ID", "Email", "Phone", "Company Name", "URL"} + for i, header := range headers { + cell := fmt.Sprintf("%c1", 'A'+i) + f.SetCellValue(sheetName, cell, header) + } + + style, err := f.NewStyle(&excelize.Style{ + Font: &excelize.Font{Bold: true}, + Fill: excelize.Fill{Type: "pattern", Color: []string{"#E0E0E0"}, Pattern: 1}, + }) + if err == nil { + f.SetCellStyle(sheetName, "A1", fmt.Sprintf("%c1", 'A'+len(headers)-1), style) + } + + for i, supplier := range suppliers { + row := i + 2 + f.SetCellValue(sheetName, fmt.Sprintf("A%d", row), supplier.ID) + f.SetCellValue(sheetName, fmt.Sprintf("B%d", row), supplier.Email) + f.SetCellValue(sheetName, fmt.Sprintf("C%d", row), supplier.Phone) + f.SetCellValue(sheetName, fmt.Sprintf("D%d", row), supplier.Name) + f.SetCellValue(sheetName, fmt.Sprintf("E%d", row), supplier.URL) + } + + f.SetColWidth(sheetName, "A", "A", 12) + f.SetColWidth(sheetName, "B", "B", 30) + f.SetColWidth(sheetName, "C", "C", 20) + f.SetColWidth(sheetName, "D", "D", 40) + f.SetColWidth(sheetName, "E", "E", 40) + + f.SetActiveSheet(index) + f.DeleteSheet("Sheet1") + + buffer, err := f.WriteToBuffer() + if err != nil { + return nil, err + } + + return buffer.Bytes(), nil +} diff --git a/internal/service/tests/auth_suite_test.go b/internal/service/tests/auth_suite_test.go new file mode 100644 index 0000000..b5b8577 --- /dev/null +++ b/internal/service/tests/auth_suite_test.go @@ -0,0 +1,449 @@ +package tests + +import ( + "context" + "errors" + "testing" + "time" + + "github.com/gojuno/minimock/v3" + "github.com/stretchr/testify/suite" + + "smart-search-back/internal/mocks" + "smart-search-back/internal/model" + "smart-search-back/internal/service" + "smart-search-back/pkg/crypto" + apperrors "smart-search-back/pkg/errors" + "smart-search-back/pkg/jwt" +) + +type Suite struct { + suite.Suite + + ctx context.Context + authService service.AuthService + userRepo *mocks.UserRepositoryMock + sessionRepo *mocks.SessionRepositoryMock +} + +func newSuite(ctx context.Context) *Suite { + return &Suite{ctx: ctx} +} + +func TestAuthService(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + suite.Run(t, newSuite(ctx)) +} + +func (s *Suite) SetupSuite() { + s.ctx = context.Background() +} + +func (s *Suite) SetupTest() { + ctrl := minimock.NewController(s.T()) + + s.userRepo = mocks.NewUserRepositoryMock(ctrl) + s.sessionRepo = mocks.NewSessionRepositoryMock(ctrl) + + s.authService = service.NewAuthService(s.userRepo, s.sessionRepo) +} + +func createTestUser(password string) *model.User { + return &model.User{ + ID: 1, + Email: "test@example.com", + EmailHash: crypto.EmailHash("test@example.com"), + PasswordHash: crypto.PasswordHash(password), + CreatedAt: time.Now(), + } +} + +func createTestSession(userID int) *model.Session { + return &model.Session{ + ID: 1, + UserID: userID, + AccessToken: "test-access-token", + RefreshToken: "test-refresh-token", + IP: "127.0.0.1", + UserAgent: "test-agent", + CreatedAt: time.Now(), + ExpiresAt: time.Now().Add(30 * 24 * time.Hour), + } +} + +func (s *Suite) TestAuthService_Login_Success() { + password := "testpassword" + user := createTestUser(password) + + s.userRepo.FindByEmailHashMock.Return(user, nil) + s.sessionRepo.CreateMock.Return(nil) + + accessToken, refreshToken, err := s.authService.Login( + s.ctx, + "test@example.com", + password, + "127.0.0.1", + "test-agent", + ) + + s.NoError(err) + s.NotEmpty(accessToken) + s.NotEmpty(refreshToken) +} + +func (s *Suite) TestAuthService_Login_UserNotFound() { + err := apperrors.NewBusinessError(apperrors.UserNotFound, "user not found") + s.userRepo.FindByEmailHashMock.Return(nil, err) + + accessToken, refreshToken, loginErr := s.authService.Login( + s.ctx, + "test@example.com", + "password", + "127.0.0.1", + "test-agent", + ) + + s.Error(loginErr) + s.Empty(accessToken) + s.Empty(refreshToken) + + var appErr *apperrors.AppError + s.True(errors.As(loginErr, &appErr)) + s.Equal(apperrors.UserNotFound, appErr.Code) +} + +func (s *Suite) TestAuthService_Login_DatabaseError_OnFindUser() { + dbErr := apperrors.NewInternalError(apperrors.DatabaseError, "failed to find user", nil) + s.userRepo.FindByEmailHashMock.Return(nil, dbErr) + + accessToken, refreshToken, err := s.authService.Login( + s.ctx, + "test@example.com", + "password", + "127.0.0.1", + "test-agent", + ) + + s.Error(err) + s.Empty(accessToken) + s.Empty(refreshToken) + + var appErr *apperrors.AppError + s.True(errors.As(err, &appErr)) + s.Equal(apperrors.InternalErrorType, appErr.Type) +} + +func (s *Suite) TestAuthService_Login_InvalidPassword() { + password := "correctpassword" + user := createTestUser(password) + s.userRepo.FindByEmailHashMock.Return(user, nil) + + accessToken, refreshToken, err := s.authService.Login( + s.ctx, + "test@example.com", + "wrongpassword", + "127.0.0.1", + "test-agent", + ) + + s.Error(err) + s.Empty(accessToken) + s.Empty(refreshToken) + + var appErr *apperrors.AppError + s.True(errors.As(err, &appErr)) + s.Equal(apperrors.AuthInvalidCredentials, appErr.Code) + s.Contains(appErr.Message, "Invalid email or password") +} + +func (s *Suite) TestAuthService_Login_EmptyPassword() { + user := createTestUser("") + s.userRepo.FindByEmailHashMock.Return(user, nil) + s.sessionRepo.CreateMock.Return(nil) + + accessToken, refreshToken, err := s.authService.Login( + s.ctx, + "test@example.com", + "", + "127.0.0.1", + "test-agent", + ) + + s.NoError(err) + s.NotEmpty(accessToken) + s.NotEmpty(refreshToken) +} + +func (s *Suite) TestAuthService_Login_EmailWithSpacesAndCase() { + password := "testpassword" + normalizedEmail := "test@example.com" + user := createTestUser(password) + user.EmailHash = crypto.EmailHash(normalizedEmail) + s.userRepo.FindByEmailHashMock.Return(user, nil) + s.sessionRepo.CreateMock.Return(nil) + + accessToken, refreshToken, err := s.authService.Login( + s.ctx, + " TEST@EXAMPLE.COM ", + password, + "127.0.0.1", + "test-agent", + ) + + s.NoError(err) + s.NotEmpty(accessToken) + s.NotEmpty(refreshToken) +} + +func (s *Suite) TestAuthService_Login_EmptyEmail() { + err := apperrors.NewBusinessError(apperrors.UserNotFound, "user not found") + s.userRepo.FindByEmailHashMock.Return(nil, err) + + accessToken, refreshToken, loginErr := s.authService.Login( + s.ctx, + "", + "password", + "127.0.0.1", + "test-agent", + ) + + s.Error(loginErr) + s.Empty(accessToken) + s.Empty(refreshToken) +} + +func (s *Suite) TestAuthService_Login_SessionCreateError() { + password := "testpassword" + user := createTestUser(password) + s.userRepo.FindByEmailHashMock.Return(user, nil) + + dbErr := apperrors.NewInternalError(apperrors.DatabaseError, "failed to create session", nil) + s.sessionRepo.CreateMock.Return(dbErr) + + accessToken, refreshToken, err := s.authService.Login( + s.ctx, + "test@example.com", + password, + "127.0.0.1", + "test-agent", + ) + + s.Error(err) + s.Empty(accessToken) + s.Empty(refreshToken) +} + +func (s *Suite) TestAuthService_Login_EmptyIPAndUserAgent() { + password := "testpassword" + user := createTestUser(password) + s.userRepo.FindByEmailHashMock.Return(user, nil) + s.sessionRepo.CreateMock.Return(nil) + + accessToken, refreshToken, err := s.authService.Login( + s.ctx, + "test@example.com", + password, + "", + "", + ) + + s.NoError(err) + s.NotEmpty(accessToken) + s.NotEmpty(refreshToken) +} + +func (s *Suite) TestAuthService_Refresh_Success() { + session := createTestSession(1) + s.sessionRepo.FindByRefreshTokenMock.Return(session, nil) + s.sessionRepo.UpdateAccessTokenMock.Return(nil) + + accessToken, err := s.authService.Refresh(s.ctx, "test-refresh-token") + + s.NoError(err) + s.NotEmpty(accessToken) +} + +func (s *Suite) TestAuthService_Refresh_RefreshInvalid() { + err := apperrors.NewBusinessError(apperrors.RefreshInvalid, "refresh token is invalid or expired") + s.sessionRepo.FindByRefreshTokenMock.Return(nil, err) + + accessToken, refreshErr := s.authService.Refresh(s.ctx, "invalid-token") + + s.Error(refreshErr) + s.Empty(accessToken) + + var appErr *apperrors.AppError + s.True(errors.As(refreshErr, &appErr)) + s.Equal(apperrors.RefreshInvalid, appErr.Code) +} + +func (s *Suite) TestAuthService_Refresh_DatabaseError_OnFindSession() { + dbErr := apperrors.NewInternalError(apperrors.DatabaseError, "failed to find session", nil) + s.sessionRepo.FindByRefreshTokenMock.Return(nil, dbErr) + + accessToken, err := s.authService.Refresh(s.ctx, "test-refresh-token") + + s.Error(err) + s.Empty(accessToken) + + var appErr *apperrors.AppError + s.True(errors.As(err, &appErr)) + s.Equal(apperrors.InternalErrorType, appErr.Type) +} + +func (s *Suite) TestAuthService_Refresh_EmptyToken() { + err := apperrors.NewBusinessError(apperrors.RefreshInvalid, "refresh token is invalid or expired") + s.sessionRepo.FindByRefreshTokenMock.Return(nil, err) + + accessToken, refreshErr := s.authService.Refresh(s.ctx, "") + + s.Error(refreshErr) + s.Empty(accessToken) +} + +func (s *Suite) TestAuthService_Refresh_UpdateAccessTokenError() { + session := createTestSession(1) + s.sessionRepo.FindByRefreshTokenMock.Return(session, nil) + + dbErr := apperrors.NewInternalError(apperrors.DatabaseError, "failed to update access token", nil) + s.sessionRepo.UpdateAccessTokenMock.Return(dbErr) + + accessToken, err := s.authService.Refresh(s.ctx, "test-refresh-token") + + s.Error(err) + s.Empty(accessToken) +} + +func (s *Suite) TestAuthService_Refresh_UserIDZero() { + session := createTestSession(0) + s.sessionRepo.FindByRefreshTokenMock.Return(session, nil) + s.sessionRepo.UpdateAccessTokenMock.Return(nil) + + accessToken, err := s.authService.Refresh(s.ctx, "test-refresh-token") + + s.NoError(err) + s.NotEmpty(accessToken) +} + +func (s *Suite) TestAuthService_Validate_Success() { + s.T().Parallel() + + userID := 1 + accessToken, err := jwt.GenerateAccessToken(userID) + s.NoError(err) + + validatedUserID, validateErr := s.authService.Validate(s.ctx, accessToken) + + s.NoError(validateErr) + s.Equal(userID, validatedUserID) +} + +func (s *Suite) TestAuthService_Validate_EmptyToken() { + s.T().Parallel() + + userID, err := s.authService.Validate(s.ctx, "") + + s.Error(err) + s.Equal(0, userID) + + var appErr *apperrors.AppError + s.True(errors.As(err, &appErr)) + s.Equal(apperrors.AuthInvalidToken, appErr.Code) +} + +func (s *Suite) TestAuthService_Validate_InvalidTokenFormat() { + s.T().Parallel() + + userID, err := s.authService.Validate(s.ctx, "invalid.token.format") + + s.Error(err) + s.Equal(0, userID) + + var appErr *apperrors.AppError + s.True(errors.As(err, &appErr)) + s.Equal(apperrors.AuthInvalidToken, appErr.Code) +} + +func (s *Suite) TestAuthService_Validate_RefreshTokenInsteadOfAccess() { + s.T().Parallel() + + userID := 1 + refreshToken, err := jwt.GenerateRefreshToken(userID) + s.NoError(err) + + validatedUserID, validateErr := s.authService.Validate(s.ctx, refreshToken) + + s.Error(validateErr) + s.Equal(0, validatedUserID) + + var appErr *apperrors.AppError + s.True(errors.As(validateErr, &appErr)) + s.Equal(apperrors.AuthInvalidToken, appErr.Code) + s.Contains(appErr.Message, "not an access token") +} + +func (s *Suite) TestAuthService_Validate_UserIDZero() { + s.T().Parallel() + + accessToken, err := jwt.GenerateAccessToken(0) + s.NoError(err) + + validatedUserID, validateErr := s.authService.Validate(s.ctx, accessToken) + + s.NoError(validateErr) + s.Equal(0, validatedUserID) +} + +func (s *Suite) TestAuthService_Validate_InvalidSignature() { + s.T().Parallel() + + invalidToken := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxIiwidHlwZSI6ImFjY2VzcyIsImlhdCI6MTYwOTQ1NjgwMCwiZXhwIjoxNjA5NDY1ODAwfQ.invalid-signature" + + userID, err := s.authService.Validate(s.ctx, invalidToken) + + s.Error(err) + s.Equal(0, userID) + + var appErr *apperrors.AppError + s.True(errors.As(err, &appErr)) + s.Equal(apperrors.AuthInvalidToken, appErr.Code) +} + +func (s *Suite) TestAuthService_Logout_Success() { + s.sessionRepo.RevokeMock.Return(nil) + + err := s.authService.Logout(s.ctx, "test-refresh-token") + + s.NoError(err) +} + +func (s *Suite) TestAuthService_Logout_DatabaseError() { + dbErr := apperrors.NewInternalError(apperrors.DatabaseError, "failed to revoke session", nil) + s.sessionRepo.RevokeMock.Return(dbErr) + + err := s.authService.Logout(s.ctx, "test-refresh-token") + + s.Error(err) + + var appErr *apperrors.AppError + s.True(errors.As(err, &appErr)) + s.Equal(apperrors.InternalErrorType, appErr.Type) +} + +func (s *Suite) TestAuthService_Logout_EmptyToken() { + s.sessionRepo.RevokeMock.Return(nil) + + err := s.authService.Logout(s.ctx, "") + + s.NoError(err) +} + +func (s *Suite) TestAuthService_Logout_NonExistentToken() { + s.sessionRepo.RevokeMock.Return(nil) + + err := s.authService.Logout(s.ctx, "non-existent-token") + + s.NoError(err) +} diff --git a/internal/service/user.go b/internal/service/user.go new file mode 100644 index 0000000..939a98c --- /dev/null +++ b/internal/service/user.go @@ -0,0 +1,83 @@ +package service + +import ( + "context" + + "smart-search-back/internal/repository" + "smart-search-back/pkg/crypto" +) + +type userService struct { + userRepo repository.UserRepository + requestRepo repository.RequestRepository + cryptoHelper *crypto.Crypto +} + +type UserInfo struct { + Email string + Name string + Phone string + CompanyName string + PaymentStatus string +} + +type Statistics struct { + RequestsCount int + SuppliersCount int + CreatedTZ int +} + +func NewUserService(userRepo repository.UserRepository, requestRepo repository.RequestRepository, cryptoSecret string) UserService { + return &userService{ + userRepo: userRepo, + requestRepo: requestRepo, + cryptoHelper: crypto.NewCrypto(cryptoSecret), + } +} + +func (s *userService) GetInfo(ctx context.Context, userID int) (*UserInfo, error) { + user, err := s.userRepo.FindByID(ctx, userID) + if err != nil { + return nil, err + } + + email, err := s.cryptoHelper.Decrypt(user.Email) + if err != nil { + return nil, err + } + + phone, err := s.cryptoHelper.Decrypt(user.Phone) + if err != nil { + return nil, err + } + + userName, err := s.cryptoHelper.Decrypt(user.UserName) + if err != nil { + return nil, err + } + + return &UserInfo{ + Email: email, + Name: userName, + Phone: phone, + CompanyName: user.CompanyName, + PaymentStatus: user.PaymentStatus, + }, nil +} + +func (s *userService) GetBalance(ctx context.Context, userID int) (float64, error) { + return s.userRepo.GetBalance(ctx, userID) +} + +func (s *userService) GetStatistics(ctx context.Context, userID int) (*Statistics, error) { + requestsCount, suppliersCount, createdTZ, err := s.requestRepo.GetUserStatistics(ctx, userID) + if err != nil { + return nil, err + } + + return &Statistics{ + RequestsCount: requestsCount, + SuppliersCount: suppliersCount, + CreatedTZ: createdTZ, + }, nil +} diff --git a/internal/worker/invite_cleaner.go b/internal/worker/invite_cleaner.go new file mode 100644 index 0000000..228c365 --- /dev/null +++ b/internal/worker/invite_cleaner.go @@ -0,0 +1,69 @@ +package worker + +import ( + "context" + "log" + "time" + + "smart-search-back/internal/repository" +) + +type InviteCleaner struct { + inviteRepo repository.InviteRepository + ctx context.Context + ticker *time.Ticker + done chan bool +} + +func NewInviteCleaner(ctx context.Context, inviteRepo repository.InviteRepository) *InviteCleaner { + return &InviteCleaner{ + inviteRepo: inviteRepo, + ctx: ctx, + done: make(chan bool), + } +} + +func (w *InviteCleaner) Start() { + w.ticker = time.NewTicker(6 * time.Hour) + + w.deactivateExpiredInvites() + + go func() { + for { + select { + case <-w.ticker.C: + w.deactivateExpiredInvites() + case <-w.done: + return + case <-w.ctx.Done(): + log.Println("Invite cleaner context cancelled, stopping worker") + return + } + } + }() + + log.Println("Invite cleaner worker started (runs every 6 hours)") +} + +func (w *InviteCleaner) Stop() { + if w.ticker != nil { + w.ticker.Stop() + } + select { + case w.done <- true: + default: + } + log.Println("Invite cleaner worker stopped") +} + +func (w *InviteCleaner) deactivateExpiredInvites() { + count, err := w.inviteRepo.DeactivateExpired(w.ctx) + if err != nil { + log.Printf("Error deactivating expired invites: %v", err) + return + } + + if count > 0 { + log.Printf("Deactivated %d expired invite codes", count) + } +} diff --git a/internal/worker/session_cleaner.go b/internal/worker/session_cleaner.go new file mode 100644 index 0000000..9459954 --- /dev/null +++ b/internal/worker/session_cleaner.go @@ -0,0 +1,69 @@ +package worker + +import ( + "context" + "log" + "time" + + "smart-search-back/internal/repository" +) + +type SessionCleaner struct { + sessionRepo repository.SessionRepository + ctx context.Context + ticker *time.Ticker + done chan bool +} + +func NewSessionCleaner(ctx context.Context, sessionRepo repository.SessionRepository) *SessionCleaner { + return &SessionCleaner{ + sessionRepo: sessionRepo, + ctx: ctx, + done: make(chan bool), + } +} + +func (w *SessionCleaner) Start() { + w.ticker = time.NewTicker(1 * time.Hour) + + w.cleanExpiredSessions() + + go func() { + for { + select { + case <-w.ticker.C: + w.cleanExpiredSessions() + case <-w.done: + return + case <-w.ctx.Done(): + log.Println("Session cleaner context cancelled, stopping worker") + return + } + } + }() + + log.Println("Session cleaner worker started (runs every hour)") +} + +func (w *SessionCleaner) Stop() { + if w.ticker != nil { + w.ticker.Stop() + } + select { + case w.done <- true: + default: + } + log.Println("Session cleaner worker stopped") +} + +func (w *SessionCleaner) cleanExpiredSessions() { + count, err := w.sessionRepo.DeleteExpired(w.ctx) + if err != nil { + log.Printf("Error cleaning expired sessions: %v", err) + return + } + + if count > 0 { + log.Printf("Cleaned %d expired sessions", count) + } +} diff --git a/migrations/00001_create_users.sql b/migrations/00001_create_users.sql new file mode 100644 index 0000000..c236e3f --- /dev/null +++ b/migrations/00001_create_users.sql @@ -0,0 +1,20 @@ +-- +goose Up +CREATE TABLE users ( + id SERIAL PRIMARY KEY, + email TEXT NOT NULL, + email_hash TEXT NOT NULL UNIQUE, + password_hash TEXT NOT NULL, + phone TEXT, + user_name TEXT, + company_name TEXT, + balance NUMERIC(10, 5) DEFAULT 0.0, + payment_status TEXT DEFAULT 'unpaid', + invites_issued INT DEFAULT 0, + invites_limit INT DEFAULT 10, + created_at TIMESTAMP DEFAULT now() +); + +CREATE INDEX idx_users_email_hash ON users(email_hash); + +-- +goose Down +DROP TABLE users; diff --git a/migrations/00002_create_sessions.sql b/migrations/00002_create_sessions.sql new file mode 100644 index 0000000..4eb733d --- /dev/null +++ b/migrations/00002_create_sessions.sql @@ -0,0 +1,18 @@ +-- +goose Up +CREATE TABLE sessions ( + id SERIAL PRIMARY KEY, + user_id INT NOT NULL REFERENCES users(id) ON DELETE CASCADE, + access_token TEXT NOT NULL, + refresh_token TEXT NOT NULL UNIQUE, + ip TEXT, + user_agent TEXT, + created_at TIMESTAMP DEFAULT now(), + expires_at TIMESTAMP NOT NULL, + revoked_at TIMESTAMP +); + +CREATE INDEX idx_sessions_refresh ON sessions(refresh_token); +CREATE INDEX idx_sessions_user_id ON sessions(user_id); + +-- +goose Down +DROP TABLE sessions; diff --git a/migrations/00003_create_invite_codes.sql b/migrations/00003_create_invite_codes.sql new file mode 100644 index 0000000..5f5085a --- /dev/null +++ b/migrations/00003_create_invite_codes.sql @@ -0,0 +1,17 @@ +-- +goose Up +CREATE TABLE invite_codes ( + id SERIAL PRIMARY KEY, + user_id INT NOT NULL REFERENCES users(id) ON DELETE CASCADE, + code BIGINT NOT NULL UNIQUE, + can_be_used_count INT DEFAULT 10, + used_count INT DEFAULT 0, + is_active BOOLEAN DEFAULT true, + created_at TIMESTAMP DEFAULT now(), + expires_at TIMESTAMP NOT NULL +); + +CREATE INDEX idx_invite_codes_code ON invite_codes(code); +CREATE INDEX idx_invite_codes_user_id ON invite_codes(user_id); + +-- +goose Down +DROP TABLE invite_codes; diff --git a/migrations/00004_create_mailing_status.sql b/migrations/00004_create_mailing_status.sql new file mode 100644 index 0000000..627205c --- /dev/null +++ b/migrations/00004_create_mailing_status.sql @@ -0,0 +1,14 @@ +-- +goose Up +CREATE TABLE mailing_status ( + id SERIAL PRIMARY KEY, + status_name TEXT NOT NULL UNIQUE +); + +INSERT INTO mailing_status (status_name) VALUES + ('pending'), + ('in_progress'), + ('completed'), + ('failed'); + +-- +goose Down +DROP TABLE mailing_status; diff --git a/migrations/00005_create_requests_for_suppliers.sql b/migrations/00005_create_requests_for_suppliers.sql new file mode 100644 index 0000000..c3f8040 --- /dev/null +++ b/migrations/00005_create_requests_for_suppliers.sql @@ -0,0 +1,18 @@ +-- +goose Up +CREATE TABLE requests_for_suppliers ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + user_id INT NOT NULL REFERENCES users(id) ON DELETE CASCADE, + request_txt TEXT, + generated_tz BOOLEAN DEFAULT false, + final_tz TEXT, + generated_final_tz BOOLEAN DEFAULT false, + final_update_tz TEXT, + mailling_status_id INT REFERENCES mailing_status(id) DEFAULT 1, + created_at TIMESTAMP DEFAULT now() +); + +CREATE INDEX idx_requests_user_id ON requests_for_suppliers(user_id); +CREATE INDEX idx_requests_status ON requests_for_suppliers(mailling_status_id); + +-- +goose Down +DROP TABLE requests_for_suppliers; diff --git a/migrations/00006_create_suppliers.sql b/migrations/00006_create_suppliers.sql new file mode 100644 index 0000000..9ad7d7b --- /dev/null +++ b/migrations/00006_create_suppliers.sql @@ -0,0 +1,16 @@ +-- +goose Up +CREATE TABLE suppliers ( + id SERIAL PRIMARY KEY, + request_id UUID NOT NULL REFERENCES requests_for_suppliers(id) ON DELETE CASCADE, + name TEXT NOT NULL, + email TEXT, + phone TEXT, + adress TEXT, + url TEXT, + created_at TIMESTAMP DEFAULT now() +); + +CREATE INDEX idx_suppliers_request_id ON suppliers(request_id); + +-- +goose Down +DROP TABLE suppliers; diff --git a/migrations/00007_create_request_token_usage.sql b/migrations/00007_create_request_token_usage.sql new file mode 100644 index 0000000..042fe31 --- /dev/null +++ b/migrations/00007_create_request_token_usage.sql @@ -0,0 +1,15 @@ +-- +goose Up +CREATE TABLE request_token_usage ( + id SERIAL PRIMARY KEY, + request_id UUID NOT NULL REFERENCES requests_for_suppliers(id) ON DELETE CASCADE, + request_token_count INT DEFAULT 0, + response_token_count INT DEFAULT 0, + token_cost NUMERIC(10, 5) DEFAULT 0.0, + type TEXT NOT NULL, + created_at TIMESTAMP DEFAULT now() +); + +CREATE INDEX idx_token_usage_request_id ON request_token_usage(request_id); + +-- +goose Down +DROP TABLE request_token_usage; diff --git a/pkg/crypto/crypto.go b/pkg/crypto/crypto.go new file mode 100644 index 0000000..32830ff --- /dev/null +++ b/pkg/crypto/crypto.go @@ -0,0 +1,125 @@ +package crypto + +import ( + "crypto/aes" + "crypto/cipher" + "crypto/hmac" + "crypto/rand" + "crypto/sha256" + "crypto/sha512" + "encoding/hex" + "errors" + "fmt" + "strings" +) + +type Crypto struct { + secret string +} + +func NewCrypto(secret string) *Crypto { + return &Crypto{secret: secret} +} + +func (c *Crypto) EmailHash(email string) string { + if email == "" { + return email + } + normalized := strings.TrimSpace(strings.ToLower(email)) + h := hmac.New(sha256.New, []byte(c.secret)) + h.Write([]byte(normalized)) + return hex.EncodeToString(h.Sum(nil)) +} + +func PasswordHash(password string) string { + h := sha512.New() + h.Write([]byte(password)) + return hex.EncodeToString(h.Sum(nil)) +} + +func (c *Crypto) getKey() []byte { + h := sha256.New() + h.Write([]byte(c.secret)) + return h.Sum(nil) +} + +func (c *Crypto) Encrypt(plaintext string) (string, error) { + if plaintext == "" { + return plaintext, nil + } + + key := c.getKey() + block, err := aes.NewCipher(key) + if err != nil { + return "", fmt.Errorf("failed to create cipher: %w", err) + } + + aesGCM, err := cipher.NewGCM(block) + if err != nil { + return "", fmt.Errorf("failed to create GCM: %w", err) + } + + iv := make([]byte, aesGCM.NonceSize()) + if _, err := rand.Read(iv); err != nil { + return "", fmt.Errorf("failed to generate IV: %w", err) + } + + ciphertext := aesGCM.Seal(nil, iv, []byte(plaintext), nil) + + tag := ciphertext[len(ciphertext)-aesGCM.Overhead():] + cipherOnly := ciphertext[:len(ciphertext)-aesGCM.Overhead()] + + return fmt.Sprintf("%s:%s:%s", + hex.EncodeToString(iv), + hex.EncodeToString(tag), + hex.EncodeToString(cipherOnly), + ), nil +} + +func (c *Crypto) Decrypt(ciphertext string) (string, error) { + if ciphertext == "" { + return ciphertext, nil + } + + parts := strings.Split(ciphertext, ":") + if len(parts) != 3 { + return "", errors.New("invalid encrypted value format") + } + + ivHex, tagHex, cipherHex := parts[0], parts[1], parts[2] + + iv, err := hex.DecodeString(ivHex) + if err != nil { + return "", fmt.Errorf("failed to decode IV: %w", err) + } + + tag, err := hex.DecodeString(tagHex) + if err != nil { + return "", fmt.Errorf("failed to decode tag: %w", err) + } + + cipherOnly, err := hex.DecodeString(cipherHex) + if err != nil { + return "", fmt.Errorf("failed to decode ciphertext: %w", err) + } + + key := c.getKey() + block, err := aes.NewCipher(key) + if err != nil { + return "", fmt.Errorf("failed to create cipher: %w", err) + } + + aesGCM, err := cipher.NewGCM(block) + if err != nil { + return "", fmt.Errorf("failed to create GCM: %w", err) + } + + ciphertextWithTag := append(cipherOnly, tag...) + + plaintext, err := aesGCM.Open(nil, iv, ciphertextWithTag, nil) + if err != nil { + return "", fmt.Errorf("failed to decrypt: %w", err) + } + + return string(plaintext), nil +} diff --git a/pkg/errors/codes.go b/pkg/errors/codes.go new file mode 100644 index 0000000..aeab8a1 --- /dev/null +++ b/pkg/errors/codes.go @@ -0,0 +1,17 @@ +package errors + +const ( + AuthInvalidCredentials = "AUTH_INVALID_CREDENTIALS" + AuthMissing = "AUTH_MISSING" + AuthInvalidToken = "AUTH_INVALID_TOKEN" + RefreshInvalid = "REFRESH_INVALID" + InviteLimitReached = "INVITE_LIMIT_REACHED" + InsufficientBalance = "INSUFFICIENT_BALANCE" + UserNotFound = "USER_NOT_FOUND" + RequestNotFound = "REQUEST_NOT_FOUND" + + DatabaseError = "DATABASE_ERROR" + EncryptionError = "ENCRYPTION_ERROR" + AIAPIError = "AI_API_ERROR" + InternalError = "INTERNAL_ERROR" +) diff --git a/pkg/errors/errors.go b/pkg/errors/errors.go new file mode 100644 index 0000000..06896c1 --- /dev/null +++ b/pkg/errors/errors.go @@ -0,0 +1,95 @@ +package errors + +import ( + "errors" + "fmt" + + "go.uber.org/zap" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +type ErrorType int + +const ( + BusinessError ErrorType = iota + InternalErrorType +) + +type AppError struct { + Code string + Message string + Type ErrorType + Err error +} + +func (e *AppError) Error() string { + if e.Err != nil { + return fmt.Sprintf("%s: %s (%v)", e.Code, e.Message, e.Err) + } + return fmt.Sprintf("%s: %s", e.Code, e.Message) +} + +func (e *AppError) Unwrap() error { + return e.Err +} + +func NewBusinessError(code, message string) *AppError { + return &AppError{ + Code: code, + Message: message, + Type: BusinessError, + } +} + +func NewInternalError(code, message string, err error) *AppError { + return &AppError{ + Code: code, + Message: message, + Type: InternalErrorType, + Err: err, + } +} + +func ToGRPCError(err error, zapLogger *zap.Logger, method string) error { + if err == nil { + return nil + } + + var appErr *AppError + ok := errors.As(err, &appErr) + if !ok { + if zapLogger != nil { + zapLogger.Error("gRPC handler error: unknown error type", + zap.String("method", method), + zap.Error(err), + ) + } + return status.Error(codes.Internal, "internal server error") + } + + if appErr.Type == InternalErrorType { + if zapLogger != nil { + zapLogger.Error("gRPC handler error: internal error", + zap.String("method", method), + zap.String("code", appErr.Code), + zap.String("message", appErr.Message), + zap.Error(appErr.Err), + ) + } + return status.Error(codes.Internal, "internal server error") + } + + switch appErr.Code { + case AuthInvalidCredentials, AuthMissing, AuthInvalidToken, RefreshInvalid: + return status.Error(codes.Unauthenticated, appErr.Message) + case InviteLimitReached: + return status.Error(codes.ResourceExhausted, appErr.Message) + case InsufficientBalance: + return status.Error(codes.FailedPrecondition, appErr.Message) + case UserNotFound, RequestNotFound: + return status.Error(codes.NotFound, appErr.Message) + default: + return status.Error(codes.Unknown, appErr.Message) + } +} diff --git a/pkg/jwt/jwt.go b/pkg/jwt/jwt.go new file mode 100644 index 0000000..8887462 --- /dev/null +++ b/pkg/jwt/jwt.go @@ -0,0 +1,79 @@ +package jwt + +import ( + "errors" + "fmt" + "strconv" + "time" + + "github.com/golang-jwt/jwt/v5" +) + +type Claims struct { + Sub string `json:"sub"` + Type string `json:"type"` + jwt.RegisteredClaims +} + +func GenerateAccessToken(userID int, secret string) (string, error) { + now := time.Now() + claims := Claims{ + Sub: strconv.Itoa(userID), + Type: "access", + RegisteredClaims: jwt.RegisteredClaims{ + IssuedAt: jwt.NewNumericDate(now), + ExpiresAt: jwt.NewNumericDate(now.Add(15 * time.Minute)), + }, + } + + token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims) + return token.SignedString([]byte(secret)) +} + +func GenerateRefreshToken(userID int, secret string) (string, error) { + now := time.Now() + claims := Claims{ + Sub: strconv.Itoa(userID), + Type: "refresh", + RegisteredClaims: jwt.RegisteredClaims{ + IssuedAt: jwt.NewNumericDate(now), + ExpiresAt: jwt.NewNumericDate(now.Add(30 * 24 * time.Hour)), + }, + } + + token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims) + return token.SignedString([]byte(secret)) +} + +func ValidateToken(tokenString, secret string) (*Claims, error) { + token, err := jwt.ParseWithClaims(tokenString, &Claims{}, func(token *jwt.Token) (interface{}, error) { + if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok { + return nil, fmt.Errorf("unexpected signing method: %v", token.Header["alg"]) + } + return []byte(secret), nil + }) + + if err != nil { + return nil, fmt.Errorf("failed to parse token: %w", err) + } + + if claims, ok := token.Claims.(*Claims); ok && token.Valid { + return claims, nil + } + + return nil, errors.New("invalid token") +} + +func GetUserIDFromToken(tokenString, secret string) (int, error) { + claims, err := ValidateToken(tokenString, secret) + if err != nil { + return 0, err + } + + userID, err := strconv.Atoi(claims.Sub) + if err != nil { + return 0, fmt.Errorf("invalid user ID in token: %w", err) + } + + return userID, nil +} diff --git a/pkg/pb/api/proto/auth/auth.pb.go b/pkg/pb/api/proto/auth/auth.pb.go new file mode 100644 index 0000000..49d73d8 --- /dev/null +++ b/pkg/pb/api/proto/auth/auth.pb.go @@ -0,0 +1,538 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.6 +// protoc v5.29.3 +// source: api/proto/auth/auth.proto + +package auth + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type LoginRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Email string `protobuf:"bytes,1,opt,name=email,proto3" json:"email,omitempty"` + Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` + Ip string `protobuf:"bytes,3,opt,name=ip,proto3" json:"ip,omitempty"` + UserAgent string `protobuf:"bytes,4,opt,name=user_agent,json=userAgent,proto3" json:"user_agent,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *LoginRequest) Reset() { + *x = LoginRequest{} + mi := &file_api_proto_auth_auth_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *LoginRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LoginRequest) ProtoMessage() {} + +func (x *LoginRequest) ProtoReflect() protoreflect.Message { + mi := &file_api_proto_auth_auth_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LoginRequest.ProtoReflect.Descriptor instead. +func (*LoginRequest) Descriptor() ([]byte, []int) { + return file_api_proto_auth_auth_proto_rawDescGZIP(), []int{0} +} + +func (x *LoginRequest) GetEmail() string { + if x != nil { + return x.Email + } + return "" +} + +func (x *LoginRequest) GetPassword() string { + if x != nil { + return x.Password + } + return "" +} + +func (x *LoginRequest) GetIp() string { + if x != nil { + return x.Ip + } + return "" +} + +func (x *LoginRequest) GetUserAgent() string { + if x != nil { + return x.UserAgent + } + return "" +} + +type LoginResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + AccessToken string `protobuf:"bytes,1,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"` + RefreshToken string `protobuf:"bytes,2,opt,name=refresh_token,json=refreshToken,proto3" json:"refresh_token,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *LoginResponse) Reset() { + *x = LoginResponse{} + mi := &file_api_proto_auth_auth_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *LoginResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LoginResponse) ProtoMessage() {} + +func (x *LoginResponse) ProtoReflect() protoreflect.Message { + mi := &file_api_proto_auth_auth_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LoginResponse.ProtoReflect.Descriptor instead. +func (*LoginResponse) Descriptor() ([]byte, []int) { + return file_api_proto_auth_auth_proto_rawDescGZIP(), []int{1} +} + +func (x *LoginResponse) GetAccessToken() string { + if x != nil { + return x.AccessToken + } + return "" +} + +func (x *LoginResponse) GetRefreshToken() string { + if x != nil { + return x.RefreshToken + } + return "" +} + +type RefreshRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + RefreshToken string `protobuf:"bytes,1,opt,name=refresh_token,json=refreshToken,proto3" json:"refresh_token,omitempty"` + Ip string `protobuf:"bytes,2,opt,name=ip,proto3" json:"ip,omitempty"` + UserAgent string `protobuf:"bytes,3,opt,name=user_agent,json=userAgent,proto3" json:"user_agent,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RefreshRequest) Reset() { + *x = RefreshRequest{} + mi := &file_api_proto_auth_auth_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RefreshRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RefreshRequest) ProtoMessage() {} + +func (x *RefreshRequest) ProtoReflect() protoreflect.Message { + mi := &file_api_proto_auth_auth_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RefreshRequest.ProtoReflect.Descriptor instead. +func (*RefreshRequest) Descriptor() ([]byte, []int) { + return file_api_proto_auth_auth_proto_rawDescGZIP(), []int{2} +} + +func (x *RefreshRequest) GetRefreshToken() string { + if x != nil { + return x.RefreshToken + } + return "" +} + +func (x *RefreshRequest) GetIp() string { + if x != nil { + return x.Ip + } + return "" +} + +func (x *RefreshRequest) GetUserAgent() string { + if x != nil { + return x.UserAgent + } + return "" +} + +type RefreshResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + AccessToken string `protobuf:"bytes,1,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"` + RefreshToken string `protobuf:"bytes,2,opt,name=refresh_token,json=refreshToken,proto3" json:"refresh_token,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RefreshResponse) Reset() { + *x = RefreshResponse{} + mi := &file_api_proto_auth_auth_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RefreshResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RefreshResponse) ProtoMessage() {} + +func (x *RefreshResponse) ProtoReflect() protoreflect.Message { + mi := &file_api_proto_auth_auth_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RefreshResponse.ProtoReflect.Descriptor instead. +func (*RefreshResponse) Descriptor() ([]byte, []int) { + return file_api_proto_auth_auth_proto_rawDescGZIP(), []int{3} +} + +func (x *RefreshResponse) GetAccessToken() string { + if x != nil { + return x.AccessToken + } + return "" +} + +func (x *RefreshResponse) GetRefreshToken() string { + if x != nil { + return x.RefreshToken + } + return "" +} + +type ValidateRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + AccessToken string `protobuf:"bytes,1,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ValidateRequest) Reset() { + *x = ValidateRequest{} + mi := &file_api_proto_auth_auth_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ValidateRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ValidateRequest) ProtoMessage() {} + +func (x *ValidateRequest) ProtoReflect() protoreflect.Message { + mi := &file_api_proto_auth_auth_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ValidateRequest.ProtoReflect.Descriptor instead. +func (*ValidateRequest) Descriptor() ([]byte, []int) { + return file_api_proto_auth_auth_proto_rawDescGZIP(), []int{4} +} + +func (x *ValidateRequest) GetAccessToken() string { + if x != nil { + return x.AccessToken + } + return "" +} + +type ValidateResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Valid bool `protobuf:"varint,1,opt,name=valid,proto3" json:"valid,omitempty"` + UserId int64 `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ValidateResponse) Reset() { + *x = ValidateResponse{} + mi := &file_api_proto_auth_auth_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ValidateResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ValidateResponse) ProtoMessage() {} + +func (x *ValidateResponse) ProtoReflect() protoreflect.Message { + mi := &file_api_proto_auth_auth_proto_msgTypes[5] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ValidateResponse.ProtoReflect.Descriptor instead. +func (*ValidateResponse) Descriptor() ([]byte, []int) { + return file_api_proto_auth_auth_proto_rawDescGZIP(), []int{5} +} + +func (x *ValidateResponse) GetValid() bool { + if x != nil { + return x.Valid + } + return false +} + +func (x *ValidateResponse) GetUserId() int64 { + if x != nil { + return x.UserId + } + return 0 +} + +type LogoutRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + AccessToken string `protobuf:"bytes,1,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *LogoutRequest) Reset() { + *x = LogoutRequest{} + mi := &file_api_proto_auth_auth_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *LogoutRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LogoutRequest) ProtoMessage() {} + +func (x *LogoutRequest) ProtoReflect() protoreflect.Message { + mi := &file_api_proto_auth_auth_proto_msgTypes[6] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LogoutRequest.ProtoReflect.Descriptor instead. +func (*LogoutRequest) Descriptor() ([]byte, []int) { + return file_api_proto_auth_auth_proto_rawDescGZIP(), []int{6} +} + +func (x *LogoutRequest) GetAccessToken() string { + if x != nil { + return x.AccessToken + } + return "" +} + +type LogoutResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *LogoutResponse) Reset() { + *x = LogoutResponse{} + mi := &file_api_proto_auth_auth_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *LogoutResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LogoutResponse) ProtoMessage() {} + +func (x *LogoutResponse) ProtoReflect() protoreflect.Message { + mi := &file_api_proto_auth_auth_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LogoutResponse.ProtoReflect.Descriptor instead. +func (*LogoutResponse) Descriptor() ([]byte, []int) { + return file_api_proto_auth_auth_proto_rawDescGZIP(), []int{7} +} + +func (x *LogoutResponse) GetSuccess() bool { + if x != nil { + return x.Success + } + return false +} + +var File_api_proto_auth_auth_proto protoreflect.FileDescriptor + +const file_api_proto_auth_auth_proto_rawDesc = "" + + "\n" + + "\x19api/proto/auth/auth.proto\x12\x04auth\"o\n" + + "\fLoginRequest\x12\x14\n" + + "\x05email\x18\x01 \x01(\tR\x05email\x12\x1a\n" + + "\bpassword\x18\x02 \x01(\tR\bpassword\x12\x0e\n" + + "\x02ip\x18\x03 \x01(\tR\x02ip\x12\x1d\n" + + "\n" + + "user_agent\x18\x04 \x01(\tR\tuserAgent\"W\n" + + "\rLoginResponse\x12!\n" + + "\faccess_token\x18\x01 \x01(\tR\vaccessToken\x12#\n" + + "\rrefresh_token\x18\x02 \x01(\tR\frefreshToken\"d\n" + + "\x0eRefreshRequest\x12#\n" + + "\rrefresh_token\x18\x01 \x01(\tR\frefreshToken\x12\x0e\n" + + "\x02ip\x18\x02 \x01(\tR\x02ip\x12\x1d\n" + + "\n" + + "user_agent\x18\x03 \x01(\tR\tuserAgent\"Y\n" + + "\x0fRefreshResponse\x12!\n" + + "\faccess_token\x18\x01 \x01(\tR\vaccessToken\x12#\n" + + "\rrefresh_token\x18\x02 \x01(\tR\frefreshToken\"4\n" + + "\x0fValidateRequest\x12!\n" + + "\faccess_token\x18\x01 \x01(\tR\vaccessToken\"A\n" + + "\x10ValidateResponse\x12\x14\n" + + "\x05valid\x18\x01 \x01(\bR\x05valid\x12\x17\n" + + "\auser_id\x18\x02 \x01(\x03R\x06userId\"2\n" + + "\rLogoutRequest\x12!\n" + + "\faccess_token\x18\x01 \x01(\tR\vaccessToken\"*\n" + + "\x0eLogoutResponse\x12\x18\n" + + "\asuccess\x18\x01 \x01(\bR\asuccess2\xe7\x01\n" + + "\vAuthService\x120\n" + + "\x05Login\x12\x12.auth.LoginRequest\x1a\x13.auth.LoginResponse\x126\n" + + "\aRefresh\x12\x14.auth.RefreshRequest\x1a\x15.auth.RefreshResponse\x129\n" + + "\bValidate\x12\x15.auth.ValidateRequest\x1a\x16.auth.ValidateResponse\x123\n" + + "\x06Logout\x12\x13.auth.LogoutRequest\x1a\x14.auth.LogoutResponseB5Z3github.com/smart-search-gateway/api/proto/auth/authb\x06proto3" + +var ( + file_api_proto_auth_auth_proto_rawDescOnce sync.Once + file_api_proto_auth_auth_proto_rawDescData []byte +) + +func file_api_proto_auth_auth_proto_rawDescGZIP() []byte { + file_api_proto_auth_auth_proto_rawDescOnce.Do(func() { + file_api_proto_auth_auth_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_api_proto_auth_auth_proto_rawDesc), len(file_api_proto_auth_auth_proto_rawDesc))) + }) + return file_api_proto_auth_auth_proto_rawDescData +} + +var file_api_proto_auth_auth_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_api_proto_auth_auth_proto_goTypes = []any{ + (*LoginRequest)(nil), // 0: auth.LoginRequest + (*LoginResponse)(nil), // 1: auth.LoginResponse + (*RefreshRequest)(nil), // 2: auth.RefreshRequest + (*RefreshResponse)(nil), // 3: auth.RefreshResponse + (*ValidateRequest)(nil), // 4: auth.ValidateRequest + (*ValidateResponse)(nil), // 5: auth.ValidateResponse + (*LogoutRequest)(nil), // 6: auth.LogoutRequest + (*LogoutResponse)(nil), // 7: auth.LogoutResponse +} +var file_api_proto_auth_auth_proto_depIdxs = []int32{ + 0, // 0: auth.AuthService.Login:input_type -> auth.LoginRequest + 2, // 1: auth.AuthService.Refresh:input_type -> auth.RefreshRequest + 4, // 2: auth.AuthService.Validate:input_type -> auth.ValidateRequest + 6, // 3: auth.AuthService.Logout:input_type -> auth.LogoutRequest + 1, // 4: auth.AuthService.Login:output_type -> auth.LoginResponse + 3, // 5: auth.AuthService.Refresh:output_type -> auth.RefreshResponse + 5, // 6: auth.AuthService.Validate:output_type -> auth.ValidateResponse + 7, // 7: auth.AuthService.Logout:output_type -> auth.LogoutResponse + 4, // [4:8] is the sub-list for method output_type + 0, // [0:4] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_api_proto_auth_auth_proto_init() } +func file_api_proto_auth_auth_proto_init() { + if File_api_proto_auth_auth_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_api_proto_auth_auth_proto_rawDesc), len(file_api_proto_auth_auth_proto_rawDesc)), + NumEnums: 0, + NumMessages: 8, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_api_proto_auth_auth_proto_goTypes, + DependencyIndexes: file_api_proto_auth_auth_proto_depIdxs, + MessageInfos: file_api_proto_auth_auth_proto_msgTypes, + }.Build() + File_api_proto_auth_auth_proto = out.File + file_api_proto_auth_auth_proto_goTypes = nil + file_api_proto_auth_auth_proto_depIdxs = nil +} diff --git a/pkg/pb/api/proto/auth/auth_grpc.pb.go b/pkg/pb/api/proto/auth/auth_grpc.pb.go new file mode 100644 index 0000000..ecb5e03 --- /dev/null +++ b/pkg/pb/api/proto/auth/auth_grpc.pb.go @@ -0,0 +1,235 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc v5.29.3 +// source: api/proto/auth/auth.proto + +package auth + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + AuthService_Login_FullMethodName = "/auth.AuthService/Login" + AuthService_Refresh_FullMethodName = "/auth.AuthService/Refresh" + AuthService_Validate_FullMethodName = "/auth.AuthService/Validate" + AuthService_Logout_FullMethodName = "/auth.AuthService/Logout" +) + +// AuthServiceClient is the client API for AuthService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type AuthServiceClient interface { + Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) + Refresh(ctx context.Context, in *RefreshRequest, opts ...grpc.CallOption) (*RefreshResponse, error) + Validate(ctx context.Context, in *ValidateRequest, opts ...grpc.CallOption) (*ValidateResponse, error) + Logout(ctx context.Context, in *LogoutRequest, opts ...grpc.CallOption) (*LogoutResponse, error) +} + +type authServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewAuthServiceClient(cc grpc.ClientConnInterface) AuthServiceClient { + return &authServiceClient{cc} +} + +func (c *authServiceClient) Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(LoginResponse) + err := c.cc.Invoke(ctx, AuthService_Login_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *authServiceClient) Refresh(ctx context.Context, in *RefreshRequest, opts ...grpc.CallOption) (*RefreshResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(RefreshResponse) + err := c.cc.Invoke(ctx, AuthService_Refresh_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *authServiceClient) Validate(ctx context.Context, in *ValidateRequest, opts ...grpc.CallOption) (*ValidateResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ValidateResponse) + err := c.cc.Invoke(ctx, AuthService_Validate_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *authServiceClient) Logout(ctx context.Context, in *LogoutRequest, opts ...grpc.CallOption) (*LogoutResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(LogoutResponse) + err := c.cc.Invoke(ctx, AuthService_Logout_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// AuthServiceServer is the server API for AuthService service. +// All implementations must embed UnimplementedAuthServiceServer +// for forward compatibility. +type AuthServiceServer interface { + Login(context.Context, *LoginRequest) (*LoginResponse, error) + Refresh(context.Context, *RefreshRequest) (*RefreshResponse, error) + Validate(context.Context, *ValidateRequest) (*ValidateResponse, error) + Logout(context.Context, *LogoutRequest) (*LogoutResponse, error) + mustEmbedUnimplementedAuthServiceServer() +} + +// UnimplementedAuthServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedAuthServiceServer struct{} + +func (UnimplementedAuthServiceServer) Login(context.Context, *LoginRequest) (*LoginResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Login not implemented") +} +func (UnimplementedAuthServiceServer) Refresh(context.Context, *RefreshRequest) (*RefreshResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Refresh not implemented") +} +func (UnimplementedAuthServiceServer) Validate(context.Context, *ValidateRequest) (*ValidateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Validate not implemented") +} +func (UnimplementedAuthServiceServer) Logout(context.Context, *LogoutRequest) (*LogoutResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Logout not implemented") +} +func (UnimplementedAuthServiceServer) mustEmbedUnimplementedAuthServiceServer() {} +func (UnimplementedAuthServiceServer) testEmbeddedByValue() {} + +// UnsafeAuthServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to AuthServiceServer will +// result in compilation errors. +type UnsafeAuthServiceServer interface { + mustEmbedUnimplementedAuthServiceServer() +} + +func RegisterAuthServiceServer(s grpc.ServiceRegistrar, srv AuthServiceServer) { + // If the following call pancis, it indicates UnimplementedAuthServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&AuthService_ServiceDesc, srv) +} + +func _AuthService_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(LoginRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AuthServiceServer).Login(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AuthService_Login_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AuthServiceServer).Login(ctx, req.(*LoginRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _AuthService_Refresh_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RefreshRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AuthServiceServer).Refresh(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AuthService_Refresh_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AuthServiceServer).Refresh(ctx, req.(*RefreshRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _AuthService_Validate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ValidateRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AuthServiceServer).Validate(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AuthService_Validate_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AuthServiceServer).Validate(ctx, req.(*ValidateRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _AuthService_Logout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(LogoutRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AuthServiceServer).Logout(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AuthService_Logout_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AuthServiceServer).Logout(ctx, req.(*LogoutRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// AuthService_ServiceDesc is the grpc.ServiceDesc for AuthService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var AuthService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "auth.AuthService", + HandlerType: (*AuthServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Login", + Handler: _AuthService_Login_Handler, + }, + { + MethodName: "Refresh", + Handler: _AuthService_Refresh_Handler, + }, + { + MethodName: "Validate", + Handler: _AuthService_Validate_Handler, + }, + { + MethodName: "Logout", + Handler: _AuthService_Logout_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "api/proto/auth/auth.proto", +} diff --git a/pkg/pb/api/proto/invite/invite.pb.go b/pkg/pb/api/proto/invite/invite.pb.go new file mode 100644 index 0000000..7aa914e --- /dev/null +++ b/pkg/pb/api/proto/invite/invite.pb.go @@ -0,0 +1,369 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.6 +// protoc v5.29.3 +// source: api/proto/invite/invite.proto + +package invite + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type GenerateRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + UserId int64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + TtlDays int32 `protobuf:"varint,2,opt,name=ttl_days,json=ttlDays,proto3" json:"ttl_days,omitempty"` + MaxUses int32 `protobuf:"varint,3,opt,name=max_uses,json=maxUses,proto3" json:"max_uses,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GenerateRequest) Reset() { + *x = GenerateRequest{} + mi := &file_api_proto_invite_invite_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GenerateRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GenerateRequest) ProtoMessage() {} + +func (x *GenerateRequest) ProtoReflect() protoreflect.Message { + mi := &file_api_proto_invite_invite_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GenerateRequest.ProtoReflect.Descriptor instead. +func (*GenerateRequest) Descriptor() ([]byte, []int) { + return file_api_proto_invite_invite_proto_rawDescGZIP(), []int{0} +} + +func (x *GenerateRequest) GetUserId() int64 { + if x != nil { + return x.UserId + } + return 0 +} + +func (x *GenerateRequest) GetTtlDays() int32 { + if x != nil { + return x.TtlDays + } + return 0 +} + +func (x *GenerateRequest) GetMaxUses() int32 { + if x != nil { + return x.MaxUses + } + return 0 +} + +type GenerateResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Code string `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"` + MaxUses int32 `protobuf:"varint,2,opt,name=max_uses,json=maxUses,proto3" json:"max_uses,omitempty"` + ExpiresAt *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=expires_at,json=expiresAt,proto3" json:"expires_at,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GenerateResponse) Reset() { + *x = GenerateResponse{} + mi := &file_api_proto_invite_invite_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GenerateResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GenerateResponse) ProtoMessage() {} + +func (x *GenerateResponse) ProtoReflect() protoreflect.Message { + mi := &file_api_proto_invite_invite_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GenerateResponse.ProtoReflect.Descriptor instead. +func (*GenerateResponse) Descriptor() ([]byte, []int) { + return file_api_proto_invite_invite_proto_rawDescGZIP(), []int{1} +} + +func (x *GenerateResponse) GetCode() string { + if x != nil { + return x.Code + } + return "" +} + +func (x *GenerateResponse) GetMaxUses() int32 { + if x != nil { + return x.MaxUses + } + return 0 +} + +func (x *GenerateResponse) GetExpiresAt() *timestamppb.Timestamp { + if x != nil { + return x.ExpiresAt + } + return nil +} + +type GetInfoRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Code string `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetInfoRequest) Reset() { + *x = GetInfoRequest{} + mi := &file_api_proto_invite_invite_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetInfoRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetInfoRequest) ProtoMessage() {} + +func (x *GetInfoRequest) ProtoReflect() protoreflect.Message { + mi := &file_api_proto_invite_invite_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetInfoRequest.ProtoReflect.Descriptor instead. +func (*GetInfoRequest) Descriptor() ([]byte, []int) { + return file_api_proto_invite_invite_proto_rawDescGZIP(), []int{2} +} + +func (x *GetInfoRequest) GetCode() string { + if x != nil { + return x.Code + } + return "" +} + +type GetInfoResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Code string `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"` + UserId int64 `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + CanBeUsedCount int32 `protobuf:"varint,3,opt,name=can_be_used_count,json=canBeUsedCount,proto3" json:"can_be_used_count,omitempty"` + UsedCount int32 `protobuf:"varint,4,opt,name=used_count,json=usedCount,proto3" json:"used_count,omitempty"` + ExpiresAt *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=expires_at,json=expiresAt,proto3" json:"expires_at,omitempty"` + IsActive bool `protobuf:"varint,6,opt,name=is_active,json=isActive,proto3" json:"is_active,omitempty"` + CreatedAt *timestamppb.Timestamp `protobuf:"bytes,7,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetInfoResponse) Reset() { + *x = GetInfoResponse{} + mi := &file_api_proto_invite_invite_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetInfoResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetInfoResponse) ProtoMessage() {} + +func (x *GetInfoResponse) ProtoReflect() protoreflect.Message { + mi := &file_api_proto_invite_invite_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetInfoResponse.ProtoReflect.Descriptor instead. +func (*GetInfoResponse) Descriptor() ([]byte, []int) { + return file_api_proto_invite_invite_proto_rawDescGZIP(), []int{3} +} + +func (x *GetInfoResponse) GetCode() string { + if x != nil { + return x.Code + } + return "" +} + +func (x *GetInfoResponse) GetUserId() int64 { + if x != nil { + return x.UserId + } + return 0 +} + +func (x *GetInfoResponse) GetCanBeUsedCount() int32 { + if x != nil { + return x.CanBeUsedCount + } + return 0 +} + +func (x *GetInfoResponse) GetUsedCount() int32 { + if x != nil { + return x.UsedCount + } + return 0 +} + +func (x *GetInfoResponse) GetExpiresAt() *timestamppb.Timestamp { + if x != nil { + return x.ExpiresAt + } + return nil +} + +func (x *GetInfoResponse) GetIsActive() bool { + if x != nil { + return x.IsActive + } + return false +} + +func (x *GetInfoResponse) GetCreatedAt() *timestamppb.Timestamp { + if x != nil { + return x.CreatedAt + } + return nil +} + +var File_api_proto_invite_invite_proto protoreflect.FileDescriptor + +const file_api_proto_invite_invite_proto_rawDesc = "" + + "\n" + + "\x1dapi/proto/invite/invite.proto\x12\x06invite\x1a\x1fgoogle/protobuf/timestamp.proto\"`\n" + + "\x0fGenerateRequest\x12\x17\n" + + "\auser_id\x18\x01 \x01(\x03R\x06userId\x12\x19\n" + + "\bttl_days\x18\x02 \x01(\x05R\attlDays\x12\x19\n" + + "\bmax_uses\x18\x03 \x01(\x05R\amaxUses\"|\n" + + "\x10GenerateResponse\x12\x12\n" + + "\x04code\x18\x01 \x01(\tR\x04code\x12\x19\n" + + "\bmax_uses\x18\x02 \x01(\x05R\amaxUses\x129\n" + + "\n" + + "expires_at\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\texpiresAt\"$\n" + + "\x0eGetInfoRequest\x12\x12\n" + + "\x04code\x18\x01 \x01(\tR\x04code\"\x9b\x02\n" + + "\x0fGetInfoResponse\x12\x12\n" + + "\x04code\x18\x01 \x01(\tR\x04code\x12\x17\n" + + "\auser_id\x18\x02 \x01(\x03R\x06userId\x12)\n" + + "\x11can_be_used_count\x18\x03 \x01(\x05R\x0ecanBeUsedCount\x12\x1d\n" + + "\n" + + "used_count\x18\x04 \x01(\x05R\tusedCount\x129\n" + + "\n" + + "expires_at\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampR\texpiresAt\x12\x1b\n" + + "\tis_active\x18\x06 \x01(\bR\bisActive\x129\n" + + "\n" + + "created_at\x18\a \x01(\v2\x1a.google.protobuf.TimestampR\tcreatedAt2\x8a\x01\n" + + "\rInviteService\x12=\n" + + "\bGenerate\x12\x17.invite.GenerateRequest\x1a\x18.invite.GenerateResponse\x12:\n" + + "\aGetInfo\x12\x16.invite.GetInfoRequest\x1a\x17.invite.GetInfoResponseB9Z7github.com/smart-search-gateway/api/proto/invite/inviteb\x06proto3" + +var ( + file_api_proto_invite_invite_proto_rawDescOnce sync.Once + file_api_proto_invite_invite_proto_rawDescData []byte +) + +func file_api_proto_invite_invite_proto_rawDescGZIP() []byte { + file_api_proto_invite_invite_proto_rawDescOnce.Do(func() { + file_api_proto_invite_invite_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_api_proto_invite_invite_proto_rawDesc), len(file_api_proto_invite_invite_proto_rawDesc))) + }) + return file_api_proto_invite_invite_proto_rawDescData +} + +var file_api_proto_invite_invite_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_api_proto_invite_invite_proto_goTypes = []any{ + (*GenerateRequest)(nil), // 0: invite.GenerateRequest + (*GenerateResponse)(nil), // 1: invite.GenerateResponse + (*GetInfoRequest)(nil), // 2: invite.GetInfoRequest + (*GetInfoResponse)(nil), // 3: invite.GetInfoResponse + (*timestamppb.Timestamp)(nil), // 4: google.protobuf.Timestamp +} +var file_api_proto_invite_invite_proto_depIdxs = []int32{ + 4, // 0: invite.GenerateResponse.expires_at:type_name -> google.protobuf.Timestamp + 4, // 1: invite.GetInfoResponse.expires_at:type_name -> google.protobuf.Timestamp + 4, // 2: invite.GetInfoResponse.created_at:type_name -> google.protobuf.Timestamp + 0, // 3: invite.InviteService.Generate:input_type -> invite.GenerateRequest + 2, // 4: invite.InviteService.GetInfo:input_type -> invite.GetInfoRequest + 1, // 5: invite.InviteService.Generate:output_type -> invite.GenerateResponse + 3, // 6: invite.InviteService.GetInfo:output_type -> invite.GetInfoResponse + 5, // [5:7] is the sub-list for method output_type + 3, // [3:5] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name +} + +func init() { file_api_proto_invite_invite_proto_init() } +func file_api_proto_invite_invite_proto_init() { + if File_api_proto_invite_invite_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_api_proto_invite_invite_proto_rawDesc), len(file_api_proto_invite_invite_proto_rawDesc)), + NumEnums: 0, + NumMessages: 4, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_api_proto_invite_invite_proto_goTypes, + DependencyIndexes: file_api_proto_invite_invite_proto_depIdxs, + MessageInfos: file_api_proto_invite_invite_proto_msgTypes, + }.Build() + File_api_proto_invite_invite_proto = out.File + file_api_proto_invite_invite_proto_goTypes = nil + file_api_proto_invite_invite_proto_depIdxs = nil +} diff --git a/pkg/pb/api/proto/invite/invite_grpc.pb.go b/pkg/pb/api/proto/invite/invite_grpc.pb.go new file mode 100644 index 0000000..3367574 --- /dev/null +++ b/pkg/pb/api/proto/invite/invite_grpc.pb.go @@ -0,0 +1,159 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc v5.29.3 +// source: api/proto/invite/invite.proto + +package invite + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + InviteService_Generate_FullMethodName = "/invite.InviteService/Generate" + InviteService_GetInfo_FullMethodName = "/invite.InviteService/GetInfo" +) + +// InviteServiceClient is the client API for InviteService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type InviteServiceClient interface { + Generate(ctx context.Context, in *GenerateRequest, opts ...grpc.CallOption) (*GenerateResponse, error) + GetInfo(ctx context.Context, in *GetInfoRequest, opts ...grpc.CallOption) (*GetInfoResponse, error) +} + +type inviteServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewInviteServiceClient(cc grpc.ClientConnInterface) InviteServiceClient { + return &inviteServiceClient{cc} +} + +func (c *inviteServiceClient) Generate(ctx context.Context, in *GenerateRequest, opts ...grpc.CallOption) (*GenerateResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GenerateResponse) + err := c.cc.Invoke(ctx, InviteService_Generate_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *inviteServiceClient) GetInfo(ctx context.Context, in *GetInfoRequest, opts ...grpc.CallOption) (*GetInfoResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetInfoResponse) + err := c.cc.Invoke(ctx, InviteService_GetInfo_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// InviteServiceServer is the server API for InviteService service. +// All implementations must embed UnimplementedInviteServiceServer +// for forward compatibility. +type InviteServiceServer interface { + Generate(context.Context, *GenerateRequest) (*GenerateResponse, error) + GetInfo(context.Context, *GetInfoRequest) (*GetInfoResponse, error) + mustEmbedUnimplementedInviteServiceServer() +} + +// UnimplementedInviteServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedInviteServiceServer struct{} + +func (UnimplementedInviteServiceServer) Generate(context.Context, *GenerateRequest) (*GenerateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Generate not implemented") +} +func (UnimplementedInviteServiceServer) GetInfo(context.Context, *GetInfoRequest) (*GetInfoResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetInfo not implemented") +} +func (UnimplementedInviteServiceServer) mustEmbedUnimplementedInviteServiceServer() {} +func (UnimplementedInviteServiceServer) testEmbeddedByValue() {} + +// UnsafeInviteServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to InviteServiceServer will +// result in compilation errors. +type UnsafeInviteServiceServer interface { + mustEmbedUnimplementedInviteServiceServer() +} + +func RegisterInviteServiceServer(s grpc.ServiceRegistrar, srv InviteServiceServer) { + // If the following call pancis, it indicates UnimplementedInviteServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&InviteService_ServiceDesc, srv) +} + +func _InviteService_Generate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GenerateRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(InviteServiceServer).Generate(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: InviteService_Generate_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(InviteServiceServer).Generate(ctx, req.(*GenerateRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _InviteService_GetInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetInfoRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(InviteServiceServer).GetInfo(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: InviteService_GetInfo_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(InviteServiceServer).GetInfo(ctx, req.(*GetInfoRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// InviteService_ServiceDesc is the grpc.ServiceDesc for InviteService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var InviteService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "invite.InviteService", + HandlerType: (*InviteServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Generate", + Handler: _InviteService_Generate_Handler, + }, + { + MethodName: "GetInfo", + Handler: _InviteService_GetInfo_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "api/proto/invite/invite.proto", +} diff --git a/pkg/pb/api/proto/request/request.pb.go b/pkg/pb/api/proto/request/request.pb.go new file mode 100644 index 0000000..fe3e1b8 --- /dev/null +++ b/pkg/pb/api/proto/request/request.pb.go @@ -0,0 +1,640 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.6 +// protoc v5.29.3 +// source: api/proto/request/request.proto + +package request + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type CreateTZRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + UserId int64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + RequestTxt string `protobuf:"bytes,2,opt,name=request_txt,json=requestTxt,proto3" json:"request_txt,omitempty"` + FileData []byte `protobuf:"bytes,3,opt,name=file_data,json=fileData,proto3" json:"file_data,omitempty"` + FileName string `protobuf:"bytes,4,opt,name=file_name,json=fileName,proto3" json:"file_name,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateTZRequest) Reset() { + *x = CreateTZRequest{} + mi := &file_api_proto_request_request_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateTZRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateTZRequest) ProtoMessage() {} + +func (x *CreateTZRequest) ProtoReflect() protoreflect.Message { + mi := &file_api_proto_request_request_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateTZRequest.ProtoReflect.Descriptor instead. +func (*CreateTZRequest) Descriptor() ([]byte, []int) { + return file_api_proto_request_request_proto_rawDescGZIP(), []int{0} +} + +func (x *CreateTZRequest) GetUserId() int64 { + if x != nil { + return x.UserId + } + return 0 +} + +func (x *CreateTZRequest) GetRequestTxt() string { + if x != nil { + return x.RequestTxt + } + return "" +} + +func (x *CreateTZRequest) GetFileData() []byte { + if x != nil { + return x.FileData + } + return nil +} + +func (x *CreateTZRequest) GetFileName() string { + if x != nil { + return x.FileName + } + return "" +} + +type CreateTZResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` + TzText string `protobuf:"bytes,2,opt,name=tz_text,json=tzText,proto3" json:"tz_text,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateTZResponse) Reset() { + *x = CreateTZResponse{} + mi := &file_api_proto_request_request_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateTZResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateTZResponse) ProtoMessage() {} + +func (x *CreateTZResponse) ProtoReflect() protoreflect.Message { + mi := &file_api_proto_request_request_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateTZResponse.ProtoReflect.Descriptor instead. +func (*CreateTZResponse) Descriptor() ([]byte, []int) { + return file_api_proto_request_request_proto_rawDescGZIP(), []int{1} +} + +func (x *CreateTZResponse) GetRequestId() string { + if x != nil { + return x.RequestId + } + return "" +} + +func (x *CreateTZResponse) GetTzText() string { + if x != nil { + return x.TzText + } + return "" +} + +type ApproveTZRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` + FinalTz string `protobuf:"bytes,2,opt,name=final_tz,json=finalTz,proto3" json:"final_tz,omitempty"` + UserId int64 `protobuf:"varint,3,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ApproveTZRequest) Reset() { + *x = ApproveTZRequest{} + mi := &file_api_proto_request_request_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ApproveTZRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ApproveTZRequest) ProtoMessage() {} + +func (x *ApproveTZRequest) ProtoReflect() protoreflect.Message { + mi := &file_api_proto_request_request_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ApproveTZRequest.ProtoReflect.Descriptor instead. +func (*ApproveTZRequest) Descriptor() ([]byte, []int) { + return file_api_proto_request_request_proto_rawDescGZIP(), []int{2} +} + +func (x *ApproveTZRequest) GetRequestId() string { + if x != nil { + return x.RequestId + } + return "" +} + +func (x *ApproveTZRequest) GetFinalTz() string { + if x != nil { + return x.FinalTz + } + return "" +} + +func (x *ApproveTZRequest) GetUserId() int64 { + if x != nil { + return x.UserId + } + return 0 +} + +type ApproveTZResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` + MailingStatus string `protobuf:"bytes,2,opt,name=mailing_status,json=mailingStatus,proto3" json:"mailing_status,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ApproveTZResponse) Reset() { + *x = ApproveTZResponse{} + mi := &file_api_proto_request_request_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ApproveTZResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ApproveTZResponse) ProtoMessage() {} + +func (x *ApproveTZResponse) ProtoReflect() protoreflect.Message { + mi := &file_api_proto_request_request_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ApproveTZResponse.ProtoReflect.Descriptor instead. +func (*ApproveTZResponse) Descriptor() ([]byte, []int) { + return file_api_proto_request_request_proto_rawDescGZIP(), []int{3} +} + +func (x *ApproveTZResponse) GetSuccess() bool { + if x != nil { + return x.Success + } + return false +} + +func (x *ApproveTZResponse) GetMailingStatus() string { + if x != nil { + return x.MailingStatus + } + return "" +} + +type GetMailingListRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + UserId int64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetMailingListRequest) Reset() { + *x = GetMailingListRequest{} + mi := &file_api_proto_request_request_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetMailingListRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetMailingListRequest) ProtoMessage() {} + +func (x *GetMailingListRequest) ProtoReflect() protoreflect.Message { + mi := &file_api_proto_request_request_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetMailingListRequest.ProtoReflect.Descriptor instead. +func (*GetMailingListRequest) Descriptor() ([]byte, []int) { + return file_api_proto_request_request_proto_rawDescGZIP(), []int{4} +} + +func (x *GetMailingListRequest) GetUserId() int64 { + if x != nil { + return x.UserId + } + return 0 +} + +type GetMailingListResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Items []*MailingItem `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetMailingListResponse) Reset() { + *x = GetMailingListResponse{} + mi := &file_api_proto_request_request_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetMailingListResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetMailingListResponse) ProtoMessage() {} + +func (x *GetMailingListResponse) ProtoReflect() protoreflect.Message { + mi := &file_api_proto_request_request_proto_msgTypes[5] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetMailingListResponse.ProtoReflect.Descriptor instead. +func (*GetMailingListResponse) Descriptor() ([]byte, []int) { + return file_api_proto_request_request_proto_rawDescGZIP(), []int{5} +} + +func (x *GetMailingListResponse) GetItems() []*MailingItem { + if x != nil { + return x.Items + } + return nil +} + +type GetMailingListByIDRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` + UserId int64 `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetMailingListByIDRequest) Reset() { + *x = GetMailingListByIDRequest{} + mi := &file_api_proto_request_request_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetMailingListByIDRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetMailingListByIDRequest) ProtoMessage() {} + +func (x *GetMailingListByIDRequest) ProtoReflect() protoreflect.Message { + mi := &file_api_proto_request_request_proto_msgTypes[6] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetMailingListByIDRequest.ProtoReflect.Descriptor instead. +func (*GetMailingListByIDRequest) Descriptor() ([]byte, []int) { + return file_api_proto_request_request_proto_rawDescGZIP(), []int{6} +} + +func (x *GetMailingListByIDRequest) GetRequestId() string { + if x != nil { + return x.RequestId + } + return "" +} + +func (x *GetMailingListByIDRequest) GetUserId() int64 { + if x != nil { + return x.UserId + } + return 0 +} + +type GetMailingListByIDResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Item *MailingItem `protobuf:"bytes,1,opt,name=item,proto3" json:"item,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetMailingListByIDResponse) Reset() { + *x = GetMailingListByIDResponse{} + mi := &file_api_proto_request_request_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetMailingListByIDResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetMailingListByIDResponse) ProtoMessage() {} + +func (x *GetMailingListByIDResponse) ProtoReflect() protoreflect.Message { + mi := &file_api_proto_request_request_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetMailingListByIDResponse.ProtoReflect.Descriptor instead. +func (*GetMailingListByIDResponse) Descriptor() ([]byte, []int) { + return file_api_proto_request_request_proto_rawDescGZIP(), []int{7} +} + +func (x *GetMailingListByIDResponse) GetItem() *MailingItem { + if x != nil { + return x.Item + } + return nil +} + +type MailingItem struct { + state protoimpl.MessageState `protogen:"open.v1"` + RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` + RequestTxt string `protobuf:"bytes,2,opt,name=request_txt,json=requestTxt,proto3" json:"request_txt,omitempty"` + FinalTz string `protobuf:"bytes,3,opt,name=final_tz,json=finalTz,proto3" json:"final_tz,omitempty"` + MailingStatus string `protobuf:"bytes,4,opt,name=mailing_status,json=mailingStatus,proto3" json:"mailing_status,omitempty"` + CreatedAt *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` + SuppliersFound int32 `protobuf:"varint,6,opt,name=suppliers_found,json=suppliersFound,proto3" json:"suppliers_found,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *MailingItem) Reset() { + *x = MailingItem{} + mi := &file_api_proto_request_request_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *MailingItem) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MailingItem) ProtoMessage() {} + +func (x *MailingItem) ProtoReflect() protoreflect.Message { + mi := &file_api_proto_request_request_proto_msgTypes[8] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use MailingItem.ProtoReflect.Descriptor instead. +func (*MailingItem) Descriptor() ([]byte, []int) { + return file_api_proto_request_request_proto_rawDescGZIP(), []int{8} +} + +func (x *MailingItem) GetRequestId() string { + if x != nil { + return x.RequestId + } + return "" +} + +func (x *MailingItem) GetRequestTxt() string { + if x != nil { + return x.RequestTxt + } + return "" +} + +func (x *MailingItem) GetFinalTz() string { + if x != nil { + return x.FinalTz + } + return "" +} + +func (x *MailingItem) GetMailingStatus() string { + if x != nil { + return x.MailingStatus + } + return "" +} + +func (x *MailingItem) GetCreatedAt() *timestamppb.Timestamp { + if x != nil { + return x.CreatedAt + } + return nil +} + +func (x *MailingItem) GetSuppliersFound() int32 { + if x != nil { + return x.SuppliersFound + } + return 0 +} + +var File_api_proto_request_request_proto protoreflect.FileDescriptor + +const file_api_proto_request_request_proto_rawDesc = "" + + "\n" + + "\x1fapi/proto/request/request.proto\x12\arequest\x1a\x1fgoogle/protobuf/timestamp.proto\"\x85\x01\n" + + "\x0fCreateTZRequest\x12\x17\n" + + "\auser_id\x18\x01 \x01(\x03R\x06userId\x12\x1f\n" + + "\vrequest_txt\x18\x02 \x01(\tR\n" + + "requestTxt\x12\x1b\n" + + "\tfile_data\x18\x03 \x01(\fR\bfileData\x12\x1b\n" + + "\tfile_name\x18\x04 \x01(\tR\bfileName\"J\n" + + "\x10CreateTZResponse\x12\x1d\n" + + "\n" + + "request_id\x18\x01 \x01(\tR\trequestId\x12\x17\n" + + "\atz_text\x18\x02 \x01(\tR\x06tzText\"e\n" + + "\x10ApproveTZRequest\x12\x1d\n" + + "\n" + + "request_id\x18\x01 \x01(\tR\trequestId\x12\x19\n" + + "\bfinal_tz\x18\x02 \x01(\tR\afinalTz\x12\x17\n" + + "\auser_id\x18\x03 \x01(\x03R\x06userId\"T\n" + + "\x11ApproveTZResponse\x12\x18\n" + + "\asuccess\x18\x01 \x01(\bR\asuccess\x12%\n" + + "\x0emailing_status\x18\x02 \x01(\tR\rmailingStatus\"0\n" + + "\x15GetMailingListRequest\x12\x17\n" + + "\auser_id\x18\x01 \x01(\x03R\x06userId\"D\n" + + "\x16GetMailingListResponse\x12*\n" + + "\x05items\x18\x01 \x03(\v2\x14.request.MailingItemR\x05items\"S\n" + + "\x19GetMailingListByIDRequest\x12\x1d\n" + + "\n" + + "request_id\x18\x01 \x01(\tR\trequestId\x12\x17\n" + + "\auser_id\x18\x02 \x01(\x03R\x06userId\"F\n" + + "\x1aGetMailingListByIDResponse\x12(\n" + + "\x04item\x18\x01 \x01(\v2\x14.request.MailingItemR\x04item\"\xf3\x01\n" + + "\vMailingItem\x12\x1d\n" + + "\n" + + "request_id\x18\x01 \x01(\tR\trequestId\x12\x1f\n" + + "\vrequest_txt\x18\x02 \x01(\tR\n" + + "requestTxt\x12\x19\n" + + "\bfinal_tz\x18\x03 \x01(\tR\afinalTz\x12%\n" + + "\x0emailing_status\x18\x04 \x01(\tR\rmailingStatus\x129\n" + + "\n" + + "created_at\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampR\tcreatedAt\x12'\n" + + "\x0fsuppliers_found\x18\x06 \x01(\x05R\x0esuppliersFound2\xc7\x02\n" + + "\x0eRequestService\x12?\n" + + "\bCreateTZ\x12\x18.request.CreateTZRequest\x1a\x19.request.CreateTZResponse\x12B\n" + + "\tApproveTZ\x12\x19.request.ApproveTZRequest\x1a\x1a.request.ApproveTZResponse\x12Q\n" + + "\x0eGetMailingList\x12\x1e.request.GetMailingListRequest\x1a\x1f.request.GetMailingListResponse\x12]\n" + + "\x12GetMailingListByID\x12\".request.GetMailingListByIDRequest\x1a#.request.GetMailingListByIDResponseB;Z9github.com/smart-search-gateway/api/proto/request/requestb\x06proto3" + +var ( + file_api_proto_request_request_proto_rawDescOnce sync.Once + file_api_proto_request_request_proto_rawDescData []byte +) + +func file_api_proto_request_request_proto_rawDescGZIP() []byte { + file_api_proto_request_request_proto_rawDescOnce.Do(func() { + file_api_proto_request_request_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_api_proto_request_request_proto_rawDesc), len(file_api_proto_request_request_proto_rawDesc))) + }) + return file_api_proto_request_request_proto_rawDescData +} + +var file_api_proto_request_request_proto_msgTypes = make([]protoimpl.MessageInfo, 9) +var file_api_proto_request_request_proto_goTypes = []any{ + (*CreateTZRequest)(nil), // 0: request.CreateTZRequest + (*CreateTZResponse)(nil), // 1: request.CreateTZResponse + (*ApproveTZRequest)(nil), // 2: request.ApproveTZRequest + (*ApproveTZResponse)(nil), // 3: request.ApproveTZResponse + (*GetMailingListRequest)(nil), // 4: request.GetMailingListRequest + (*GetMailingListResponse)(nil), // 5: request.GetMailingListResponse + (*GetMailingListByIDRequest)(nil), // 6: request.GetMailingListByIDRequest + (*GetMailingListByIDResponse)(nil), // 7: request.GetMailingListByIDResponse + (*MailingItem)(nil), // 8: request.MailingItem + (*timestamppb.Timestamp)(nil), // 9: google.protobuf.Timestamp +} +var file_api_proto_request_request_proto_depIdxs = []int32{ + 8, // 0: request.GetMailingListResponse.items:type_name -> request.MailingItem + 8, // 1: request.GetMailingListByIDResponse.item:type_name -> request.MailingItem + 9, // 2: request.MailingItem.created_at:type_name -> google.protobuf.Timestamp + 0, // 3: request.RequestService.CreateTZ:input_type -> request.CreateTZRequest + 2, // 4: request.RequestService.ApproveTZ:input_type -> request.ApproveTZRequest + 4, // 5: request.RequestService.GetMailingList:input_type -> request.GetMailingListRequest + 6, // 6: request.RequestService.GetMailingListByID:input_type -> request.GetMailingListByIDRequest + 1, // 7: request.RequestService.CreateTZ:output_type -> request.CreateTZResponse + 3, // 8: request.RequestService.ApproveTZ:output_type -> request.ApproveTZResponse + 5, // 9: request.RequestService.GetMailingList:output_type -> request.GetMailingListResponse + 7, // 10: request.RequestService.GetMailingListByID:output_type -> request.GetMailingListByIDResponse + 7, // [7:11] is the sub-list for method output_type + 3, // [3:7] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name +} + +func init() { file_api_proto_request_request_proto_init() } +func file_api_proto_request_request_proto_init() { + if File_api_proto_request_request_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_api_proto_request_request_proto_rawDesc), len(file_api_proto_request_request_proto_rawDesc)), + NumEnums: 0, + NumMessages: 9, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_api_proto_request_request_proto_goTypes, + DependencyIndexes: file_api_proto_request_request_proto_depIdxs, + MessageInfos: file_api_proto_request_request_proto_msgTypes, + }.Build() + File_api_proto_request_request_proto = out.File + file_api_proto_request_request_proto_goTypes = nil + file_api_proto_request_request_proto_depIdxs = nil +} diff --git a/pkg/pb/api/proto/request/request_grpc.pb.go b/pkg/pb/api/proto/request/request_grpc.pb.go new file mode 100644 index 0000000..1904b2e --- /dev/null +++ b/pkg/pb/api/proto/request/request_grpc.pb.go @@ -0,0 +1,235 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc v5.29.3 +// source: api/proto/request/request.proto + +package request + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + RequestService_CreateTZ_FullMethodName = "/request.RequestService/CreateTZ" + RequestService_ApproveTZ_FullMethodName = "/request.RequestService/ApproveTZ" + RequestService_GetMailingList_FullMethodName = "/request.RequestService/GetMailingList" + RequestService_GetMailingListByID_FullMethodName = "/request.RequestService/GetMailingListByID" +) + +// RequestServiceClient is the client API for RequestService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type RequestServiceClient interface { + CreateTZ(ctx context.Context, in *CreateTZRequest, opts ...grpc.CallOption) (*CreateTZResponse, error) + ApproveTZ(ctx context.Context, in *ApproveTZRequest, opts ...grpc.CallOption) (*ApproveTZResponse, error) + GetMailingList(ctx context.Context, in *GetMailingListRequest, opts ...grpc.CallOption) (*GetMailingListResponse, error) + GetMailingListByID(ctx context.Context, in *GetMailingListByIDRequest, opts ...grpc.CallOption) (*GetMailingListByIDResponse, error) +} + +type requestServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewRequestServiceClient(cc grpc.ClientConnInterface) RequestServiceClient { + return &requestServiceClient{cc} +} + +func (c *requestServiceClient) CreateTZ(ctx context.Context, in *CreateTZRequest, opts ...grpc.CallOption) (*CreateTZResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(CreateTZResponse) + err := c.cc.Invoke(ctx, RequestService_CreateTZ_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *requestServiceClient) ApproveTZ(ctx context.Context, in *ApproveTZRequest, opts ...grpc.CallOption) (*ApproveTZResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ApproveTZResponse) + err := c.cc.Invoke(ctx, RequestService_ApproveTZ_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *requestServiceClient) GetMailingList(ctx context.Context, in *GetMailingListRequest, opts ...grpc.CallOption) (*GetMailingListResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetMailingListResponse) + err := c.cc.Invoke(ctx, RequestService_GetMailingList_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *requestServiceClient) GetMailingListByID(ctx context.Context, in *GetMailingListByIDRequest, opts ...grpc.CallOption) (*GetMailingListByIDResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetMailingListByIDResponse) + err := c.cc.Invoke(ctx, RequestService_GetMailingListByID_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// RequestServiceServer is the server API for RequestService service. +// All implementations must embed UnimplementedRequestServiceServer +// for forward compatibility. +type RequestServiceServer interface { + CreateTZ(context.Context, *CreateTZRequest) (*CreateTZResponse, error) + ApproveTZ(context.Context, *ApproveTZRequest) (*ApproveTZResponse, error) + GetMailingList(context.Context, *GetMailingListRequest) (*GetMailingListResponse, error) + GetMailingListByID(context.Context, *GetMailingListByIDRequest) (*GetMailingListByIDResponse, error) + mustEmbedUnimplementedRequestServiceServer() +} + +// UnimplementedRequestServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedRequestServiceServer struct{} + +func (UnimplementedRequestServiceServer) CreateTZ(context.Context, *CreateTZRequest) (*CreateTZResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateTZ not implemented") +} +func (UnimplementedRequestServiceServer) ApproveTZ(context.Context, *ApproveTZRequest) (*ApproveTZResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ApproveTZ not implemented") +} +func (UnimplementedRequestServiceServer) GetMailingList(context.Context, *GetMailingListRequest) (*GetMailingListResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetMailingList not implemented") +} +func (UnimplementedRequestServiceServer) GetMailingListByID(context.Context, *GetMailingListByIDRequest) (*GetMailingListByIDResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetMailingListByID not implemented") +} +func (UnimplementedRequestServiceServer) mustEmbedUnimplementedRequestServiceServer() {} +func (UnimplementedRequestServiceServer) testEmbeddedByValue() {} + +// UnsafeRequestServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to RequestServiceServer will +// result in compilation errors. +type UnsafeRequestServiceServer interface { + mustEmbedUnimplementedRequestServiceServer() +} + +func RegisterRequestServiceServer(s grpc.ServiceRegistrar, srv RequestServiceServer) { + // If the following call pancis, it indicates UnimplementedRequestServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&RequestService_ServiceDesc, srv) +} + +func _RequestService_CreateTZ_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateTZRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(RequestServiceServer).CreateTZ(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: RequestService_CreateTZ_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(RequestServiceServer).CreateTZ(ctx, req.(*CreateTZRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _RequestService_ApproveTZ_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ApproveTZRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(RequestServiceServer).ApproveTZ(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: RequestService_ApproveTZ_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(RequestServiceServer).ApproveTZ(ctx, req.(*ApproveTZRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _RequestService_GetMailingList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetMailingListRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(RequestServiceServer).GetMailingList(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: RequestService_GetMailingList_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(RequestServiceServer).GetMailingList(ctx, req.(*GetMailingListRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _RequestService_GetMailingListByID_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetMailingListByIDRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(RequestServiceServer).GetMailingListByID(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: RequestService_GetMailingListByID_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(RequestServiceServer).GetMailingListByID(ctx, req.(*GetMailingListByIDRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// RequestService_ServiceDesc is the grpc.ServiceDesc for RequestService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var RequestService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "request.RequestService", + HandlerType: (*RequestServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "CreateTZ", + Handler: _RequestService_CreateTZ_Handler, + }, + { + MethodName: "ApproveTZ", + Handler: _RequestService_ApproveTZ_Handler, + }, + { + MethodName: "GetMailingList", + Handler: _RequestService_GetMailingList_Handler, + }, + { + MethodName: "GetMailingListByID", + Handler: _RequestService_GetMailingListByID_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "api/proto/request/request.proto", +} diff --git a/pkg/pb/api/proto/supplier/supplier.pb.go b/pkg/pb/api/proto/supplier/supplier.pb.go new file mode 100644 index 0000000..e4a9eec --- /dev/null +++ b/pkg/pb/api/proto/supplier/supplier.pb.go @@ -0,0 +1,201 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.6 +// protoc v5.29.3 +// source: api/proto/supplier/supplier.proto + +package supplier + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type ExportExcelRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` + UserId int64 `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ExportExcelRequest) Reset() { + *x = ExportExcelRequest{} + mi := &file_api_proto_supplier_supplier_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ExportExcelRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExportExcelRequest) ProtoMessage() {} + +func (x *ExportExcelRequest) ProtoReflect() protoreflect.Message { + mi := &file_api_proto_supplier_supplier_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ExportExcelRequest.ProtoReflect.Descriptor instead. +func (*ExportExcelRequest) Descriptor() ([]byte, []int) { + return file_api_proto_supplier_supplier_proto_rawDescGZIP(), []int{0} +} + +func (x *ExportExcelRequest) GetRequestId() string { + if x != nil { + return x.RequestId + } + return "" +} + +func (x *ExportExcelRequest) GetUserId() int64 { + if x != nil { + return x.UserId + } + return 0 +} + +type ExportExcelResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + FileData []byte `protobuf:"bytes,1,opt,name=file_data,json=fileData,proto3" json:"file_data,omitempty"` + FileName string `protobuf:"bytes,2,opt,name=file_name,json=fileName,proto3" json:"file_name,omitempty"` + MimeType string `protobuf:"bytes,3,opt,name=mime_type,json=mimeType,proto3" json:"mime_type,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ExportExcelResponse) Reset() { + *x = ExportExcelResponse{} + mi := &file_api_proto_supplier_supplier_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ExportExcelResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExportExcelResponse) ProtoMessage() {} + +func (x *ExportExcelResponse) ProtoReflect() protoreflect.Message { + mi := &file_api_proto_supplier_supplier_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ExportExcelResponse.ProtoReflect.Descriptor instead. +func (*ExportExcelResponse) Descriptor() ([]byte, []int) { + return file_api_proto_supplier_supplier_proto_rawDescGZIP(), []int{1} +} + +func (x *ExportExcelResponse) GetFileData() []byte { + if x != nil { + return x.FileData + } + return nil +} + +func (x *ExportExcelResponse) GetFileName() string { + if x != nil { + return x.FileName + } + return "" +} + +func (x *ExportExcelResponse) GetMimeType() string { + if x != nil { + return x.MimeType + } + return "" +} + +var File_api_proto_supplier_supplier_proto protoreflect.FileDescriptor + +const file_api_proto_supplier_supplier_proto_rawDesc = "" + + "\n" + + "!api/proto/supplier/supplier.proto\x12\bsupplier\"L\n" + + "\x12ExportExcelRequest\x12\x1d\n" + + "\n" + + "request_id\x18\x01 \x01(\tR\trequestId\x12\x17\n" + + "\auser_id\x18\x02 \x01(\x03R\x06userId\"l\n" + + "\x13ExportExcelResponse\x12\x1b\n" + + "\tfile_data\x18\x01 \x01(\fR\bfileData\x12\x1b\n" + + "\tfile_name\x18\x02 \x01(\tR\bfileName\x12\x1b\n" + + "\tmime_type\x18\x03 \x01(\tR\bmimeType2]\n" + + "\x0fSupplierService\x12J\n" + + "\vExportExcel\x12\x1c.supplier.ExportExcelRequest\x1a\x1d.supplier.ExportExcelResponseB=Z;github.com/smart-search-gateway/api/proto/supplier/supplierb\x06proto3" + +var ( + file_api_proto_supplier_supplier_proto_rawDescOnce sync.Once + file_api_proto_supplier_supplier_proto_rawDescData []byte +) + +func file_api_proto_supplier_supplier_proto_rawDescGZIP() []byte { + file_api_proto_supplier_supplier_proto_rawDescOnce.Do(func() { + file_api_proto_supplier_supplier_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_api_proto_supplier_supplier_proto_rawDesc), len(file_api_proto_supplier_supplier_proto_rawDesc))) + }) + return file_api_proto_supplier_supplier_proto_rawDescData +} + +var file_api_proto_supplier_supplier_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_api_proto_supplier_supplier_proto_goTypes = []any{ + (*ExportExcelRequest)(nil), // 0: supplier.ExportExcelRequest + (*ExportExcelResponse)(nil), // 1: supplier.ExportExcelResponse +} +var file_api_proto_supplier_supplier_proto_depIdxs = []int32{ + 0, // 0: supplier.SupplierService.ExportExcel:input_type -> supplier.ExportExcelRequest + 1, // 1: supplier.SupplierService.ExportExcel:output_type -> supplier.ExportExcelResponse + 1, // [1:2] is the sub-list for method output_type + 0, // [0:1] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_api_proto_supplier_supplier_proto_init() } +func file_api_proto_supplier_supplier_proto_init() { + if File_api_proto_supplier_supplier_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_api_proto_supplier_supplier_proto_rawDesc), len(file_api_proto_supplier_supplier_proto_rawDesc)), + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_api_proto_supplier_supplier_proto_goTypes, + DependencyIndexes: file_api_proto_supplier_supplier_proto_depIdxs, + MessageInfos: file_api_proto_supplier_supplier_proto_msgTypes, + }.Build() + File_api_proto_supplier_supplier_proto = out.File + file_api_proto_supplier_supplier_proto_goTypes = nil + file_api_proto_supplier_supplier_proto_depIdxs = nil +} diff --git a/pkg/pb/api/proto/supplier/supplier_grpc.pb.go b/pkg/pb/api/proto/supplier/supplier_grpc.pb.go new file mode 100644 index 0000000..0b28696 --- /dev/null +++ b/pkg/pb/api/proto/supplier/supplier_grpc.pb.go @@ -0,0 +1,121 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc v5.29.3 +// source: api/proto/supplier/supplier.proto + +package supplier + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + SupplierService_ExportExcel_FullMethodName = "/supplier.SupplierService/ExportExcel" +) + +// SupplierServiceClient is the client API for SupplierService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type SupplierServiceClient interface { + ExportExcel(ctx context.Context, in *ExportExcelRequest, opts ...grpc.CallOption) (*ExportExcelResponse, error) +} + +type supplierServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewSupplierServiceClient(cc grpc.ClientConnInterface) SupplierServiceClient { + return &supplierServiceClient{cc} +} + +func (c *supplierServiceClient) ExportExcel(ctx context.Context, in *ExportExcelRequest, opts ...grpc.CallOption) (*ExportExcelResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ExportExcelResponse) + err := c.cc.Invoke(ctx, SupplierService_ExportExcel_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// SupplierServiceServer is the server API for SupplierService service. +// All implementations must embed UnimplementedSupplierServiceServer +// for forward compatibility. +type SupplierServiceServer interface { + ExportExcel(context.Context, *ExportExcelRequest) (*ExportExcelResponse, error) + mustEmbedUnimplementedSupplierServiceServer() +} + +// UnimplementedSupplierServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedSupplierServiceServer struct{} + +func (UnimplementedSupplierServiceServer) ExportExcel(context.Context, *ExportExcelRequest) (*ExportExcelResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ExportExcel not implemented") +} +func (UnimplementedSupplierServiceServer) mustEmbedUnimplementedSupplierServiceServer() {} +func (UnimplementedSupplierServiceServer) testEmbeddedByValue() {} + +// UnsafeSupplierServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to SupplierServiceServer will +// result in compilation errors. +type UnsafeSupplierServiceServer interface { + mustEmbedUnimplementedSupplierServiceServer() +} + +func RegisterSupplierServiceServer(s grpc.ServiceRegistrar, srv SupplierServiceServer) { + // If the following call pancis, it indicates UnimplementedSupplierServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&SupplierService_ServiceDesc, srv) +} + +func _SupplierService_ExportExcel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ExportExcelRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SupplierServiceServer).ExportExcel(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: SupplierService_ExportExcel_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SupplierServiceServer).ExportExcel(ctx, req.(*ExportExcelRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// SupplierService_ServiceDesc is the grpc.ServiceDesc for SupplierService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var SupplierService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "supplier.SupplierService", + HandlerType: (*SupplierServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "ExportExcel", + Handler: _SupplierService_ExportExcel_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "api/proto/supplier/supplier.proto", +} diff --git a/pkg/pb/api/proto/user/user.pb.go b/pkg/pb/api/proto/user/user.pb.go new file mode 100644 index 0000000..2ef1a88 --- /dev/null +++ b/pkg/pb/api/proto/user/user.pb.go @@ -0,0 +1,548 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.6 +// protoc v5.29.3 +// source: api/proto/user/user.proto + +package user + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type GetInfoRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + UserId int64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetInfoRequest) Reset() { + *x = GetInfoRequest{} + mi := &file_api_proto_user_user_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetInfoRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetInfoRequest) ProtoMessage() {} + +func (x *GetInfoRequest) ProtoReflect() protoreflect.Message { + mi := &file_api_proto_user_user_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetInfoRequest.ProtoReflect.Descriptor instead. +func (*GetInfoRequest) Descriptor() ([]byte, []int) { + return file_api_proto_user_user_proto_rawDescGZIP(), []int{0} +} + +func (x *GetInfoRequest) GetUserId() int64 { + if x != nil { + return x.UserId + } + return 0 +} + +type GetInfoResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Email string `protobuf:"bytes,1,opt,name=email,proto3" json:"email,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Phone string `protobuf:"bytes,3,opt,name=phone,proto3" json:"phone,omitempty"` + CompanyName string `protobuf:"bytes,4,opt,name=company_name,json=companyName,proto3" json:"company_name,omitempty"` + PaymentStatus string `protobuf:"bytes,5,opt,name=payment_status,json=paymentStatus,proto3" json:"payment_status,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetInfoResponse) Reset() { + *x = GetInfoResponse{} + mi := &file_api_proto_user_user_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetInfoResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetInfoResponse) ProtoMessage() {} + +func (x *GetInfoResponse) ProtoReflect() protoreflect.Message { + mi := &file_api_proto_user_user_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetInfoResponse.ProtoReflect.Descriptor instead. +func (*GetInfoResponse) Descriptor() ([]byte, []int) { + return file_api_proto_user_user_proto_rawDescGZIP(), []int{1} +} + +func (x *GetInfoResponse) GetEmail() string { + if x != nil { + return x.Email + } + return "" +} + +func (x *GetInfoResponse) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *GetInfoResponse) GetPhone() string { + if x != nil { + return x.Phone + } + return "" +} + +func (x *GetInfoResponse) GetCompanyName() string { + if x != nil { + return x.CompanyName + } + return "" +} + +func (x *GetInfoResponse) GetPaymentStatus() string { + if x != nil { + return x.PaymentStatus + } + return "" +} + +type GetBalanceRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + UserId int64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetBalanceRequest) Reset() { + *x = GetBalanceRequest{} + mi := &file_api_proto_user_user_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetBalanceRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetBalanceRequest) ProtoMessage() {} + +func (x *GetBalanceRequest) ProtoReflect() protoreflect.Message { + mi := &file_api_proto_user_user_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetBalanceRequest.ProtoReflect.Descriptor instead. +func (*GetBalanceRequest) Descriptor() ([]byte, []int) { + return file_api_proto_user_user_proto_rawDescGZIP(), []int{2} +} + +func (x *GetBalanceRequest) GetUserId() int64 { + if x != nil { + return x.UserId + } + return 0 +} + +type GetBalanceResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Balance float64 `protobuf:"fixed64,1,opt,name=balance,proto3" json:"balance,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetBalanceResponse) Reset() { + *x = GetBalanceResponse{} + mi := &file_api_proto_user_user_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetBalanceResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetBalanceResponse) ProtoMessage() {} + +func (x *GetBalanceResponse) ProtoReflect() protoreflect.Message { + mi := &file_api_proto_user_user_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetBalanceResponse.ProtoReflect.Descriptor instead. +func (*GetBalanceResponse) Descriptor() ([]byte, []int) { + return file_api_proto_user_user_proto_rawDescGZIP(), []int{3} +} + +func (x *GetBalanceResponse) GetBalance() float64 { + if x != nil { + return x.Balance + } + return 0 +} + +type GetStatisticsRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + UserId int64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetStatisticsRequest) Reset() { + *x = GetStatisticsRequest{} + mi := &file_api_proto_user_user_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetStatisticsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetStatisticsRequest) ProtoMessage() {} + +func (x *GetStatisticsRequest) ProtoReflect() protoreflect.Message { + mi := &file_api_proto_user_user_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetStatisticsRequest.ProtoReflect.Descriptor instead. +func (*GetStatisticsRequest) Descriptor() ([]byte, []int) { + return file_api_proto_user_user_proto_rawDescGZIP(), []int{4} +} + +func (x *GetStatisticsRequest) GetUserId() int64 { + if x != nil { + return x.UserId + } + return 0 +} + +type GetStatisticsResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + TotalRequests int32 `protobuf:"varint,1,opt,name=total_requests,json=totalRequests,proto3" json:"total_requests,omitempty"` + SuccessfulRequests int32 `protobuf:"varint,2,opt,name=successful_requests,json=successfulRequests,proto3" json:"successful_requests,omitempty"` + FailedRequests int32 `protobuf:"varint,3,opt,name=failed_requests,json=failedRequests,proto3" json:"failed_requests,omitempty"` + TotalSpent float64 `protobuf:"fixed64,4,opt,name=total_spent,json=totalSpent,proto3" json:"total_spent,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetStatisticsResponse) Reset() { + *x = GetStatisticsResponse{} + mi := &file_api_proto_user_user_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetStatisticsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetStatisticsResponse) ProtoMessage() {} + +func (x *GetStatisticsResponse) ProtoReflect() protoreflect.Message { + mi := &file_api_proto_user_user_proto_msgTypes[5] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetStatisticsResponse.ProtoReflect.Descriptor instead. +func (*GetStatisticsResponse) Descriptor() ([]byte, []int) { + return file_api_proto_user_user_proto_rawDescGZIP(), []int{5} +} + +func (x *GetStatisticsResponse) GetTotalRequests() int32 { + if x != nil { + return x.TotalRequests + } + return 0 +} + +func (x *GetStatisticsResponse) GetSuccessfulRequests() int32 { + if x != nil { + return x.SuccessfulRequests + } + return 0 +} + +func (x *GetStatisticsResponse) GetFailedRequests() int32 { + if x != nil { + return x.FailedRequests + } + return 0 +} + +func (x *GetStatisticsResponse) GetTotalSpent() float64 { + if x != nil { + return x.TotalSpent + } + return 0 +} + +type GetBalanceStatisticsRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + UserId int64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetBalanceStatisticsRequest) Reset() { + *x = GetBalanceStatisticsRequest{} + mi := &file_api_proto_user_user_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetBalanceStatisticsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetBalanceStatisticsRequest) ProtoMessage() {} + +func (x *GetBalanceStatisticsRequest) ProtoReflect() protoreflect.Message { + mi := &file_api_proto_user_user_proto_msgTypes[6] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetBalanceStatisticsRequest.ProtoReflect.Descriptor instead. +func (*GetBalanceStatisticsRequest) Descriptor() ([]byte, []int) { + return file_api_proto_user_user_proto_rawDescGZIP(), []int{6} +} + +func (x *GetBalanceStatisticsRequest) GetUserId() int64 { + if x != nil { + return x.UserId + } + return 0 +} + +type GetBalanceStatisticsResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Balance float64 `protobuf:"fixed64,1,opt,name=balance,proto3" json:"balance,omitempty"` + TotalRequests int32 `protobuf:"varint,2,opt,name=total_requests,json=totalRequests,proto3" json:"total_requests,omitempty"` + TotalSpent float64 `protobuf:"fixed64,3,opt,name=total_spent,json=totalSpent,proto3" json:"total_spent,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetBalanceStatisticsResponse) Reset() { + *x = GetBalanceStatisticsResponse{} + mi := &file_api_proto_user_user_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetBalanceStatisticsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetBalanceStatisticsResponse) ProtoMessage() {} + +func (x *GetBalanceStatisticsResponse) ProtoReflect() protoreflect.Message { + mi := &file_api_proto_user_user_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetBalanceStatisticsResponse.ProtoReflect.Descriptor instead. +func (*GetBalanceStatisticsResponse) Descriptor() ([]byte, []int) { + return file_api_proto_user_user_proto_rawDescGZIP(), []int{7} +} + +func (x *GetBalanceStatisticsResponse) GetBalance() float64 { + if x != nil { + return x.Balance + } + return 0 +} + +func (x *GetBalanceStatisticsResponse) GetTotalRequests() int32 { + if x != nil { + return x.TotalRequests + } + return 0 +} + +func (x *GetBalanceStatisticsResponse) GetTotalSpent() float64 { + if x != nil { + return x.TotalSpent + } + return 0 +} + +var File_api_proto_user_user_proto protoreflect.FileDescriptor + +const file_api_proto_user_user_proto_rawDesc = "" + + "\n" + + "\x19api/proto/user/user.proto\x12\x04user\")\n" + + "\x0eGetInfoRequest\x12\x17\n" + + "\auser_id\x18\x01 \x01(\x03R\x06userId\"\x9b\x01\n" + + "\x0fGetInfoResponse\x12\x14\n" + + "\x05email\x18\x01 \x01(\tR\x05email\x12\x12\n" + + "\x04name\x18\x02 \x01(\tR\x04name\x12\x14\n" + + "\x05phone\x18\x03 \x01(\tR\x05phone\x12!\n" + + "\fcompany_name\x18\x04 \x01(\tR\vcompanyName\x12%\n" + + "\x0epayment_status\x18\x05 \x01(\tR\rpaymentStatus\",\n" + + "\x11GetBalanceRequest\x12\x17\n" + + "\auser_id\x18\x01 \x01(\x03R\x06userId\".\n" + + "\x12GetBalanceResponse\x12\x18\n" + + "\abalance\x18\x01 \x01(\x01R\abalance\"/\n" + + "\x14GetStatisticsRequest\x12\x17\n" + + "\auser_id\x18\x01 \x01(\x03R\x06userId\"\xb9\x01\n" + + "\x15GetStatisticsResponse\x12%\n" + + "\x0etotal_requests\x18\x01 \x01(\x05R\rtotalRequests\x12/\n" + + "\x13successful_requests\x18\x02 \x01(\x05R\x12successfulRequests\x12'\n" + + "\x0ffailed_requests\x18\x03 \x01(\x05R\x0efailedRequests\x12\x1f\n" + + "\vtotal_spent\x18\x04 \x01(\x01R\n" + + "totalSpent\"6\n" + + "\x1bGetBalanceStatisticsRequest\x12\x17\n" + + "\auser_id\x18\x01 \x01(\x03R\x06userId\"\x80\x01\n" + + "\x1cGetBalanceStatisticsResponse\x12\x18\n" + + "\abalance\x18\x01 \x01(\x01R\abalance\x12%\n" + + "\x0etotal_requests\x18\x02 \x01(\x05R\rtotalRequests\x12\x1f\n" + + "\vtotal_spent\x18\x03 \x01(\x01R\n" + + "totalSpent2\xaf\x02\n" + + "\vUserService\x126\n" + + "\aGetInfo\x12\x14.user.GetInfoRequest\x1a\x15.user.GetInfoResponse\x12?\n" + + "\n" + + "GetBalance\x12\x17.user.GetBalanceRequest\x1a\x18.user.GetBalanceResponse\x12H\n" + + "\rGetStatistics\x12\x1a.user.GetStatisticsRequest\x1a\x1b.user.GetStatisticsResponse\x12]\n" + + "\x14GetBalanceStatistics\x12!.user.GetBalanceStatisticsRequest\x1a\".user.GetBalanceStatisticsResponseB5Z3github.com/smart-search-gateway/api/proto/user/userb\x06proto3" + +var ( + file_api_proto_user_user_proto_rawDescOnce sync.Once + file_api_proto_user_user_proto_rawDescData []byte +) + +func file_api_proto_user_user_proto_rawDescGZIP() []byte { + file_api_proto_user_user_proto_rawDescOnce.Do(func() { + file_api_proto_user_user_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_api_proto_user_user_proto_rawDesc), len(file_api_proto_user_user_proto_rawDesc))) + }) + return file_api_proto_user_user_proto_rawDescData +} + +var file_api_proto_user_user_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_api_proto_user_user_proto_goTypes = []any{ + (*GetInfoRequest)(nil), // 0: user.GetInfoRequest + (*GetInfoResponse)(nil), // 1: user.GetInfoResponse + (*GetBalanceRequest)(nil), // 2: user.GetBalanceRequest + (*GetBalanceResponse)(nil), // 3: user.GetBalanceResponse + (*GetStatisticsRequest)(nil), // 4: user.GetStatisticsRequest + (*GetStatisticsResponse)(nil), // 5: user.GetStatisticsResponse + (*GetBalanceStatisticsRequest)(nil), // 6: user.GetBalanceStatisticsRequest + (*GetBalanceStatisticsResponse)(nil), // 7: user.GetBalanceStatisticsResponse +} +var file_api_proto_user_user_proto_depIdxs = []int32{ + 0, // 0: user.UserService.GetInfo:input_type -> user.GetInfoRequest + 2, // 1: user.UserService.GetBalance:input_type -> user.GetBalanceRequest + 4, // 2: user.UserService.GetStatistics:input_type -> user.GetStatisticsRequest + 6, // 3: user.UserService.GetBalanceStatistics:input_type -> user.GetBalanceStatisticsRequest + 1, // 4: user.UserService.GetInfo:output_type -> user.GetInfoResponse + 3, // 5: user.UserService.GetBalance:output_type -> user.GetBalanceResponse + 5, // 6: user.UserService.GetStatistics:output_type -> user.GetStatisticsResponse + 7, // 7: user.UserService.GetBalanceStatistics:output_type -> user.GetBalanceStatisticsResponse + 4, // [4:8] is the sub-list for method output_type + 0, // [0:4] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_api_proto_user_user_proto_init() } +func file_api_proto_user_user_proto_init() { + if File_api_proto_user_user_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_api_proto_user_user_proto_rawDesc), len(file_api_proto_user_user_proto_rawDesc)), + NumEnums: 0, + NumMessages: 8, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_api_proto_user_user_proto_goTypes, + DependencyIndexes: file_api_proto_user_user_proto_depIdxs, + MessageInfos: file_api_proto_user_user_proto_msgTypes, + }.Build() + File_api_proto_user_user_proto = out.File + file_api_proto_user_user_proto_goTypes = nil + file_api_proto_user_user_proto_depIdxs = nil +} diff --git a/pkg/pb/api/proto/user/user_grpc.pb.go b/pkg/pb/api/proto/user/user_grpc.pb.go new file mode 100644 index 0000000..a74cf31 --- /dev/null +++ b/pkg/pb/api/proto/user/user_grpc.pb.go @@ -0,0 +1,235 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc v5.29.3 +// source: api/proto/user/user.proto + +package user + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + UserService_GetInfo_FullMethodName = "/user.UserService/GetInfo" + UserService_GetBalance_FullMethodName = "/user.UserService/GetBalance" + UserService_GetStatistics_FullMethodName = "/user.UserService/GetStatistics" + UserService_GetBalanceStatistics_FullMethodName = "/user.UserService/GetBalanceStatistics" +) + +// UserServiceClient is the client API for UserService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type UserServiceClient interface { + GetInfo(ctx context.Context, in *GetInfoRequest, opts ...grpc.CallOption) (*GetInfoResponse, error) + GetBalance(ctx context.Context, in *GetBalanceRequest, opts ...grpc.CallOption) (*GetBalanceResponse, error) + GetStatistics(ctx context.Context, in *GetStatisticsRequest, opts ...grpc.CallOption) (*GetStatisticsResponse, error) + GetBalanceStatistics(ctx context.Context, in *GetBalanceStatisticsRequest, opts ...grpc.CallOption) (*GetBalanceStatisticsResponse, error) +} + +type userServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewUserServiceClient(cc grpc.ClientConnInterface) UserServiceClient { + return &userServiceClient{cc} +} + +func (c *userServiceClient) GetInfo(ctx context.Context, in *GetInfoRequest, opts ...grpc.CallOption) (*GetInfoResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetInfoResponse) + err := c.cc.Invoke(ctx, UserService_GetInfo_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *userServiceClient) GetBalance(ctx context.Context, in *GetBalanceRequest, opts ...grpc.CallOption) (*GetBalanceResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetBalanceResponse) + err := c.cc.Invoke(ctx, UserService_GetBalance_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *userServiceClient) GetStatistics(ctx context.Context, in *GetStatisticsRequest, opts ...grpc.CallOption) (*GetStatisticsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetStatisticsResponse) + err := c.cc.Invoke(ctx, UserService_GetStatistics_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *userServiceClient) GetBalanceStatistics(ctx context.Context, in *GetBalanceStatisticsRequest, opts ...grpc.CallOption) (*GetBalanceStatisticsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetBalanceStatisticsResponse) + err := c.cc.Invoke(ctx, UserService_GetBalanceStatistics_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// UserServiceServer is the server API for UserService service. +// All implementations must embed UnimplementedUserServiceServer +// for forward compatibility. +type UserServiceServer interface { + GetInfo(context.Context, *GetInfoRequest) (*GetInfoResponse, error) + GetBalance(context.Context, *GetBalanceRequest) (*GetBalanceResponse, error) + GetStatistics(context.Context, *GetStatisticsRequest) (*GetStatisticsResponse, error) + GetBalanceStatistics(context.Context, *GetBalanceStatisticsRequest) (*GetBalanceStatisticsResponse, error) + mustEmbedUnimplementedUserServiceServer() +} + +// UnimplementedUserServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedUserServiceServer struct{} + +func (UnimplementedUserServiceServer) GetInfo(context.Context, *GetInfoRequest) (*GetInfoResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetInfo not implemented") +} +func (UnimplementedUserServiceServer) GetBalance(context.Context, *GetBalanceRequest) (*GetBalanceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetBalance not implemented") +} +func (UnimplementedUserServiceServer) GetStatistics(context.Context, *GetStatisticsRequest) (*GetStatisticsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetStatistics not implemented") +} +func (UnimplementedUserServiceServer) GetBalanceStatistics(context.Context, *GetBalanceStatisticsRequest) (*GetBalanceStatisticsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetBalanceStatistics not implemented") +} +func (UnimplementedUserServiceServer) mustEmbedUnimplementedUserServiceServer() {} +func (UnimplementedUserServiceServer) testEmbeddedByValue() {} + +// UnsafeUserServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to UserServiceServer will +// result in compilation errors. +type UnsafeUserServiceServer interface { + mustEmbedUnimplementedUserServiceServer() +} + +func RegisterUserServiceServer(s grpc.ServiceRegistrar, srv UserServiceServer) { + // If the following call pancis, it indicates UnimplementedUserServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&UserService_ServiceDesc, srv) +} + +func _UserService_GetInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetInfoRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UserServiceServer).GetInfo(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: UserService_GetInfo_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UserServiceServer).GetInfo(ctx, req.(*GetInfoRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _UserService_GetBalance_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetBalanceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UserServiceServer).GetBalance(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: UserService_GetBalance_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UserServiceServer).GetBalance(ctx, req.(*GetBalanceRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _UserService_GetStatistics_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetStatisticsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UserServiceServer).GetStatistics(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: UserService_GetStatistics_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UserServiceServer).GetStatistics(ctx, req.(*GetStatisticsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _UserService_GetBalanceStatistics_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetBalanceStatisticsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UserServiceServer).GetBalanceStatistics(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: UserService_GetBalanceStatistics_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UserServiceServer).GetBalanceStatistics(ctx, req.(*GetBalanceStatisticsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// UserService_ServiceDesc is the grpc.ServiceDesc for UserService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var UserService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "user.UserService", + HandlerType: (*UserServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetInfo", + Handler: _UserService_GetInfo_Handler, + }, + { + MethodName: "GetBalance", + Handler: _UserService_GetBalance_Handler, + }, + { + MethodName: "GetStatistics", + Handler: _UserService_GetStatistics_Handler, + }, + { + MethodName: "GetBalanceStatistics", + Handler: _UserService_GetBalanceStatistics_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "api/proto/user/user.proto", +}