chore: import upstream snapshot with attribution
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
import { vi } from 'vitest'
|
||||
|
||||
/**
|
||||
* Default mock environment values for testing
|
||||
*/
|
||||
export const defaultMockEnv = {
|
||||
// Core
|
||||
DATABASE_URL: 'postgresql://test:test@localhost:5432/test',
|
||||
BETTER_AUTH_URL: 'https://test.sim.ai',
|
||||
BETTER_AUTH_SECRET: 'test-secret-that-is-at-least-32-chars-long',
|
||||
ENCRYPTION_KEY: 'test-encryption-key-32-chars-long!',
|
||||
INTERNAL_API_SECRET: 'test-internal-api-secret-32-chars!',
|
||||
|
||||
// Email
|
||||
RESEND_API_KEY: 'test-resend-key',
|
||||
FROM_EMAIL_ADDRESS: 'Sim <noreply@test.sim.ai>',
|
||||
EMAIL_DOMAIN: 'test.sim.ai',
|
||||
PERSONAL_EMAIL_FROM: 'Test <test@test.sim.ai>',
|
||||
|
||||
// URLs
|
||||
NEXT_PUBLIC_APP_URL: 'https://test.sim.ai',
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a mock getEnv function that returns values from the provided env object
|
||||
*/
|
||||
export function createMockGetEnv(envValues: Record<string, string | undefined> = defaultMockEnv) {
|
||||
return vi.fn((key: string) => envValues[key])
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a complete env mock object for use with vi.doMock
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* vi.doMock('@/lib/core/config/env', () => createEnvMock())
|
||||
*
|
||||
* // With custom values
|
||||
* vi.doMock('@/lib/core/config/env', () => createEnvMock({
|
||||
* NEXT_PUBLIC_APP_URL: 'https://custom.example.com',
|
||||
* }))
|
||||
* ```
|
||||
*/
|
||||
export function createEnvMock(overrides: Record<string, string | undefined> = {}) {
|
||||
const envValues = { ...defaultMockEnv, ...overrides }
|
||||
|
||||
return {
|
||||
env: envValues,
|
||||
getEnv: createMockGetEnv(envValues),
|
||||
isTruthy: (value: string | boolean | number | undefined) =>
|
||||
typeof value === 'string' ? value.toLowerCase() === 'true' || value === '1' : Boolean(value),
|
||||
isFalsy: (value: string | boolean | number | undefined) =>
|
||||
typeof value === 'string'
|
||||
? value.toLowerCase() === 'false' || value === '0'
|
||||
: value === false,
|
||||
envBoolean: (value: boolean | string | undefined | null): boolean | undefined => {
|
||||
if (typeof value === 'boolean') return value
|
||||
if (value === undefined || value === null || value === '') return undefined
|
||||
const normalized = String(value).trim().toLowerCase()
|
||||
return (
|
||||
normalized === 'true' || normalized === '1' || normalized === 'yes' || normalized === 'on'
|
||||
)
|
||||
},
|
||||
envNumber: (
|
||||
value: number | string | undefined | null,
|
||||
fallback: number,
|
||||
options: { min?: number } = {}
|
||||
): number => {
|
||||
const min = options.min ?? 0
|
||||
if (typeof value === 'number' && Number.isFinite(value) && value >= min) return value
|
||||
if (value === undefined || value === null || value === '') return fallback
|
||||
const parsed = Number(value)
|
||||
return Number.isFinite(parsed) && parsed >= min ? parsed : fallback
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre-configured env mock for direct use with vi.mock
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* vi.mock('@/lib/core/config/env', () => envMock)
|
||||
* ```
|
||||
*/
|
||||
export const envMock = createEnvMock()
|
||||
Reference in New Issue
Block a user