Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Integration/Fastly/FastlyServiceUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ public function __invoke(PostDeploy $event): void

$io = new SymfonyStyle(new ArgvInput(), $event->output);

if (EnvironmentHelper::getVariable('FASTLY_DISABLE_SNIPPET_UPDATE') === '1') {
$io->info('FASTLY_DISABLE_SNIPPET_UPDATE is set. Skipping Fastly service update.');

return;
}

if ($apiToken === '' || $serviceId === '') {
$io->info('FASTLY_API_TOKEN or FASTLY_SERVICE_ID is not set. Skipping Fastly service update.');

Expand Down
22 changes: 22 additions & 0 deletions tests/Integration/Fastly/FastlyServiceUpdaterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,28 @@ public function testDoesNothingWithoutFastlyApiToken(): void
$fs->remove($tmpDir);
}

#[Env('FASTLY_API_TOKEN', 'API_TOKEN')]
#[Env('FASTLY_SERVICE_ID', 'SERVICE_ID')]
#[Env('FASTLY_DISABLE_SNIPPET_UPDATE', '1')]
public function testDoesNothingWhenDisabledViaEnv(): void
{
$fastlyAPIClient = $this->createMock(FastlyAPIClient::class);
$fastlyAPIClient
->expects($this->never())
->method('setApiKey');

$fs = new Filesystem();
$tmpDir = sys_get_temp_dir() . '/' . uniqid('fastly-test-', true);

$fs->mkdir($tmpDir . '/config/fastly');

$updater = new FastlyServiceUpdater($tmpDir, $fastlyAPIClient);

$updater(new PostDeploy(new RunConfiguration(), new NullOutput()));

$fs->remove($tmpDir);
}

#[Env('FASTLY_API_TOKEN', 'API_TOKEN')]
#[Env('FASTLY_SERVICE_ID', 'SERVICE_ID')]
public function testCreateSnippet(): void
Expand Down