Files
schpet__linear-cli/test/utils/test-helpers.ts
Peter Schilling af20b0f310 use --allow-all instead of fine grained permissions
this thing runs exec loosely so i don't think they afford me mcuh, and they frequently cause problems
2026-01-29 16:33:18 +00:00

43 lines
1.2 KiB
TypeScript

import { MockLinearServer } from "./mock_linear_server.ts"
// Common Deno args for permissions used across all tests
export const commonDenoArgs = ["--allow-all", "--quiet"]
// Helper function to set up mock Linear server with common environment
export async function setupMockLinearServer(
mockResponses: Array<{
queryName: string
variables?: Record<string, unknown>
response: Record<string, unknown>
}>,
envVars?: Record<string, string>,
): Promise<{ server: MockLinearServer; cleanup: () => Promise<void> }> {
const server = new MockLinearServer(mockResponses)
await server.start()
Deno.env.set("LINEAR_GRAPHQL_ENDPOINT", server.getEndpoint())
Deno.env.set("LINEAR_API_KEY", "Bearer test-token")
// Set any additional environment variables
if (envVars) {
for (const [key, value] of Object.entries(envVars)) {
Deno.env.set(key, value)
}
}
const cleanup = async () => {
await server.stop()
Deno.env.delete("LINEAR_GRAPHQL_ENDPOINT")
Deno.env.delete("LINEAR_API_KEY")
// Clean up additional environment variables
if (envVars) {
for (const key of Object.keys(envVars)) {
Deno.env.delete(key)
}
}
}
return { server, cleanup }
}