Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 40cbddf

Browse files
committed
Added negative test
1 parent 7b90a0c commit 40cbddf

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/test/java/com/spotify/github/v3/clients/RepositoryClientTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import static java.util.concurrent.CompletableFuture.completedFuture;
3535
import static org.hamcrest.MatcherAssert.assertThat;
3636
import static org.hamcrest.core.Is.is;
37+
import static org.junit.Assert.assertFalse;
3738
import static org.junit.Assert.assertTrue;
3839
import static org.mockito.ArgumentMatchers.any;
3940
import static org.mockito.Mockito.mock;
@@ -145,6 +146,15 @@ public void isCollaborator() throws Exception {
145146
assertTrue(isCollaborator);
146147
}
147148

149+
@Test
150+
public void isNotCollaborator() throws Exception {
151+
final Response response = mock(Response.class);
152+
when(response.code()).thenReturn(404);
153+
when(github.request("/repos/someowner/somerepo/collaborators/user")).thenReturn(completedFuture(response));
154+
boolean isCollaborator = repoClient.isCollaborator("user").get();
155+
assertFalse(isCollaborator);
156+
}
157+
148158
@Test
149159
public void listCommits() throws Exception {
150160
final CompletableFuture<List<CommitItem>> fixture =

0 commit comments

Comments
 (0)