Skip to content

Commit

Permalink
test(test): improve commit command test coverage
Browse files Browse the repository at this point in the history
- Improved coverage for CommitCommandTest.php
- Added more test cases for CommitCommand class
- Updated test assertions for better accuracy
- Closes #128
  • Loading branch information
ityaozm@gmail.com committed Jun 12, 2024
1 parent 76db059 commit f31ab69
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions tests/Feature/CommitCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,13 @@
]);
});

$this->artisan(CommitCommand::class, [
'path' => repository_path(),
'--generator' => 'openai',
]);
$this
->artisan(CommitCommand::class, [
'path' => repository_path(),
'--generator' => 'openai',
])
// ->expectsChoice('Please choice commit type', array_key_first($types = config('ai-commit.types')), $types)
->expectsQuestion('Please choice commit type', array_key_first(config('ai-commit.types')));
})
->depends('it will throw TaskException(no cached files to commit)')
->group(__DIR__, __FILE__)
Expand Down Expand Up @@ -107,6 +110,8 @@
$message->keys()->all(),
[$message->all()]
)
// ->expectsChoice('Please choice commit type', array_key_first($types = config('ai-commit.types')), $types)
->expectsQuestion('Please choice commit type', array_key_first(config('ai-commit.types')))
// ->expectsChoice('Please choice a commit message', $message->pluck('subject', 'id')->first(), $message->pluck('subject', 'id')->all())
// ->expectsQuestion('Please choice a commit message', '<comment>regenerating...</comment>')
->expectsConfirmation('Do you want to commit this message?', 'yes')
Expand All @@ -118,6 +123,7 @@
afterAll(static function (): void {
// 清理 playground 仓库
Process::fromShellCommandline('git reset HEAD^', repository_path())->run();
Process::fromShellCommandline('git checkout -- .', repository_path())->run();
// Process::fromShellCommandline('git checkout -- .', repository_path())->run();
Process::fromShellCommandline('git checkout HEAD -- .', repository_path())->run();
Process::fromShellCommandline('git add tests/Fixtures/repository/', base_path())->mustRun();
});

0 comments on commit f31ab69

Please sign in to comment.