Skip to content

Commit dc28e64

Browse files
Update README formatting for clarity and enhance proxy tests with stop functionality
1 parent 02ec798 commit dc28e64

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ Configuration and logs are stored in:
6565

6666
If you encounter issues:
6767

68-
1. Run `cloudsqlctl doctor` to check for common problems.
69-
2. Check the logs in `%LOCALAPPDATA%\CloudSQLCTL\logs`.
70-
3. Ensure `gcloud` is installed and authenticated (`gcloud auth login`).
68+
1. Run `cloudsqlctl doctor` to check for common problems.
69+
2. Check the logs in `%LOCALAPPDATA%\CloudSQLCTL\logs`.
70+
3. Ensure `gcloud` is installed and authenticated (`gcloud auth login`).
7171

7272
## Contributing
7373

bin/cloudsqlctl.exe

0 Bytes
Binary file not shown.

tests/proxy.test.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jest.unstable_mockModule('fs-extra', () => ({
1414

1515
// Mock execa
1616
jest.unstable_mockModule('execa', () => ({
17-
default: jest.fn(),
17+
execa: jest.fn(),
1818
}));
1919

2020
// Mock child_process
@@ -34,15 +34,24 @@ describe('Proxy Module', () => {
3434
});
3535

3636
it('should return false if PID file does not exist', async () => {
37-
(fs.pathExists as jest.Mock).mockReturnValue(Promise.resolve(false));
37+
(fs.pathExists as unknown as jest.Mock).mockReturnValue(Promise.resolve(false));
3838
const running = await isRunning();
3939
expect(running).toBe(false);
4040
});
4141

4242
it('should start proxy if not running', async () => {
43-
(fs.pathExists as jest.Mock).mockReturnValue(Promise.resolve(false));
43+
(fs.pathExists as unknown as jest.Mock).mockReturnValue(Promise.resolve(false));
4444
const pid = await startProxy('test-connection');
4545
expect(pid).toBe(12345);
4646
expect(fs.writeFile).toHaveBeenCalled();
4747
});
48+
49+
it('should stop proxy if running', async () => {
50+
(fs.pathExists as unknown as jest.Mock).mockReturnValue(Promise.resolve(true));
51+
(fs.readFile as unknown as jest.Mock).mockReturnValue(Promise.resolve('12345'));
52+
53+
await stopProxy();
54+
55+
expect(fs.remove).toHaveBeenCalled();
56+
});
4857
});

0 commit comments

Comments
 (0)