From 798d7471647a5b242af347fcaa30b4a893fbe508 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 9 Feb 2024 13:38:17 +0100 Subject: [PATCH] add Docker run command parse test --- bootstrap/helpers/docker.php | 17 +++-------------- tests/Feature/DockerRunTest.php | 9 +++++++++ tests/Feature/ExampleTest.php | 7 ------- tests/Feature/ParseServiceTest.php | 7 ------- tests/Pest.php | 2 +- tests/Unit/ExampleTest.php | 5 ----- tests/Unit/RulesTest.php | 5 ----- 7 files changed, 13 insertions(+), 39 deletions(-) create mode 100644 tests/Feature/DockerRunTest.php delete mode 100644 tests/Feature/ExampleTest.php delete mode 100644 tests/Feature/ParseServiceTest.php delete mode 100644 tests/Unit/ExampleTest.php delete mode 100644 tests/Unit/RulesTest.php diff --git a/bootstrap/helpers/docker.php b/bootstrap/helpers/docker.php index 3ebec43b9..eb0898bfd 100644 --- a/bootstrap/helpers/docker.php +++ b/bootstrap/helpers/docker.php @@ -349,18 +349,8 @@ function convert_docker_run_to_compose(?string $custom_docker_run_options = null foreach ($matches as $match) { $option = $match[1]; $value = isset($match[2]) && $match[2] !== '' ? $match[2] : true; - if ($list_options->contains($option)) { - $value = explode(',', $value); - } - if (array_key_exists($option, $options)) { - if (is_array($options[$option])) { - $options[$option][] = $value; - } else { - $options[$option] = [$options[$option], $value]; - } - } else { - $options[$option] = $value; - } + $options[$option][] = $value; + $options[$option] = array_unique($options[$option]); } $options = collect($options); // Easily get mappings from https://github.com/composerize/composerize/blob/master/packages/composerize/src/mappings.js @@ -370,7 +360,7 @@ function convert_docker_run_to_compose(?string $custom_docker_run_options = null } if ($option === '--ulimit') { $ulimits = collect([]); - collect($value)->map(function ($ulimit) use ($ulimits){ + collect($value)->map(function ($ulimit) use ($ulimits) { $ulimit = explode('=', $ulimit); $type = $ulimit[0]; $limits = explode(':', $ulimit[1]); @@ -381,7 +371,6 @@ function convert_docker_run_to_compose(?string $custom_docker_run_options = null 'soft' => $soft_limit, 'hard' => $hard_limit ]); - } else { $soft_limit = $ulimit[1]; $ulimits->put($type, [ diff --git a/tests/Feature/DockerRunTest.php b/tests/Feature/DockerRunTest.php new file mode 100644 index 000000000..8821d1ad4 --- /dev/null +++ b/tests/Feature/DockerRunTest.php @@ -0,0 +1,9 @@ +toBe([ + 'cap_add' => ['NET_ADMIN', 'NET_RAW', 'SYS_ADMIN'], + ])->ray(); +}); diff --git a/tests/Feature/ExampleTest.php b/tests/Feature/ExampleTest.php deleted file mode 100644 index e07cdfb06..000000000 --- a/tests/Feature/ExampleTest.php +++ /dev/null @@ -1,7 +0,0 @@ -get('/api/health'); - - $response->assertStatus(200); -}); diff --git a/tests/Feature/ParseServiceTest.php b/tests/Feature/ParseServiceTest.php deleted file mode 100644 index a48119799..000000000 --- a/tests/Feature/ParseServiceTest.php +++ /dev/null @@ -1,7 +0,0 @@ -toBe(3); - }); diff --git a/tests/Pest.php b/tests/Pest.php index 50ab1e433..fa6dc801f 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -12,7 +12,7 @@ */ uses( - Tests\TestCase::class, + // Tests\TestCase::class, // Illuminate\Foundation\Testing\RefreshDatabase::class, )->in('Feature'); diff --git a/tests/Unit/ExampleTest.php b/tests/Unit/ExampleTest.php deleted file mode 100644 index 44a4f337a..000000000 --- a/tests/Unit/ExampleTest.php +++ /dev/null @@ -1,5 +0,0 @@ -toBeTrue(); -}); diff --git a/tests/Unit/RulesTest.php b/tests/Unit/RulesTest.php deleted file mode 100644 index 585e7126c..000000000 --- a/tests/Unit/RulesTest.php +++ /dev/null @@ -1,5 +0,0 @@ -expect(['dd', 'dump']) - ->not->toBeUsed();