Skip to content

Commit

Permalink
Add a test for default branches from config (#224)
Browse files Browse the repository at this point in the history
* Add a test for default branches from config

* Try to trigger CI
  • Loading branch information
eiriksm committed Sep 24, 2021
1 parent b9fd494 commit 21bd0c4
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/fixtures/composer-develop.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extra": {
"violinist": {
"default_branch": "develop"
}
},
"require": {
"psr/log": "^1.0.0"
}
}
61 changes: 61 additions & 0 deletions test/fixtures/composer-develop.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"_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": "12419b18b7f2a646b445f66a758bab4a",
"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"
],
"support": {
"issues": "https://github.com/php-fig/log/issues",
"source": "https://github.com/php-fig/log/tree/1.0.0"
},
"time": "2012-12-21T11:40:51+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
"plugin-api-version": "2.1.0"
}
7 changes: 7 additions & 0 deletions test/fixtures/composer-master.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extra": {
"violinist": {
"default_branch": "develop"
}
}
}
18 changes: 18 additions & 0 deletions test/fixtures/composer-master.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"_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": "f9f1f63b110b9e511d7f794f53c7816b",
"packages": [],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
"plugin-api-version": "2.1.0"
}
42 changes: 42 additions & 0 deletions test/integration/ConfigBranchOrderTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace eiriksm\CosyComposerTest\integration;

/**
* Test for a default commit message.
*/
class ConfigBranchOrderTest extends ComposerUpdateIntegrationBase
{
protected $packageForUpdateOutput = 'psr/log';
protected $packageVersionForFromUpdateOutput = '1.0.0';
protected $packageVersionForToUpdateOutput = '1.0.2';

public function setUp()
{
parent::setUp();
$this->createComposerFileFromFixtures($this->dir, 'composer-master.json');
}

public function testUpdateInCorrectBranch()
{
$this->runtestExpectedOutput();
// Since we don't place the updated composer.lock file, we fully expect the package to not be updated.
// This might also of course be the case for the actual bug we are testing here, but since we already know that
// the lock file in master contains no packages, then this demonstrates that this bug prevents the config branch
// files from being read. Totally.
$this->assertOutputContainsMessage('psr/log was not updated running composer update', $this->cosy);
}

protected function handleExecutorReturnCallback($cmd, &$return)
{
if ($cmd === 'git checkout develop') {
$this->createComposerFileFromFixtures($this->dir, 'composer-develop.json');
$this->placeComposerLockContentsFromFixture('composer-develop.lock', $this->dir);
}
}

protected function placeInitialComposerLock()
{
$this->placeComposerLockContentsFromFixture('composer-master.lock', $this->dir);
}
}

0 comments on commit 21bd0c4

Please sign in to comment.