summaryrefslogtreecommitdiff
path: root/packages/cli/src/utils/gitUtils.test.ts
diff options
context:
space:
mode:
authorLee James <[email protected]>2025-08-07 12:00:46 -0400
committerGitHub <[email protected]>2025-08-07 16:00:46 +0000
commit8d848dca4a52d169b3dfea2f66e7e5f69ee5e45c (patch)
treebbb82f3a1e8024e6c116c1ca3b5a5313fa31ab02 /packages/cli/src/utils/gitUtils.test.ts
parent6ae75c9f32a968efa50857a8f24b958a58a84fd6 (diff)
feat: open repo secrets page in addition to README (#5684)
Diffstat (limited to 'packages/cli/src/utils/gitUtils.test.ts')
-rw-r--r--packages/cli/src/utils/gitUtils.test.ts34
1 files changed, 34 insertions, 0 deletions
diff --git a/packages/cli/src/utils/gitUtils.test.ts b/packages/cli/src/utils/gitUtils.test.ts
index 4a29f589..7a5f210c 100644
--- a/packages/cli/src/utils/gitUtils.test.ts
+++ b/packages/cli/src/utils/gitUtils.test.ts
@@ -10,6 +10,7 @@ import {
isGitHubRepository,
getGitRepoRoot,
getLatestGitHubRelease,
+ getGitHubRepoInfo,
} from './gitUtils.js';
vi.mock('child_process');
@@ -44,6 +45,39 @@ describe('isGitHubRepository', async () => {
});
});
+describe('getGitHubRepoInfo', async () => {
+ beforeEach(() => {
+ vi.resetAllMocks();
+ });
+
+ afterEach(() => {
+ vi.restoreAllMocks();
+ });
+
+ it('throws an error if github repo info cannot be determined', async () => {
+ vi.mocked(child_process.execSync).mockImplementation((): string => {
+ throw new Error('oops');
+ });
+ expect(() => {
+ getGitHubRepoInfo();
+ }).toThrowError(/oops/);
+ });
+
+ it('throws an error if owner/repo could not be determined', async () => {
+ vi.mocked(child_process.execSync).mockReturnValueOnce('');
+ expect(() => {
+ getGitHubRepoInfo();
+ }).toThrowError(/Owner & repo could not be extracted from remote URL/);
+ });
+
+ it('returns the owner and repo', async () => {
+ vi.mocked(child_process.execSync).mockReturnValueOnce(
+ 'https://github.com/owner/repo.git ',
+ );
+ expect(getGitHubRepoInfo()).toEqual({ owner: 'owner', repo: 'repo' });
+ });
+});
+
describe('getGitRepoRoot', async () => {
beforeEach(() => {
vi.resetAllMocks();