Skip to content

Commit f31ab69

Browse files
author
ityaozm@gmail.com
committed
test(test): improve commit command test coverage
- Improved coverage for CommitCommandTest.php - Added more test cases for CommitCommand class - Updated test assertions for better accuracy - Closes #128
1 parent 76db059 commit f31ab69

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

tests/Feature/CommitCommandTest.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,13 @@
7575
]);
7676
});
7777

78-
$this->artisan(CommitCommand::class, [
79-
'path' => repository_path(),
80-
'--generator' => 'openai',
81-
]);
78+
$this
79+
->artisan(CommitCommand::class, [
80+
'path' => repository_path(),
81+
'--generator' => 'openai',
82+
])
83+
// ->expectsChoice('Please choice commit type', array_key_first($types = config('ai-commit.types')), $types)
84+
->expectsQuestion('Please choice commit type', array_key_first(config('ai-commit.types')));
8285
})
8386
->depends('it will throw TaskException(no cached files to commit)')
8487
->group(__DIR__, __FILE__)
@@ -107,6 +110,8 @@
107110
$message->keys()->all(),
108111
[$message->all()]
109112
)
113+
// ->expectsChoice('Please choice commit type', array_key_first($types = config('ai-commit.types')), $types)
114+
->expectsQuestion('Please choice commit type', array_key_first(config('ai-commit.types')))
110115
// ->expectsChoice('Please choice a commit message', $message->pluck('subject', 'id')->first(), $message->pluck('subject', 'id')->all())
111116
// ->expectsQuestion('Please choice a commit message', '<comment>regenerating...</comment>')
112117
->expectsConfirmation('Do you want to commit this message?', 'yes')
@@ -118,6 +123,7 @@
118123
afterAll(static function (): void {
119124
// 清理 playground 仓库
120125
Process::fromShellCommandline('git reset HEAD^', repository_path())->run();
121-
Process::fromShellCommandline('git checkout -- .', repository_path())->run();
126+
// Process::fromShellCommandline('git checkout -- .', repository_path())->run();
127+
Process::fromShellCommandline('git checkout HEAD -- .', repository_path())->run();
122128
Process::fromShellCommandline('git add tests/Fixtures/repository/', base_path())->mustRun();
123129
});

0 commit comments

Comments
 (0)