Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
peterfox authored and github-actions[bot] committed Jun 18, 2022
1 parent 3398f32 commit 4eee141
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 33 deletions.
8 changes: 6 additions & 2 deletions src/Commands/CreateQueueCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ public function action(
): int {
$location = CloudTasksClient::locationName($config['project_id'], $config['location']);
$cloudQueue = new Queue();
$cloudQueue->setName(CloudTasksClient::queueName(
$config['project_id'], $config['location'], $queueName ?? $config['queue'])
$cloudQueue->setName(
CloudTasksClient::queueName(
$config['project_id'],
$config['location'],
$queueName ?? $config['queue']
)
);
$cloudQueue = $queueModifier->apply($cloudQueue, $config['settings'] ?? []);
$client->createQueue($location, $cloudQueue);
Expand Down
4 changes: 3 additions & 1 deletion src/Commands/DeleteQueueCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public function action(CloudTasksClient $client, array $config, string $namespac
return 0;
}
$queueName = CloudTasksClient::queueName(
$config['project_id'], $config['location'], $queueName ?? $config['queue']
$config['project_id'],
$config['location'],
$queueName ?? $config['queue']
);
$client->deleteQueue($queueName);
$this->line("Queue {$namespaceName} has been deleted.");
Expand Down
4 changes: 3 additions & 1 deletion src/Commands/ListTasksCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ public function action(
array $config,
): int {
$cloudQueueName = CloudTasksClient::queueName(
$config['project_id'], $config['location'], $queueName ?? $config['queue']
$config['project_id'],
$config['location'],
$queueName ?? $config['queue']
);

$pagedResponse = $client->listTasks($cloudQueueName);
Expand Down
4 changes: 3 additions & 1 deletion src/Commands/PurgeQueueCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ public function action(CloudTasksClient $client, string $namespaceName, string|n
return 0;
}
$cloudQueueName = CloudTasksClient::queueName(
$config['project_id'], $config['location'], $queueName ?? $config['queue']
$config['project_id'],
$config['location'],
$queueName ?? $config['queue']
);
$client->purgeQueue($cloudQueueName);
$this->line("Queue {$namespaceName} is being purged.");
Expand Down
6 changes: 4 additions & 2 deletions src/Commands/QueueStatsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ class QueueStatsCommand extends QueueInteractionCommand
public function action(CloudTasksClient $client, string $namespaceName, string|null $queueName, array $config): int
{
$cloudQueueName = CloudTasksClient::queueName(
$config['project_id'], $config['location'], $queueName ?? $config['queue']
$config['project_id'],
$config['location'],
$queueName ?? $config['queue']
);
$cloudQueue = $client->getQueue($cloudQueueName, [
'readMask' => new FieldMask(['paths' => ['state', 'stats']])
'readMask' => new FieldMask(['paths' => ['state', 'stats']]),
]);
$stats = $cloudQueue->getStats();

Expand Down
4 changes: 3 additions & 1 deletion src/Commands/QueueStatusCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ public function action(CloudTasksClient $client, string $namespaceName, string|n
{
$shouldToggle = (bool) $this->option('toggle');
$cloudQueueName = CloudTasksClient::queueName(
$config['project_id'], $config['location'], $queueName ?? $config['queue']
$config['project_id'],
$config['location'],
$queueName ?? $config['queue']
);
$cloudQueue = $client->getQueue($cloudQueueName);
$this->line(sprintf(
Expand Down
4 changes: 3 additions & 1 deletion src/Commands/UpdateQueueCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ public function action(
CloudQueueModifier $queueModifier
): int {
$cloudQueueName = CloudTasksClient::queueName(
$config['project_id'], $config['location'], $queueName ?? $config['queue']
$config['project_id'],
$config['location'],
$queueName ?? $config['queue']
);
$cloudQueue = new Queue();
$cloudQueue->setName($cloudQueueName);
Expand Down
3 changes: 2 additions & 1 deletion src/Dispatchers/AppEngineDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ public function size($queue = null): int
{
$queueName = Client::queueName($this->projectId, $this->location, $queue);
$cloudQueue = $this->client->getQueue($queueName, [
'readMask' => new FieldMask(['paths' => ['stats.tasksCount']])
'readMask' => new FieldMask(['paths' => ['stats.tasksCount']]),
]);

return (int) $cloudQueue->getStats()->getTasksCount();
}
}
3 changes: 2 additions & 1 deletion src/Dispatchers/HttpDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ public function size($queue = null): int
{
$queueName = Client::queueName($this->projectId, $this->location, $queue);
$cloudQueue = $this->client->getQueue($queueName, [
'readMask' => new FieldMask(['paths' => ['stats.tasksCount']])
'readMask' => new FieldMask(['paths' => ['stats.tasksCount']]),
]);

return (int) $cloudQueue->getStats()->getTasksCount();
}
}
5 changes: 2 additions & 3 deletions src/Exceptions/CloudTasksQueueDoesNotExistException.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ public function __construct(protected string $connection, protected string $queu

public function getSolution(): Solution
{
return new class($this->connection, $this->queue) implements Solution {

return new class ($this->connection, $this->queue) implements Solution {
public function __construct(protected string $connection, protected string $queue)
{
}
Expand All @@ -39,7 +38,7 @@ public function getSolutionDescription(): string
public function getDocumentationLinks(): array
{
return [
'Google Cloud - Cloud Tasks - Creating Queues' => 'https://cloud.google.com/tasks/docs/creating-queues'
'Google Cloud - Cloud Tasks - Creating Queues' => 'https://cloud.google.com/tasks/docs/creating-queues',
];
}
};
Expand Down
3 changes: 1 addition & 2 deletions src/Exceptions/ServiceEmailNotSetException.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ public function __construct(protected string $connection, protected string $queu

public function getSolution(): Solution
{
return new class($this->connection) implements Solution {

return new class ($this->connection) implements Solution {
public function __construct(protected string $connection)
{
}
Expand Down
21 changes: 10 additions & 11 deletions tests/CommandsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@

namespace TradeCoverExchange\GoogleCloudTaskLaravel\Tests;

use Google\ApiCore\Page;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Tasks\V2beta3\Attempt;
use Google\Cloud\Tasks\V2beta3\CloudTasksClient;
use Google\Cloud\Tasks\V2beta3\Queue;
use Google\Cloud\Tasks\V2beta3\Queue\State;
use Google\Cloud\Tasks\V2beta3\QueueStats;
use Google\Cloud\Tasks\V2beta3\Task;
use Google\Protobuf\FieldMask;
use Google\Protobuf\Timestamp;
use Illuminate\Support\Carbon;
use Mockery\MockInterface;
Expand All @@ -32,7 +30,6 @@ public function setUp(): void
->withAnyArgs()
->once()
->andReturn($this->client);

});
}

Expand All @@ -51,7 +48,7 @@ public function testCreatingQueue()
->once();

$this->artisan('google:cloud:queue:create', [
'name' => 'http_cloud_tasks'
'name' => 'http_cloud_tasks',
])
->assertExitCode(0);
}
Expand All @@ -63,7 +60,7 @@ public function testDeletingQueue()
->once();

$this->artisan('google:cloud:queue:delete', [
'name' => 'http_cloud_tasks'
'name' => 'http_cloud_tasks',
])
->expectsQuestion('This action will delete all unfinished tasks permanently, do you wish to continue?', 'y')
->assertExitCode(0);
Expand All @@ -89,7 +86,7 @@ public function testPurgingQueue()
->once();

$this->artisan('google:cloud:queue:clear', [
'name' => 'http_cloud_tasks'
'name' => 'http_cloud_tasks',
])
->expectsQuestion('This action will delete all unfinished tasks permanently, do you wish to continue?', 'y')
->assertExitCode(0);
Expand Down Expand Up @@ -117,7 +114,7 @@ public function testUpdateQueue()
->once();

$this->artisan('google:cloud:queue:update', [
'name' => 'http_cloud_tasks'
'name' => 'http_cloud_tasks',
])
->assertExitCode(0);
}
Expand All @@ -131,7 +128,7 @@ public function testProvidingStats()

$this->client
->shouldReceive('getQueue')
->with('projects/test/locations/europe-west1/queues/default', \Mockery::on(fn($value) => is_array($value)))
->with('projects/test/locations/europe-west1/queues/default', \Mockery::on(fn ($value) => is_array($value)))
->andReturn($cloudQueue);

$cloudQueue->setState(Queue\State::RUNNING);
Expand All @@ -142,7 +139,7 @@ public function testProvidingStats()
$stats->setOldestEstimatedArrivalTime((new Timestamp())->setSeconds(now()->timestamp));

$this->artisan('google:cloud:queue:stats', [
'name' => 'http_cloud_tasks'
'name' => 'http_cloud_tasks',
])
->expectsTable([
'queue',
Expand Down Expand Up @@ -180,7 +177,7 @@ public function testProvidesTheQueueStatus()
$cloudQueue->setState(Queue\State::RUNNING);

$this->artisan('google:cloud:queue:status', [
'name' => 'http_cloud_tasks'
'name' => 'http_cloud_tasks',
])
->expectsOutput('Queue http_cloud_tasks:default is running')
->assertExitCode(0);
Expand Down Expand Up @@ -249,7 +246,9 @@ public function testRetrievesListOfTasks()
$paginated = \Mockery::mock(PagedListResponse::class)
->shouldReceive('iterateAllElements')
->andReturn(function () use ($tasks): \Generator {
foreach ($tasks as $task) yield $task;
foreach ($tasks as $task) {
yield $task;
}
})
->getMock();

Expand Down
9 changes: 3 additions & 6 deletions tests/MonitorCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
use Google\Cloud\Tasks\V2beta3\CloudTasksClient;
use Google\Cloud\Tasks\V2beta3\Queue;
use Google\Cloud\Tasks\V2beta3\QueueStats;
use Google\Protobuf\FieldMask;
use Illuminate\Queue\Console\MonitorCommand;
use Mockery\MockInterface;
use Orchestra\Testbench\TestCase;
use TradeCoverExchange\GoogleCloudTaskLaravel\CloudTaskServiceProvider;
Expand All @@ -26,7 +24,6 @@ public function setUp(): void
->withAnyArgs()
->once()
->andReturn($this->client);

});
}

Expand All @@ -37,17 +34,17 @@ public function testQueueWorksWithMonitorCommand()

$this->client
->shouldReceive('getQueue')
->with('projects/test/locations/europe-west1/queues/default', \Mockery::on(fn($value) => is_array($value)))
->with('projects/test/locations/europe-west1/queues/default', \Mockery::on(fn ($value) => is_array($value)))
->andReturn($cloudQueue);

$cloudQueue->setStats($stats);
$stats->setTasksCount(10);

$this->artisan('queue:monitor', [
'queues' => 'http_cloud_tasks:default'
'queues' => 'http_cloud_tasks:default',
])
->expectsTable(['Connection', 'Queue', 'Size', 'Status'], [[
'http_cloud_tasks', 'default', '10', 'OK'
'http_cloud_tasks', 'default', '10', 'OK',
]])
->assertExitCode(0);
}
Expand Down

0 comments on commit 4eee141

Please sign in to comment.