Skip to content

Commit 03f9159

Browse files
test(providers): complete provider-utils/env mocks for hosted-key streaming wiring
1 parent 12a4dd1 commit 03f9159

9 files changed

Lines changed: 26 additions & 3 deletions

File tree

apps/sim/providers/azure-anthropic/index.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ const {
3535
})
3636

3737
vi.mock('@anthropic-ai/sdk', () => ({ default: mockAnthropic }))
38-
vi.mock('@/lib/core/config/env', () => ({ env: envState }))
38+
vi.mock('@/lib/core/config/env', () => ({
39+
env: envState,
40+
getEnv: (key: string) => (envState as Record<string, string | undefined>)[key],
41+
isTruthy: (v: unknown) => v === true || v === 'true' || v === '1',
42+
isFalsy: (v: unknown) => v === false || v === 'false' || v === '0',
43+
}))
3944
vi.mock('@/lib/core/security/input-validation.server', () => ({
4045
validateUrlWithDNS: mockValidate,
4146
createPinnedFetch: mockCreatePinnedFetch,

apps/sim/providers/azure-openai/index.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,12 @@ const {
4343
})
4444

4545
vi.mock('openai', () => ({ AzureOpenAI: mockAzureOpenAI }))
46-
vi.mock('@/lib/core/config/env', () => ({ env: envState }))
46+
vi.mock('@/lib/core/config/env', () => ({
47+
env: envState,
48+
getEnv: (key: string) => (envState as Record<string, string | undefined>)[key],
49+
isTruthy: (v: unknown) => v === true || v === 'true' || v === '1',
50+
isFalsy: (v: unknown) => v === false || v === 'false' || v === '0',
51+
}))
4752
vi.mock('@/providers', () => ({ MAX_TOOL_ITERATIONS: 20 }))
4853
vi.mock('@/lib/core/security/input-validation.server', () => ({
4954
validateUrlWithDNS: mockValidate,

apps/sim/providers/baseten/index.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ vi.mock('@/providers/trace-enrichment', () => ({
4949
}))
5050

5151
vi.mock('@/providers/utils', () => ({
52+
isCachedInput: (context?: string | null) => !!context && context.length > 0,
5253
calculateCost: vi.fn().mockReturnValue({ input: 0, output: 0, total: 0 }),
5354
generateSchemaInstructions: vi.fn(() => 'SCHEMA_INSTRUCTIONS'),
5455
prepareToolExecution: vi.fn(() => ({ toolParams: { x: 1 }, executionParams: { x: 1 } })),

apps/sim/providers/fireworks/index.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ vi.mock('@/providers/trace-enrichment', () => ({
4949
}))
5050

5151
vi.mock('@/providers/utils', () => ({
52+
isCachedInput: (context?: string | null) => !!context && context.length > 0,
5253
calculateCost: vi.fn().mockReturnValue({ input: 0, output: 0, total: 0 }),
5354
generateSchemaInstructions: vi.fn(() => 'SCHEMA_INSTRUCTIONS'),
5455
prepareToolExecution: vi.fn(() => ({ toolParams: { x: 1 }, executionParams: { x: 1 } })),

apps/sim/providers/litellm/index.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ vi.mock('@/providers', () => ({ MAX_TOOL_ITERATIONS: 20 }))
2222

2323
vi.mock('@/lib/core/config/env', () => ({
2424
env: { LITELLM_BASE_URL: 'http://litellm.test', LITELLM_API_KEY: '' },
25+
getEnv: (_key: string) => undefined,
26+
isTruthy: (v: unknown) => v === true || v === 'true' || v === '1',
27+
isFalsy: (v: unknown) => v === false || v === 'false' || v === '0',
2528
}))
2629

2730
vi.mock('@/stores/providers', () => ({

apps/sim/providers/ollama-cloud/index.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ vi.mock('@/providers/ollama-cloud/utils', () => ({
6868
},
6969
}))
7070
vi.mock('@/providers/utils', () => ({
71+
isCachedInput: (context?: string | null) => !!context && context.length > 0,
7172
calculateCost: () => ({ input: 0, output: 0, total: 0, pricing: null }),
7273
generateSchemaInstructions: () => 'SCHEMA_INSTRUCTIONS',
7374
prepareToolExecution: (_tool: unknown, args: Record<string, unknown>) => ({

apps/sim/providers/ollama/index.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ vi.mock('@/providers/ollama/utils', () => ({
5656
},
5757
}))
5858
vi.mock('@/providers/utils', () => ({
59+
isCachedInput: (context?: string | null) => !!context && context.length > 0,
5960
calculateCost: () => ({ input: 0, output: 0, total: 0, pricing: null }),
6061
generateSchemaInstructions: () => 'SCHEMA_INSTRUCTIONS',
6162
prepareToolExecution: (_tool: unknown, args: Record<string, unknown>) => ({

apps/sim/providers/together/index.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ vi.mock('@/providers/trace-enrichment', () => ({
4949
}))
5050

5151
vi.mock('@/providers/utils', () => ({
52+
isCachedInput: (context?: string | null) => !!context && context.length > 0,
5253
calculateCost: vi.fn().mockReturnValue({ input: 0, output: 0, total: 0 }),
5354
generateSchemaInstructions: vi.fn(() => 'SCHEMA_INSTRUCTIONS'),
5455
prepareToolExecution: vi.fn(() => ({ toolParams: { x: 1 }, executionParams: { x: 1 } })),

apps/sim/providers/vllm/index.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@ const {
4444
})
4545

4646
vi.mock('openai', () => ({ default: mockOpenAI }))
47-
vi.mock('@/lib/core/config/env', () => ({ env: envState }))
47+
vi.mock('@/lib/core/config/env', () => ({
48+
env: envState,
49+
getEnv: (key: string) => (envState as Record<string, string | undefined>)[key],
50+
isTruthy: (v: unknown) => v === true || v === 'true' || v === '1',
51+
isFalsy: (v: unknown) => v === false || v === 'false' || v === '0',
52+
}))
4853
vi.mock('@/lib/core/security/input-validation.server', () => ({
4954
validateUrlWithDNS: mockValidateUrlWithDNS,
5055
createPinnedFetch: mockCreatePinnedFetch,

0 commit comments

Comments
 (0)