-
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.
Merge pull request #2 from netsells/feature/pre-pr-tidy
Pre-PR Tidy
- Loading branch information
Showing
13 changed files
with
149 additions
and
92 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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,64 @@ | ||
<?php | ||
|
||
namespace Tests\Feature; | ||
|
||
use App\Exceptions\ProcessFailed; | ||
use App\Helpers\Process; | ||
use Illuminate\Foundation\Testing\WithFaker; | ||
use Mockery; | ||
use Tests\TestCase; | ||
|
||
class AwsEc2ListCommandTest extends TestCase | ||
{ | ||
use WithFaker; | ||
|
||
public function testHandlesError() | ||
{ | ||
$this->mock(Process::class, function ($mock) { | ||
$mock->shouldReceive('withCommand')->once()->andReturnSelf(); | ||
$mock->shouldReceive('run')->once()->andThrow(ProcessFailed::class, "Something bad happened", 1); | ||
}); | ||
|
||
$this->artisan('aws:ec2:list') | ||
->assertExitCode(1); | ||
} | ||
|
||
public function testHandlesNoInstances() | ||
{ | ||
$this->mock(Process::class, function ($mock) { | ||
$mock->shouldReceive('withCommand')->once()->andReturnSelf(); | ||
$mock->shouldReceive('run')->once()->andReturn(null); | ||
}); | ||
|
||
$this->artisan('aws:ec2:list') | ||
->assertExitCode(0); | ||
} | ||
|
||
public function testHandlesInstances() | ||
{ | ||
$instance = [ | ||
'InstanceId' => $this->faker->iban, | ||
'Name' => $this->faker->company, | ||
'PrivateIpAddress' => $this->faker->localIpv4, | ||
'InstanceType' => $this->faker->creditCardType, | ||
]; | ||
|
||
$this->mock(Process::class, function ($mock) use ($instance) { | ||
$mock->shouldReceive('withCommand')->once()->andReturnSelf(); | ||
$mock->shouldReceive('run')->once()->andReturn(json_encode([ | ||
[ | ||
[ | ||
'InstanceId' => $instance['InstanceId'], | ||
'Name' => $instance['Name'], | ||
'PrivateIpAddress' => $instance['PrivateIpAddress'], | ||
'InstanceType' => $instance['InstanceType'], | ||
] | ||
] | ||
])); | ||
}); | ||
|
||
// TODO: Learn how to read output and assert, laravel's implementation is crap | ||
$this->artisan('aws:ec2:list') | ||
->assertExitCode(0); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.