Skip to content

Commit

Permalink
Make it possible to always allow direct deps (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
eiriksm authored Mar 17, 2023
1 parent 9d45736 commit 6fc48dd
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public function getDefaultConfig()
{
return (object) [
'always_update_all' => 0,
'always_allow_direct_dependencies' => 0,
'allow_list' => [],
'update_dev_dependencies' => 1,
'check_only_direct_dependencies' => 1,
Expand Down Expand Up @@ -87,6 +88,11 @@ public function getLabelsSecurity() : array
return $this->config->labels_security;
}

public function shouldAlwaysAllowDirect() : bool
{
return (bool) $this->config->always_allow_direct_dependencies;
}

public function hasConfigForKey($key)
{
return !empty($this->configOptionsSet[$key]);
Expand Down
41 changes: 41 additions & 0 deletions tests/UnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ protected function runTestExpectedResultFromFixture($filename, $expected_result,
self::assertEquals($expected_result, $data->{$method}());
}

/**
* Test the different things we can set in always allow direct.
*
* @dataProvider getAlwaysAllowDirect
*/
public function testAlwaysDirect($filename, $expected_result)
{
$data = $this->createDataFromFixture($filename);
self::assertEquals($expected_result, $data->shouldAlwaysAllowDirect());
}

/**
* Test the different things we can set in run scripts, and what we expect from it.
*
Expand Down Expand Up @@ -741,6 +752,36 @@ public function emptyConfigs()
];
}

public function getAlwaysAllowDirect()
{
return [
[
'empty.json',
false,
],
[
'always_allow_direct_dependencies.json',
true
],
[
'always_allow_direct_dependencies2.json',
true
],
[
'always_allow_direct_dependencies3.json',
true
],
[
'always_allow_direct_dependencies4.json',
false
],
[
'always_allow_direct_dependencies5.json',
false
],
];
}

public function getRunScriptData()
{
return [
Expand Down
7 changes: 7 additions & 0 deletions tests/fixtures/always_allow_direct_dependencies.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extra": {
"violinist": {
"always_allow_direct_dependencies": "yes_of_course_this_should_be_an_int_but_this_evaluates_to_true"
}
}
}
7 changes: 7 additions & 0 deletions tests/fixtures/always_allow_direct_dependencies2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extra": {
"violinist": {
"always_allow_direct_dependencies": 1
}
}
}
7 changes: 7 additions & 0 deletions tests/fixtures/always_allow_direct_dependencies3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extra": {
"violinist": {
"always_allow_direct_dependencies": "1"
}
}
}
7 changes: 7 additions & 0 deletions tests/fixtures/always_allow_direct_dependencies4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extra": {
"violinist": {
"always_allow_direct_dependencies": "0"
}
}
}
7 changes: 7 additions & 0 deletions tests/fixtures/always_allow_direct_dependencies5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extra": {
"violinist": {
"always_allow_direct_dependencies": 0
}
}
}

0 comments on commit 6fc48dd

Please sign in to comment.