tests pass!
This commit is contained in:
@@ -32,7 +32,7 @@ test('index route displays servers for an organisation', function () {
|
||||
'name' => 'keystone',
|
||||
'external_id' => 'net-12345',
|
||||
'provider_id' => $provider->id,
|
||||
'ip_range' => fake()->ipv4() . '/24',
|
||||
'ip_range' => fake()->ipv4().'/24',
|
||||
]);
|
||||
|
||||
Server::factory()->count(2)->create([
|
||||
@@ -43,7 +43,7 @@ test('index route displays servers for an organisation', function () {
|
||||
|
||||
$response = $this->get(route('servers.index', ['organisation' => $organisation->id]));
|
||||
$response->assertStatus(200);
|
||||
$response->assertInertia(fn(AssertableInertia $page) => $page
|
||||
$response->assertInertia(fn (AssertableInertia $page) => $page
|
||||
->component('servers/Index'));
|
||||
});
|
||||
|
||||
@@ -51,7 +51,7 @@ test('create route returns inertia view', function () {
|
||||
$organisation = Organisation::factory()->create();
|
||||
$response = $this->get(route('servers.create', ['organisation' => $organisation->id]));
|
||||
$response->assertStatus(200);
|
||||
$response->assertInertia(fn(AssertableInertia $page) => $page
|
||||
$response->assertInertia(fn (AssertableInertia $page) => $page
|
||||
->component('servers/Create'));
|
||||
});
|
||||
|
||||
@@ -77,7 +77,7 @@ test('store route creates a server with valid data', function () {
|
||||
'name' => 'hetzner',
|
||||
'type' => ProviderType::HETZNER,
|
||||
'token' => Str::uuid(),
|
||||
'organisation_id' => $organisation->id
|
||||
'organisation_id' => $organisation->id,
|
||||
]);
|
||||
|
||||
$network = $organisation->networks()->create([
|
||||
@@ -85,21 +85,12 @@ test('store route creates a server with valid data', function () {
|
||||
'name' => 'keystone',
|
||||
'external_id' => 'net-12345',
|
||||
'provider_id' => $provider->id,
|
||||
'ip_range' => fake()->ipv4() . '/24',
|
||||
'ip_range' => fake()->ipv4().'/24',
|
||||
]);
|
||||
|
||||
$this->mock(HetznerService::class, function (MockInterface $mock) use ($network) {
|
||||
$this->partialMock(HetznerService::class, function (MockInterface $mock) use ($network) {
|
||||
$mock->shouldReceive('createServer')
|
||||
->once()
|
||||
->with(
|
||||
Mockery::on(function ($arg) {
|
||||
return is_string($arg['name']) && strlen($arg['name']) > 0;
|
||||
}),
|
||||
'cx11',
|
||||
'hel1',
|
||||
'ubuntu-20.04',
|
||||
$network->external_id
|
||||
)
|
||||
->andReturn(new CreatedServer(
|
||||
name: 'test-server-from-mock',
|
||||
rootPassword: 'password123',
|
||||
@@ -108,6 +99,7 @@ test('store route creates a server with valid data', function () {
|
||||
ipv4: '192.0.2.100',
|
||||
ipv6: '2001:db8::100',
|
||||
networkId: $network->external_id,
|
||||
privateIp: '10.0.0.1',
|
||||
));
|
||||
|
||||
$mock->shouldReceive('createNetwork')->never();
|
||||
@@ -132,14 +124,18 @@ test('store route creates a server with valid data', function () {
|
||||
|
||||
test('show route displays a single server', function () {
|
||||
$organisation = Organisation::factory()->create();
|
||||
$provider = Provider::factory()->forOrganisation($organisation)->create();
|
||||
$network = $organisation->networks()->create([
|
||||
'type' => NetworkType::EXTERNAL,
|
||||
'name' => 'keystone',
|
||||
'external_id' => 'net-12345',
|
||||
'provider_id' => $provider->id,
|
||||
'ip_range' => fake()->ipv4().'/24',
|
||||
]);
|
||||
$server = Server::factory()->create([
|
||||
'organisation_id' => $organisation->id,
|
||||
'external_network_id' => $network->id,
|
||||
'provider_id' => $provider->id,
|
||||
]);
|
||||
|
||||
$response = $this->get(route('servers.show', [
|
||||
@@ -148,6 +144,6 @@ test('show route displays a single server', function () {
|
||||
]));
|
||||
|
||||
$response->assertStatus(200);
|
||||
$response->assertInertia(fn(AssertableInertia $page) => $page
|
||||
$response->assertInertia(fn (AssertableInertia $page) => $page
|
||||
->component('servers/Show'));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user