mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-07-20 15:00:54 -07:00
Refac: Centralize storage file management (#4078)
Co-authored-by: Taylor Mullen <ntaylormullen@google.com>
This commit is contained in:
@@ -11,7 +11,7 @@ import {
|
||||
clearCachedCredentialFile,
|
||||
clearOauthClientCache,
|
||||
} from './oauth2.js';
|
||||
import { getCachedGoogleAccount } from '../utils/user_account.js';
|
||||
import { UserAccountManager } from '../utils/userAccountManager.js';
|
||||
import { OAuth2Client, Compute } from 'google-auth-library';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
@@ -180,7 +180,10 @@ describe('oauth2', () => {
|
||||
});
|
||||
|
||||
// Verify the getCachedGoogleAccount function works
|
||||
expect(getCachedGoogleAccount()).toBe('test-google-account@gmail.com');
|
||||
const userAccountManager = new UserAccountManager();
|
||||
expect(userAccountManager.getCachedGoogleAccount()).toBe(
|
||||
'test-google-account@gmail.com',
|
||||
);
|
||||
});
|
||||
|
||||
it('should perform login with user code', async () => {
|
||||
@@ -533,14 +536,17 @@ describe('oauth2', () => {
|
||||
googleAccountPath,
|
||||
JSON.stringify(accountData),
|
||||
);
|
||||
const userAccountManager = new UserAccountManager();
|
||||
|
||||
expect(fs.existsSync(credsPath)).toBe(true);
|
||||
expect(fs.existsSync(googleAccountPath)).toBe(true);
|
||||
expect(getCachedGoogleAccount()).toBe('test@example.com');
|
||||
expect(userAccountManager.getCachedGoogleAccount()).toBe(
|
||||
'test@example.com',
|
||||
);
|
||||
|
||||
await clearCachedCredentialFile();
|
||||
expect(fs.existsSync(credsPath)).toBe(false);
|
||||
expect(getCachedGoogleAccount()).toBeNull();
|
||||
expect(userAccountManager.getCachedGoogleAccount()).toBeNull();
|
||||
const updatedAccountData = JSON.parse(
|
||||
fs.readFileSync(googleAccountPath, 'utf-8'),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user