1
2
3
4
5 package com.jcabi.github.mock;
6
7 import com.jcabi.github.PullRef;
8 import com.jcabi.github.Repo;
9 import java.io.IOException;
10 import org.hamcrest.MatcherAssert;
11 import org.hamcrest.Matchers;
12 import org.junit.jupiter.api.Test;
13
14
15
16
17
18 final class MkPullRefTest {
19
20
21
22 private static final String REF = "awesome-branch";
23
24
25
26
27 private static final String SHA =
28 "361bb23ed4c028914d45d53c3727c48b035ee643";
29
30
31
32
33 private static final String USERNAME = "myrtle";
34
35
36
37
38
39 @Test
40 void fetchesRepo() throws IOException {
41 final MkStorage storage = new MkStorage.InFile();
42 final Repo repo = new MkGitHub(storage, MkPullRefTest.USERNAME)
43 .randomRepo();
44 MatcherAssert.assertThat(
45 "Values are not equal",
46 MkPullRefTest.pullRef(storage, repo).repo().coordinates(),
47 Matchers.equalTo(repo.coordinates())
48 );
49 }
50
51
52
53
54
55 @Test
56 void fetchesRef() throws IOException {
57 MatcherAssert.assertThat(
58 "Values are not equal",
59 MkPullRefTest.pullRef().ref(),
60 Matchers.equalTo(MkPullRefTest.REF)
61 );
62 }
63
64
65
66
67
68 @Test
69 void fetchesSha() throws IOException {
70 MatcherAssert.assertThat(
71 "Values are not equal",
72 MkPullRefTest.pullRef().sha(),
73 Matchers.equalTo(MkPullRefTest.SHA)
74 );
75 }
76
77
78
79
80
81
82 private static PullRef pullRef() throws IOException {
83 final MkStorage storage = new MkStorage.InFile();
84 return new MkPullRef(
85 storage,
86 ((MkBranches) new MkGitHub(storage, MkPullRefTest.USERNAME)
87 .randomRepo()
88 .branches()).create(MkPullRefTest.REF, MkPullRefTest.SHA)
89 );
90 }
91
92
93
94
95
96
97
98
99 private static PullRef pullRef(
100 final MkStorage storage,
101 final Repo repo
102 ) throws IOException {
103 return new MkPullRef(
104 storage,
105 ((MkBranches) repo.branches())
106 .create(MkPullRefTest.REF, MkPullRefTest.SHA)
107 );
108 }
109 }