Skip to content
Snippets Groups Projects
Unverified Commit 18c30f8f authored by Petar Bašić's avatar Petar Bašić Committed by Lee Rowlands
Browse files

Issue #3219061 by petar_basic, larowlan: Generic frontend environment does not...

Issue #3219061 by petar_basic, larowlan: Generic frontend environment does not regard 201 response as triggered deploy
parent c2164da7
Branches
Tags 3.2.0
No related merge requests found
Showing
with 76 additions and 17 deletions
......@@ -8,3 +8,8 @@ package: 'Build hooks'
dependencies:
- drupal:views
- dynamic_entity_reference:dynamic_entity_reference
# Information added by Drupal.org packaging script on 2021-05-20
version: '3.1.4'
project: 'build_hooks'
datestamp: 1621488841
......@@ -53,3 +53,10 @@ build_hooks.frontend_environment.plugin_settings:
provider:
type: string
label: 'Provider'
frontend_environment.settings.generic:
type: build_hooks.frontend_environment.plugin_settings
mapping:
build_hook_url:
type: string
label: 'Build hook URL'
......@@ -6,3 +6,8 @@ core_version_requirement: ^8 || ^9
package: 'Build hooks'
dependencies:
- drupal:build_hooks
# Information added by Drupal.org packaging script on 2021-05-20
version: '3.1.4'
project: 'build_hooks'
datestamp: 1621488841
......@@ -2,16 +2,8 @@
namespace Drupal\Tests\build_hooks_bitbucket\Kernel;
use Drupal\build_hooks\Entity\FrontendEnvironment;
use Drupal\build_hooks\TriggerInterface;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\KernelTests\KernelTestBase;
use Drupal\Tests\build_hooks\Kernel\BuildHooksKernelTestBase;
use GuzzleHttp\Client;
use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Middleware;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;
/**
......@@ -19,8 +11,7 @@ use GuzzleHttp\Psr7\Response;
*
* @group build_hooks_bitbucket
*/
class BitbucketBuildHooksTest extends BuildHooksKernelTestBase
{
class BitbucketBuildHooksTest extends BuildHooksKernelTestBase {
/**
* {@inheritdoc}
......@@ -105,5 +96,4 @@ class BitbucketBuildHooksTest extends BuildHooksKernelTestBase
];
}
}
......@@ -6,3 +6,8 @@ core_version_requirement: ^8 || ^9
package: 'Build hooks'
dependencies:
- drupal:build_hooks
# Information added by Drupal.org packaging script on 2021-05-20
version: '3.1.4'
project: 'build_hooks'
datestamp: 1621488841
......@@ -6,7 +6,7 @@
*/
/**
* Update circleci configuration
* Update circleci configuration.
*/
function build_hooks_circleci_update_8201(&$sandbox) {
$config_factory = \Drupal::configFactory();
......
......@@ -6,3 +6,8 @@ core_version_requirement: ^8 || ^9
package: 'Build hooks'
dependencies:
- drupal:build_hooks
# Information added by Drupal.org packaging script on 2021-05-20
version: '3.1.4'
project: 'build_hooks'
datestamp: 1621488841
......@@ -6,7 +6,7 @@
*/
/**
* Update netlify configuration
* Update netlify configuration.
*/
function build_hooks_netlify_update_8201(&$sandbox) {
$config_factory = \Drupal::configFactory();
......
......@@ -21,7 +21,7 @@ class GenericFrontendEnvironment extends FrontendEnvironmentBase {
* {@inheritdoc}
*/
public function defaultConfiguration() {
return [] + parent::defaultConfiguration();
return ['build_hook_url' => ''] + parent::defaultConfiguration();
}
/**
......
......@@ -192,7 +192,7 @@ abstract class FrontendEnvironmentBase extends PluginBase implements FrontendEnv
* {@inheritdoc}
*/
public function deploymentWasTriggered(ResponseInterface $response): bool {
return $response->getStatusCode() === 200;
return in_array($response->getStatusCode(), [200, 201], FALSE);
}
/**
......
......@@ -4,3 +4,8 @@ package: Testing
type: module
dependencies:
- build_hooks:build_hooks
# Information added by Drupal.org packaging script on 2021-05-20
version: '3.1.4'
project: 'build_hooks'
datestamp: 1621488841
......@@ -84,7 +84,7 @@ abstract class BuildHooksKernelTestBase extends KernelTestBase {
* Expected URL.
* @param array $settings
* Plugin settings.
* @param Response $mockResponse
* @param \GuzzleHttp\Psr7\Response $mockResponse
* Response object to be returned by the mocked http-client.
* @param string|null $entity_label
* Entity label to use.
......@@ -97,7 +97,7 @@ abstract class BuildHooksKernelTestBase extends KernelTestBase {
string $deployment_strategy,
string $expected_url = NULL,
array $settings = [],
Response $mockResponse = null,
Response $mockResponse = NULL,
string $entity_label = NULL
) : ?Request {
$response = $mockResponse ?? new Response(200, [], 'Hello, World');
......
......@@ -3,6 +3,7 @@
namespace Drupal\Tests\build_hooks\Kernel;
use Drupal\build_hooks\TriggerInterface;
use GuzzleHttp\Psr7\Response;
/**
* Defines a class for testing plugins can prevent builds.
......@@ -49,4 +50,40 @@ class BuildTriggerTest extends BuildHooksKernelTestBase {
);
}
/**
* Tests generic front-end environment deployments.
*
* @dataProvider providerFrontendEnvironment
*/
public function testGenericFrontendEnvironment(string $deployment_strategy = TriggerInterface::DEPLOYMENT_STRATEGY_MANUAL) {
$this->assertFrontendEnvironmentBuildHook(
'generic',
$deployment_strategy,
'http://example.com?foo=bar',
[
'build_hook_url' => 'http://example.com?foo=bar',
],
new Response(201, [], 'Hello, Generic'));
}
/**
* Provider for ::testFrontendEnvironment.
*
* @return array[]
* Test cases.
*/
public function providerFrontendEnvironment() {
return [
'Entity save' => [
TriggerInterface::DEPLOYMENT_STRATEGY_ENTITYSAVE,
],
'Cron' => [
TriggerInterface::DEPLOYMENT_STRATEGY_CRON,
],
'Manual' => [
TriggerInterface::DEPLOYMENT_STRATEGY_MANUAL,
],
];
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment