Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 53954cf

Browse files
feat: #72 error when issue type not exists
1 parent 5bc4e6e commit 53954cf

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

‎app/Commands/IssueImportCommand.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use App\Coding\Issue;
66
use App\Coding\Iteration;
77
use App\Coding\Project;
8+
use Exception;
89
use LaravelZero\Framework\Commands\Command;
910
use Rap2hpoutre\FastExcel\Facades\FastExcel;
1011

@@ -57,7 +58,7 @@ public function handle(Issue $codingIssue, Project $codingProject, Iteration $it
5758
foreach ($rows as $row) {
5859
try {
5960
$issueResult = $this->createIssueByRow($codingProject, $codingIssue, $iteration, $row);
60-
} catch (\Exception $e) {
61+
} catch (Exception $e) {
6162
$this->error('Error: ' . $e->getMessage());
6263
return 1;
6364
}
@@ -77,6 +78,9 @@ private function createIssueByRow(Project $codingProject, Issue $issue, Iteratio
7778
$this->issueTypes[$item['Name']] = $item;
7879
}
7980
}
81+
if (!isset($this->issueTypes[$row['事项类型']])) {
82+
throw new Exception('' . $row['事项类型'] . '」类型不存在,请在项目设置中添加');
83+
}
8084
$data = [
8185
'Type' => $this->issueTypes[$row['事项类型']]['IssueType'],
8286
'IssueTypeId' => $this->issueTypes[$row['事项类型']]['Id'],

‎tests/Feature/IssueImportCommandTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,4 +178,15 @@ public function testImportSubTask()
178178
->expectsOutput("https://$this->teamDomain.coding.net/p/$this->projectUri/all/issues/" . $subTask2['Code'])
179179
->assertExitCode(0);
180180
}
181+
182+
public function testImportFailedIssueTypeNotExists()
183+
{
184+
$mock = \Mockery::mock(Project::class, [])->makePartial();
185+
$this->instance(Project::class, $mock);
186+
$mock->shouldReceive('getIssueTypes')->times(1)->andReturn([]);
187+
188+
$this->artisan('issue:import', ['file' => $this->dataDir . 'coding/scrum-issues.csv'])
189+
->expectsOutput('Error: 「史诗」类型不存在,请在项目设置中添加')
190+
->assertExitCode(1);
191+
}
181192
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /