-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: updated tests and refactored commands
- Loading branch information
Showing
6 changed files
with
77 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
use App\Jobs\SyncRepository; | ||
use App\Models\Repository; | ||
use Illuminate\Support\Facades\Queue; | ||
|
||
use function Pest\Laravel\artisan; | ||
use function Pest\Laravel\assertDatabaseHas; | ||
|
||
it('can sync repositories as parameter', function () { | ||
$repositories = Repository::factory()->count(2)->create()->pluck('name'); | ||
Queue::fake(); | ||
artisan("repository:sync {$repositories->join(' ')} test") | ||
->expectsOutput("Dispatching sync for '{$repositories->get(0)}'.") | ||
->expectsOutput("Dispatching sync for '{$repositories->get(1)}'.") | ||
->expectsOutput("Repository 'test' not found.") | ||
->assertExitCode(0); | ||
Queue::assertPushed(SyncRepository::class, 2); | ||
}); | ||
|
||
it('can create a repository through cli', function () { | ||
$repository = Repository::factory()->make(); | ||
Queue::fake(); | ||
artisan('repository:create') | ||
->expectsQuestion('What is the name of the repository?', $repository->name) | ||
->expectsQuestion('Provide the command to be ran to sync this repository.', $repository->command) | ||
->expectsQuestion('Provide the folder where the data is.', $repository->source_folder) | ||
->expectsQuestion('Please provide how much time the repository must be kept back from upstream.', $repository->delay) | ||
->assertExitCode(0); | ||
assertDatabaseHas('repositories', $repository->toArray()); | ||
Queue::assertPushed(SyncRepository::class); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters