Isolate Kimi usage home lookup in tests (#1636)
This commit is contained in:
@@ -24,6 +24,7 @@ const KimiAuthSchema = z.object({
|
||||
interface KimiQuotaProviderOptions {
|
||||
logger: Logger;
|
||||
fetch?: ProviderApiFetch;
|
||||
homeDir?: string;
|
||||
}
|
||||
|
||||
export class KimiQuotaProvider implements ProviderUsageFetcher {
|
||||
@@ -32,10 +33,12 @@ export class KimiQuotaProvider implements ProviderUsageFetcher {
|
||||
|
||||
private readonly logger: Logger;
|
||||
private readonly fetchApi: ProviderApiFetch;
|
||||
private readonly homeDir?: string;
|
||||
|
||||
constructor(options: KimiQuotaProviderOptions) {
|
||||
this.logger = options.logger;
|
||||
this.fetchApi = options.fetch ?? fetch;
|
||||
this.homeDir = options.homeDir;
|
||||
}
|
||||
|
||||
async fetchUsage(): Promise<ProviderUsage> {
|
||||
@@ -88,13 +91,14 @@ export class KimiQuotaProvider implements ProviderUsageFetcher {
|
||||
}
|
||||
|
||||
private async readKimiToken(): Promise<string | null> {
|
||||
const homeDir = this.homeDir ?? homedir();
|
||||
const paths = [
|
||||
join(
|
||||
process.env["KIMI_CODE_HOME"] || join(homedir(), ".kimi-code"),
|
||||
process.env["KIMI_CODE_HOME"] || join(homeDir, ".kimi-code"),
|
||||
"credentials",
|
||||
"kimi-code.json",
|
||||
),
|
||||
join(homedir(), ".kimi", "credentials", "kimi-code.json"),
|
||||
join(homeDir, ".kimi", "credentials", "kimi-code.json"),
|
||||
];
|
||||
|
||||
for (const path of paths) {
|
||||
|
||||
Reference in New Issue
Block a user