Skip to content

Commit

Permalink
Merge pull request #2 from placetopay-org/feature/project-is-optional
Browse files Browse the repository at this point in the history
Makes the project argument Optional
  • Loading branch information
eduarguz authored Apr 2, 2020
2 parents f1feab7 + 8874151 commit 20a3331
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Console/Commands/CreateVersionFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function handle(Factory $validator)
VersionFile::generate([
'sha' => $options['sha'],
'time' => $options['time'],
'project' => $options['project'],
'project' => $options['project']?? '',
'branch' => $options['branch'],
]);

Expand All @@ -58,7 +58,7 @@ private function validateOptions(Factory $validator)
return $validator->make($this->options(), [
'sha' => 'required',
'time' => 'required',
'project' => 'required',
'project' => 'nullable',
'branch' => 'required',
])->validate();
}
Expand Down
20 changes: 20 additions & 0 deletions tests/Commands/CreateVersionFileCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,26 @@ public function can_create_version_file()
$this->assertJsonStringEqualsJsonFile(VersionFile::path(), json_encode($input));
}

/** @test */
public function can_create_version_file_without_project_variable()
{
$input = [
'sha' => 'abcdef',
'time' => '20200315170330',
'branch' => 'master',
'project' => '',
];

$this->artisan('app-version:create', [
'--sha' => $input['sha'],
'--time' => $input['time'],
'--branch' => $input['branch'],
])->assertExitCode(0);

$this->assertFileExists(VersionFile::path());
$this->assertJsonStringEqualsJsonFile(VersionFile::path(), json_encode($input));
}

protected function tearDown(): void
{
VersionFile::delete();
Expand Down

0 comments on commit 20a3331

Please sign in to comment.