/**
 * Mock factories for services
 */

import { vi } from 'vitest';

export function createMockStorageClient() {
  return {
    upload: vi.fn().mockResolvedValue('test-key'),
    download: vi.fn().mockResolvedValue(Buffer.from('test content')),
    delete: vi.fn().mockResolvedValue(undefined),
    getPresignedUrl: vi.fn().mockResolvedValue('https://presigned-url.example.com'),
    objectExists: vi.fn().mockResolvedValue(false),
  };
}

export function createMockKMSClient() {
  return {
    encrypt: vi.fn().mockResolvedValue(Buffer.from('encrypted')),
    decrypt: vi.fn().mockResolvedValue(Buffer.from('decrypted')),
    sign: vi.fn().mockResolvedValue(Buffer.from('signature')),
    verify: vi.fn().mockResolvedValue(true),
  };
}

export function createMockDatabasePool() {
  return {
    query: vi.fn().mockResolvedValue({ rows: [], rowCount: 0 }),
    end: vi.fn().mockResolvedValue(undefined),
  };
}

export function createMockFastifyRequest(overrides?: Partial<any>) {
  return {
    headers: {},
    params: {},
    query: {},
    body: {},
    user: undefined,
    id: 'test-request-id',
    log: {
      info: vi.fn(),
      error: vi.fn(),
      warn: vi.fn(),
    },
    ...overrides,
  };
}

export function createMockFastifyReply() {
  return {
    status: vi.fn().mockReturnThis(),
    send: vi.fn().mockReturnThis(),
    header: vi.fn().mockReturnThis(),
    code: vi.fn().mockReturnThis(),
  };
}

