Skip to content

Commit

Permalink
Merge fde1086 into 1e7f4ea
Browse files Browse the repository at this point in the history
  • Loading branch information
eiriksm committed Jul 11, 2020
2 parents 1e7f4ea + fde1086 commit eb8d74d
Show file tree
Hide file tree
Showing 4 changed files with 282 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/fixtures/composer-concurrent.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"require": {
"psr/log": "^1.0.0",
"violinist-dev/violinist-config": "dev-master"
},
"extra": {
"violinist": {
"number_of_concurrent_updates": 1
}
}
}
97 changes: 97 additions & 0 deletions test/fixtures/composer-concurrent.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "0a52ecd537677c6b40e49be23e454791",
"packages": [
{
"name": "psr/log",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log.git",
"reference": "fe0936ee26643249e916849d48e3a51d5f5e278b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b",
"reference": "fe0936ee26643249e916849d48e3a51d5f5e278b",
"shasum": ""
},
"type": "library",
"autoload": {
"psr-0": {
"Psr\\Log\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interface for logging libraries",
"keywords": [
"log",
"psr",
"psr-3"
],
"time": "2012-12-21T11:40:51+00:00"
},
{
"name": "violinist-dev/violinist-config",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/violinist-dev/violinist-config.git",
"reference": "7df08914087a53b45f9131117006b9ecc2fa3166"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/violinist-dev/violinist-config/zipball/7df08914087a53b45f9131117006b9ecc2fa3166",
"reference": "7df08914087a53b45f9131117006b9ecc2fa3166",
"shasum": ""
},
"require-dev": {
"phpunit/phpunit": "^6.5",
"satooshi/php-coveralls": "^2.0",
"squizlabs/php_codesniffer": "^3.4"
},
"type": "library",
"autoload": {
"psr-4": {
"Violinist\\Config\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Eirik S. Morland",
"email": "eirik@morland.no"
}
],
"description": "Get violinist config from composer.json",
"time": "2020-07-10T15:43:41+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": {
"violinist-dev/violinist-config": 20
},
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
"plugin-api-version": "1.1.0"
}
106 changes: 106 additions & 0 deletions test/fixtures/composer-concurrent.lock-updated
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "0a52ecd537677c6b40e49be23e454791",
"packages": [
{
"name": "psr/log",
"version": "1.1.3",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log.git",
"reference": "0f73288fd15629204f9d42b7055f72dacbe811fc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/0f73288fd15629204f9d42b7055f72dacbe811fc",
"reference": "0f73288fd15629204f9d42b7055f72dacbe811fc",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.1.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Log\\": "Psr/Log/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interface for logging libraries",
"homepage": "https://github.com/php-fig/log",
"keywords": [
"log",
"psr",
"psr-3"
],
"time": "2020-03-23T09:12:05+00:00"
},
{
"name": "violinist-dev/violinist-config",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/violinist-dev/violinist-config.git",
"reference": "31bccb1862b490911d5cea0114cfdbba9fe6dbdb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/violinist-dev/violinist-config/zipball/31bccb1862b490911d5cea0114cfdbba9fe6dbdb",
"reference": "31bccb1862b490911d5cea0114cfdbba9fe6dbdb",
"shasum": ""
},
"require-dev": {
"phpunit/phpunit": "^6.5",
"satooshi/php-coveralls": "^2.0",
"squizlabs/php_codesniffer": "^3.4"
},
"type": "library",
"autoload": {
"psr-4": {
"Violinist\\Config\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Eirik S. Morland",
"email": "eirik@morland.no"
}
],
"description": "Get violinist config from composer.json",
"time": "2020-07-10T15:45:33+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": {
"violinist-dev/violinist-config": 20
},
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
"plugin-api-version": "1.1.0"
}
68 changes: 68 additions & 0 deletions test/integration/UpdatesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,74 @@ function ($cmd) use (&$called, $dir) {
$this->assertEquals(true, $called);
}

public function testUpdatesAvailableConcurrentLimit()
{
$c = $this->getMockCosy();
$dir = '/tmp/' . uniqid();
$this->setupDirectory($c, $dir);
$mock_definition = $this->getMockDefinition();
$mock_app = $this->getMockApp($mock_definition);
$c->setApp($mock_app);
$mock_output = $this->createMock(ArrayOutput::class);
$mock_output->method('fetch')
->willReturn([
[
sprintf('{"installed": [
{"name": "%s", "version": "%s", "latest": "%s", "latest-status": "semver-safe-update"},
{"name": "%s", "version": "%s", "latest": "%s", "latest-status": "semver-safe-update"}
]}', 'psr/log', '1.0.0', '1.0.3', 'violinist-dev/violinist-config', '1.0.0', '1.0.2'),
]
]);
$c->setOutput($mock_output);
$mock_executer = $this->getMockExecuterWithReturnCallback(
function ($cmd) use ($dir) {
$return = 0;
$expected_command = $this->createExpectedCommandForPackage('psr/log');
if ($cmd == $expected_command) {
file_put_contents("$dir/composer.lock", file_get_contents(__DIR__ . '/../fixtures/composer-concurrent.lock-updated'));
}
$expected_command = $this->createExpectedCommandForPackage('violinist-dev/violinist-config');
if ($cmd == $expected_command) {
file_put_contents("$dir/composer.lock", file_get_contents(__DIR__ . '/../fixtures/composer-concurrent.lock-updated'));
}
return $return;
}
);
$c->setExecuter($mock_executer);
$this->createComposerFileFromFixtures($dir, 'composer-concurrent.json');
// Then we are going to mock the provider factory.
$mock_provider_factory = $this->createMock(ProviderFactory::class);
$mock_provider = $this->createMock(Github::class);
$fake_pr_url = 'http://example.com/pr';
$slug = new Slug();
$slug->setProvider('github.com');
$slug->setSlug('a/b');
$mock_provider->expects($this->once())
->method('createPullRequest')
->willReturn([
'html_url' => $fake_pr_url,
]);
$mock_provider->method('repoIsPrivate')
->willReturn(true);
$mock_provider->method('getDefaultBranch')
->willReturn('master');
$mock_provider->method('getBranchesFlattened')
->willReturn([]);
$default_sha = 123;
$mock_provider->method('getDefaultBase')
->willReturn($default_sha);
$mock_provider->method('getPrsNamed')
->willReturn([]);
$mock_provider_factory->method('createFromHost')
->willReturn($mock_provider);
$composer_lock_contents = file_get_contents(__DIR__ . '/../fixtures/composer-concurrent.lock');
file_put_contents("$dir/composer.lock", $composer_lock_contents);
$c->setProviderFactory($mock_provider_factory);
$c->run();
$message = $this->findMessage('Skipping violinist-dev/violinist-config because the number of max concurrent PRs (1) seems to have been reached', $c);
$this->assertNotFalse($message);
}

public function testUpdateAvailableButUpdatedToOther()
{
$c = $this->getMockCosy();
Expand Down

0 comments on commit eb8d74d

Please sign in to comment.