|
2 | 2 |
|
3 | 3 | namespace Laravel\VaporCli\Tests;
|
4 | 4 |
|
| 5 | +use Illuminate\Container\Container; |
5 | 6 | use Laravel\VaporCli\Docker;
|
6 | 7 | use PHPUnit\Framework\TestCase;
|
| 8 | +use Symfony\Component\Yaml\Yaml; |
7 | 9 |
|
8 | 10 | class DockerTest extends TestCase
|
9 | 11 | {
|
| 12 | + protected function setUp(): void |
| 13 | + { |
| 14 | + parent::setUp(); |
| 15 | + touch($testManifest = getcwd().'/test.vapor.yml'); |
| 16 | + Container::getInstance()->offsetSet('manifest', $testManifest); |
| 17 | + } |
| 18 | + |
| 19 | + protected function tearDown(): void |
| 20 | + { |
| 21 | + @unlink(Container::getInstance()->offsetGet('manifest')); |
| 22 | + parent::tearDown(); |
| 23 | + } |
| 24 | + |
10 | 25 | public function test_build_command_no_build_args()
|
11 | 26 | {
|
12 | 27 | $command = Docker::buildCommand('my-project', 'production', [], []);
|
@@ -41,4 +56,21 @@ public function test_build_command_cli_and_manifest_build_args()
|
41 | 56 | "--build-arg='FOO=BAR' --build-arg='FIZZ=BAZZ' --build-arg='BAR=FOO' .";
|
42 | 57 | $this->assertEquals($expectedCommand, $command);
|
43 | 58 | }
|
| 59 | + |
| 60 | + public function test_dockerfile_from_manifest() |
| 61 | + { |
| 62 | + file_put_contents(Container::getInstance()->offsetGet('manifest'), Yaml::dump([ |
| 63 | + 'id' => 1, |
| 64 | + 'name' => 'Test', |
| 65 | + 'environments' => [ |
| 66 | + 'production' => [ |
| 67 | + 'runtime' => 'docker', |
| 68 | + 'dockerfile' => 'docker/shared.Dockerfile', |
| 69 | + ], |
| 70 | + ], |
| 71 | + ])); |
| 72 | + $command = Docker::buildCommand('my-project', 'production', [], []); |
| 73 | + $expectedCommand = 'docker build --pull --file=docker/shared.Dockerfile --tag=my-project:production .'; |
| 74 | + $this->assertEquals($expectedCommand, $command); |
| 75 | + } |
44 | 76 | }
|
0 commit comments