fix(pr-3347): use worktree-local cleanup helper in ai tests
This commit is contained in:
@@ -9,7 +9,7 @@ import {
|
||||
RemoteAuthCredentialStore,
|
||||
startAuthBroker,
|
||||
} from "@oh-my-pi/pi-ai/auth-broker";
|
||||
import { removeWithRetries } from "@oh-my-pi/pi-utils";
|
||||
import { removeWithRetries } from "../../utils/src/temp";
|
||||
|
||||
// MCP OAuth credentials extend the base OAuthCredential with refresh material
|
||||
// (tokenUrl/clientId/clientSecret/resource) embedded so token refresh works for
|
||||
|
||||
@@ -5,7 +5,7 @@ import * as path from "node:path";
|
||||
import { AuthStorage, SqliteAuthCredentialStore } from "@oh-my-pi/pi-ai";
|
||||
import { AuthBrokerRefresher } from "@oh-my-pi/pi-ai/auth-broker";
|
||||
import * as oauthUtils from "@oh-my-pi/pi-ai/registry/oauth";
|
||||
import { removeWithRetries } from "@oh-my-pi/pi-utils";
|
||||
import { removeWithRetries } from "../../utils/src/temp";
|
||||
|
||||
const ANTHROPIC_ENV = ["ANTHROPIC_API_KEY", "ANTHROPIC_OAUTH_TOKEN"] as const;
|
||||
const savedEnv: Partial<Record<(typeof ANTHROPIC_ENV)[number], string | undefined>> = {};
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
type SnapshotResponse,
|
||||
startAuthBroker,
|
||||
} from "@oh-my-pi/pi-ai/auth-broker";
|
||||
import { removeWithRetries } from "@oh-my-pi/pi-utils";
|
||||
import { removeWithRetries } from "../../utils/src/temp";
|
||||
|
||||
const ANTHROPIC_ENV = ["ANTHROPIC_API_KEY", "ANTHROPIC_OAUTH_TOKEN"] as const;
|
||||
const savedEnv: Partial<Record<(typeof ANTHROPIC_ENV)[number], string | undefined>> = {};
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
type SnapshotResponse,
|
||||
writeAuthBrokerSnapshotCache,
|
||||
} from "@oh-my-pi/pi-ai/auth-broker";
|
||||
import { removeWithRetries } from "@oh-my-pi/pi-utils";
|
||||
import { removeWithRetries } from "../../utils/src/temp";
|
||||
|
||||
const TOKEN = "broker-cache-token";
|
||||
const URL = "http://127.0.0.1:8765";
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
startAuthBroker,
|
||||
} from "@oh-my-pi/pi-ai/auth-broker";
|
||||
import * as oauthUtils from "@oh-my-pi/pi-ai/registry/oauth";
|
||||
import { removeWithRetries } from "@oh-my-pi/pi-utils";
|
||||
import { removeWithRetries } from "../../utils/src/temp";
|
||||
|
||||
const ANTHROPIC_ENV = ["ANTHROPIC_API_KEY", "ANTHROPIC_OAUTH_TOKEN"] as const;
|
||||
const savedEnv: Partial<Record<(typeof ANTHROPIC_ENV)[number], string | undefined>> = {};
|
||||
|
||||
@@ -4,7 +4,7 @@ import * as os from "node:os";
|
||||
import * as path from "node:path";
|
||||
import { type AuthCredentialStore, AuthStorage, SqliteAuthCredentialStore } from "@oh-my-pi/pi-ai/auth-storage";
|
||||
import * as oauthUtils from "@oh-my-pi/pi-ai/registry/oauth";
|
||||
import { removeWithRetries } from "@oh-my-pi/pi-utils";
|
||||
import { removeWithRetries } from "../../utils/src/temp";
|
||||
|
||||
const PROVIDER = "unit-oauth-identity";
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import { type AuthCredentialStore, AuthStorage, SqliteAuthCredentialStore } from
|
||||
import * as oauthUtils from "@oh-my-pi/pi-ai/registry/oauth";
|
||||
import type { OAuthCredentials } from "@oh-my-pi/pi-ai/registry/oauth/types";
|
||||
import type { UsageLimit, UsageProvider, UsageReport } from "@oh-my-pi/pi-ai/usage";
|
||||
import { removeWithRetries } from "@oh-my-pi/pi-utils";
|
||||
import { removeWithRetries } from "../../utils/src/temp";
|
||||
|
||||
const HOUR_MS = 60 * 60 * 1000;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import { AuthStorage, SqliteAuthCredentialStore } from "@oh-my-pi/pi-ai/auth-sto
|
||||
import * as deepseekModule from "@oh-my-pi/pi-ai/registry/deepseek";
|
||||
import * as kagiModule from "@oh-my-pi/pi-ai/registry/kagi";
|
||||
import * as ollamaCloudModule from "@oh-my-pi/pi-ai/registry/ollama-cloud";
|
||||
import { removeWithRetries } from "@oh-my-pi/pi-utils";
|
||||
import { removeWithRetries } from "../../utils/src/temp";
|
||||
|
||||
function countCredentialRows(dbPath: string, provider: string): number {
|
||||
const db = new Database(dbPath, { readonly: true });
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
SqliteAuthCredentialStore,
|
||||
} from "@oh-my-pi/pi-ai/auth-storage";
|
||||
import * as oauthUtils from "@oh-my-pi/pi-ai/registry/oauth";
|
||||
import { removeWithRetries } from "@oh-my-pi/pi-utils";
|
||||
import { removeWithRetries } from "../../utils/src/temp";
|
||||
|
||||
describe("AuthStorage broker sentinel refresh", () => {
|
||||
let tempDir = "";
|
||||
|
||||
@@ -6,7 +6,7 @@ import { type AuthCredentialStore, AuthStorage, SqliteAuthCredentialStore } from
|
||||
import * as oauthUtils from "@oh-my-pi/pi-ai/registry/oauth";
|
||||
import type { OAuthCredentials } from "@oh-my-pi/pi-ai/registry/oauth/types";
|
||||
import type { UsageLimit, UsageProvider, UsageReport } from "@oh-my-pi/pi-ai/usage";
|
||||
import { removeWithRetries } from "@oh-my-pi/pi-utils";
|
||||
import { removeWithRetries } from "../../utils/src/temp";
|
||||
|
||||
const WEEK_MS = 7 * 24 * 60 * 60 * 1000;
|
||||
const HOUR_MS = 60 * 60 * 1000;
|
||||
|
||||
@@ -3,7 +3,7 @@ import * as fs from "node:fs/promises";
|
||||
import * as os from "node:os";
|
||||
import * as path from "node:path";
|
||||
import { type AuthCredentialStore, AuthStorage, SqliteAuthCredentialStore } from "@oh-my-pi/pi-ai/auth-storage";
|
||||
import { removeWithRetries } from "@oh-my-pi/pi-utils";
|
||||
import { removeWithRetries } from "../../utils/src/temp";
|
||||
import { withEnv } from "./helpers";
|
||||
|
||||
const SUPPRESS_ANTHROPIC_ENV = {
|
||||
|
||||
@@ -3,7 +3,7 @@ import * as fs from "node:fs/promises";
|
||||
import * as os from "node:os";
|
||||
import * as path from "node:path";
|
||||
import { type AuthCredentialStore, AuthStorage, SqliteAuthCredentialStore } from "@oh-my-pi/pi-ai/auth-storage";
|
||||
import { removeWithRetries } from "@oh-my-pi/pi-utils";
|
||||
import { removeWithRetries } from "../../utils/src/temp";
|
||||
import { withEnv } from "./helpers";
|
||||
|
||||
// Clear every env var the providers under test alias, so ambient shell / ~/.env
|
||||
|
||||
@@ -4,7 +4,7 @@ import * as fs from "node:fs/promises";
|
||||
import * as os from "node:os";
|
||||
import * as path from "node:path";
|
||||
import { AuthStorage, type FetchImpl, type OAuthCredential, SqliteAuthCredentialStore } from "@oh-my-pi/pi-ai";
|
||||
import { removeWithRetries } from "@oh-my-pi/pi-utils";
|
||||
import { removeWithRetries } from "../../utils/src/temp";
|
||||
import { registerOAuthProvider, unregisterOAuthProviders } from "../src/registry/oauth";
|
||||
|
||||
const LEGACY_TIMESTAMP = 1_700_000_000;
|
||||
|
||||
@@ -4,7 +4,7 @@ import * as os from "node:os";
|
||||
import * as path from "node:path";
|
||||
import { type AuthCredentialStore, AuthStorage, SqliteAuthCredentialStore } from "@oh-my-pi/pi-ai/auth-storage";
|
||||
import { registerOAuthProvider, unregisterOAuthProviders } from "@oh-my-pi/pi-ai/registry/oauth";
|
||||
import { removeWithRetries } from "@oh-my-pi/pi-utils";
|
||||
import { removeWithRetries } from "../../utils/src/temp";
|
||||
|
||||
const PROVIDER = "unit-rotate-oauth";
|
||||
const SOURCE = "auth-storage-force-refresh-rotate-test";
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
SqliteAuthCredentialStore,
|
||||
} from "@oh-my-pi/pi-ai/auth-storage";
|
||||
import * as oauthUtils from "@oh-my-pi/pi-ai/registry/oauth";
|
||||
import { removeWithRetries } from "@oh-my-pi/pi-utils";
|
||||
import { removeWithRetries } from "../../utils/src/temp";
|
||||
import { withEnv } from "./helpers";
|
||||
|
||||
const SUPPRESS_ANTHROPIC_ENV = {
|
||||
|
||||
@@ -4,7 +4,7 @@ import * as os from "node:os";
|
||||
import * as path from "node:path";
|
||||
import { type AuthCredentialStore, AuthStorage, SqliteAuthCredentialStore } from "@oh-my-pi/pi-ai/auth-storage";
|
||||
import { registerOAuthProvider, unregisterOAuthProviders } from "@oh-my-pi/pi-ai/registry/oauth";
|
||||
import { removeWithRetries } from "@oh-my-pi/pi-utils";
|
||||
import { removeWithRetries } from "../../utils/src/temp";
|
||||
|
||||
describe("AuthStorage OAuth refresh skew", () => {
|
||||
let tempDir = "";
|
||||
|
||||
@@ -14,7 +14,7 @@ import * as fs from "node:fs/promises";
|
||||
import * as os from "node:os";
|
||||
import * as path from "node:path";
|
||||
import { isSqliteBusyError, SqliteAuthCredentialStore } from "@oh-my-pi/pi-ai/auth-storage";
|
||||
import { removeWithRetries } from "@oh-my-pi/pi-utils";
|
||||
import { removeWithRetries } from "../../utils/src/temp";
|
||||
|
||||
interface SqliteBusyShape extends Error {
|
||||
code: string;
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
resolveAwsCredentials,
|
||||
tokenizeCredentialProcessCommand,
|
||||
} from "@oh-my-pi/pi-ai/providers/aws-credentials";
|
||||
import { removeWithRetries } from "@oh-my-pi/pi-utils";
|
||||
import { removeWithRetries } from "../../utils/src/temp";
|
||||
|
||||
// `credential_process` integration coverage. Drives a real `Bun.spawn`
|
||||
// against a fixture script so the JSON envelope contract, exit-code
|
||||
|
||||
@@ -5,7 +5,7 @@ import * as path from "node:path";
|
||||
import type { ModelSpec } from "@oh-my-pi/pi-ai/types";
|
||||
import { readModelCache } from "@oh-my-pi/pi-catalog/model-cache";
|
||||
import { resolveProviderModels } from "@oh-my-pi/pi-catalog/model-manager";
|
||||
import { removeWithRetries } from "@oh-my-pi/pi-utils";
|
||||
import { removeWithRetries } from "../../utils/src/temp";
|
||||
|
||||
const TTL_MS = 24 * 60 * 60 * 1000;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import * as os from "node:os";
|
||||
import * as path from "node:path";
|
||||
import { AuthStorage, SqliteAuthCredentialStore } from "@oh-my-pi/pi-ai/auth-storage";
|
||||
import * as kimiOauth from "@oh-my-pi/pi-ai/registry/oauth/kimi";
|
||||
import { removeWithRetries } from "@oh-my-pi/pi-utils";
|
||||
import { removeWithRetries } from "../../utils/src/temp";
|
||||
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
|
||||
@@ -6,7 +6,7 @@ import * as path from "node:path";
|
||||
import type { Model } from "@oh-my-pi/pi-ai/types";
|
||||
import { buildModel } from "@oh-my-pi/pi-catalog/build";
|
||||
import { readModelCache, writeModelCache } from "@oh-my-pi/pi-catalog/model-cache";
|
||||
import { removeWithRetries } from "@oh-my-pi/pi-utils";
|
||||
import { removeWithRetries } from "../../utils/src/temp";
|
||||
|
||||
const TTL_MS = 24 * 60 * 60 * 1000;
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
startAuthBroker,
|
||||
} from "@oh-my-pi/pi-ai/auth-broker";
|
||||
import * as oauthUtils from "@oh-my-pi/pi-ai/registry/oauth";
|
||||
import { removeWithRetries } from "@oh-my-pi/pi-utils";
|
||||
import { removeWithRetries } from "../../utils/src/temp";
|
||||
|
||||
const ANTHROPIC_ENV = ["ANTHROPIC_API_KEY", "ANTHROPIC_OAUTH_TOKEN"] as const;
|
||||
const savedEnv: Partial<Record<(typeof ANTHROPIC_ENV)[number], string | undefined>> = {};
|
||||
|
||||
@@ -8,7 +8,7 @@ import type { AssistantMessage, FetchImpl, Model, ModelSpec } from "@oh-my-pi/pi
|
||||
import { AssistantMessageEventStream } from "@oh-my-pi/pi-ai/utils/event-stream";
|
||||
import { wrapFetchForRequestDebug } from "@oh-my-pi/pi-ai/utils/request-debug";
|
||||
import { buildModel } from "@oh-my-pi/pi-catalog/build";
|
||||
import { removeWithRetries } from "@oh-my-pi/pi-utils";
|
||||
import { removeWithRetries } from "../../utils/src/temp";
|
||||
|
||||
const enc = new TextEncoder();
|
||||
|
||||
|
||||
@@ -9,7 +9,8 @@ import { complete, getEnvApiKey, stream } from "@oh-my-pi/pi-ai/stream";
|
||||
import type { Api, Context, ImageContent, Model, OptionsForApi, Tool, ToolResultMessage } from "@oh-my-pi/pi-ai/types";
|
||||
import { buildModel } from "@oh-my-pi/pi-catalog/build";
|
||||
import { getBundledModel } from "@oh-my-pi/pi-catalog/models";
|
||||
import { $which, removeWithRetries } from "@oh-my-pi/pi-utils";
|
||||
import { $which } from "@oh-my-pi/pi-utils";
|
||||
import { removeWithRetries } from "../../utils/src/temp";
|
||||
import { type } from "arktype";
|
||||
import { e2eApiKey, resolveApiKey } from "./oauth";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user