/
GitHubRepoTest.php
54 lines (42 loc) · 1.46 KB
/
GitHubRepoTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
namespace Tests\Unit;
use App\Exceptions\GitHubException;
use App\GitHubRepo;
use Illuminate\Support\Facades\Http;
use Tests\TestCase;
class GitHubRepoTest extends TestCase
{
/** @test */
function requires_valid_url()
{
$this->expectException(GitHubException::class);
GitHubRepo::make('https://notgithub.com/starwars/lightsabers');
}
/** @test */
public function it_gets_the_latest_release_version_for_tagged_releases()
{
Http::fake([
'https://api.github.com/repos/starwars/lightsabers/releases' => Http::response(collect([
[
'name' => 'Release',
'tag_name' => 'v1.0',
],
])),
]);
$repo = GitHubRepo::make('https://github.com/starwars/lightsabers');
$this->assertEquals('v1.0', $repo->latestReleaseVersion());
}
/** @test */
public function it_falls_back_to_master_when_there_are_no_releases()
{
Http::fake(['https://api.github.com/repos/starwars/lightsabers/releases' => Http::response([])]);
$repo = GitHubRepo::make('https://github.com/starwars/lightsabers');
$this->assertEquals('master', $repo->latestReleaseVersion());
}
/** @test */
function it_returns_proper_readme_format()
{
$repo = GitHubRepo::make('https://github.com/starwars/lightsabers');
$this->assertEquals(GitHubRepo::README_FORMAT, $repo->readmeFormat());
}
}