Skip to content

Commit

Permalink
Merge branch 'main' into feat-create-issue
Browse files Browse the repository at this point in the history
  • Loading branch information
aorinevo authored and kavitha186 committed Mar 24, 2024
2 parents 531cea0 + b1239dd commit 5d0fb3a
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 98 deletions.
128 changes: 64 additions & 64 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions src/commands/__snapshots__/list-issues.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ exports[`list-issue command should list issues when the command is invoked 1`] =
[MockFunction] {
"calls": [
[
"╔══════════════╤═════════════╤═══════════╤═══════════
issue Numberissue TitleOwnerRepo Name
╟──────────────┼─────────────┼───────────┼───────────╢
undefined undefinedundefinedundefined
╚══════════════╧═════════════╧═══════════╧═══════════╝
"╔══════════════╤═════════════╤════════════╤════════╤═══════════
issue Numberissue TitleOwner status Repo Name
╟──────────────┼─────────────┼────────────┼────────┼───────────╢
3 new titleNerdwalletclosedshepherd
╚══════════════╧═════════════╧════════════╧════════╧═══════════╝
",
],
],
Expand Down
50 changes: 49 additions & 1 deletion src/commands/issue.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('issue command', () => {
let mockContext: IMigrationContext;
let mockContext1: IMigrationContext;
let mockContext2: IMigrationContext;

let mockContext3: IMigrationContext;
beforeEach(() => {
jest.clearAllMocks();
mockContext = {
Expand Down Expand Up @@ -88,6 +88,34 @@ describe('issue command', () => {
adapter: mockAdapter,
logger: mockLogger,
};
mockContext3 = {
shepherd: {
workingDirectory: 'workingDirectory',
},
migration: {
migrationDirectory: 'migrationDirectory',
spec: {
id: 'id',
title: 'title',
adapter: {
type: 'adapter',
},
hooks: {},
issues: {
title: 'this is issue',
description: 'issue description',
state_reason: 'not_planned',
labels: ['bug'],
},
},
workingDirectory: 'workingDirectory',
selectedRepos: [{ name: 'selectedRepos' }],
repos: [{ name: 'selectedRepos' }],
upstreamOwner: 'upstreamOwner',
},
adapter: mockAdapter,
logger: mockLogger,
};
});

it('create issue if the issue doesnt exists in tracker', async () => {
Expand Down Expand Up @@ -153,4 +181,24 @@ describe('issue command', () => {
await issue(mockContext2);
expect(mockSpinner.fail).toHaveBeenCalledWith('No issues in the shepherd yml to post');
});
it('should catch error when issue with no title command is accessed', async () => {
(getIssueListsFromTracker as jest.Mock).mockResolvedValueOnce([
{
issueNumber: '7',
title: 'this is my first updated issue',
owner: 'newowner',
status: 'open',
repo: 'newrepo',
},
{
issueNumber: '0',
title: 'this is my first updated issue',
owner: 'newowner4',
status: 'open',
repo: 'newrepo4',
},
]);
await issue(mockContext3);
expect(mockContext3.adapter.createIssue).toHaveBeenCalled();
});
});
5 changes: 5 additions & 0 deletions src/commands/issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ export default async (context: IMigrationContext) => {
try {
const title = spec.issues.title;
const issuesList: IssueTracker[] = await getIssueListsFromTracker(context);
let status = spec.issues.state;

if (!status) {
status = 'open';
}
await forEachRepo(context, async (repo) => {
logger.spinner('Posting an issue');

Expand All @@ -39,6 +43,7 @@ export default async (context: IMigrationContext) => {
issueNumber,
title,
owner: repo.owner,
status,
repo: repo.name,
});
spinner.succeed('Issue posted in the repository');
Expand Down
Loading

0 comments on commit 5d0fb3a

Please sign in to comment.