|
1 | 1 | package org.kohsuke.github; |
2 | 2 |
|
3 | | -import junit.framework.TestCase; |
| 3 | +import org.junit.Before; |
| 4 | +import org.junit.Test; |
4 | 5 |
|
5 | 6 | import java.util.List; |
6 | | -import java.util.UUID; |
7 | 7 |
|
8 | 8 | /** |
9 | 9 | * Integration test for {@link GHContent}. |
10 | 10 | */ |
11 | | -public class GHContentIntegrationTest extends TestCase { |
| 11 | +public class GHContentIntegrationTest extends AbstractGitHubApiTestBase { |
12 | 12 |
|
13 | | - private GitHub gitHub; |
14 | 13 | private GHRepository repo; |
15 | | - private String createdFilename; |
| 14 | + private String createdFilename = rnd.next(); |
16 | 15 |
|
| 16 | + @Before |
17 | 17 | @Override |
18 | 18 | public void setUp() throws Exception { |
19 | 19 | super.setUp(); |
20 | | - |
21 | | - gitHub = GitHub.connect(); |
22 | | - repo = gitHub.getRepository("acollign/github-api-test").fork(); |
23 | | - createdFilename = UUID.randomUUID().toString(); |
| 20 | + repo = gitHub.getRepository("github-api-test-org/github-api-test").fork(); |
24 | 21 | } |
25 | 22 |
|
| 23 | + @Test |
26 | 24 | public void testGetFileContent() throws Exception { |
27 | 25 | GHContent content = repo.getFileContent("ghcontent-ro/a-file-with-content"); |
28 | 26 |
|
29 | 27 | assertTrue(content.isFile()); |
30 | 28 | assertEquals("thanks for reading me\n", content.getContent()); |
31 | 29 | } |
32 | 30 |
|
| 31 | + @Test |
33 | 32 | public void testGetEmptyFileContent() throws Exception { |
34 | 33 | GHContent content = repo.getFileContent("ghcontent-ro/an-empty-file"); |
35 | 34 |
|
36 | 35 | assertTrue(content.isFile()); |
37 | 36 | assertEquals("", content.getContent()); |
38 | 37 | } |
39 | 38 |
|
| 39 | + @Test |
40 | 40 | public void testGetDirectoryContent() throws Exception { |
41 | 41 | List<GHContent> entries = repo.getDirectoryContent("ghcontent-ro/a-dir-with-3-entries"); |
42 | 42 |
|
43 | 43 | assertTrue(entries.size() == 3); |
44 | 44 | } |
45 | 45 |
|
| 46 | + @Test |
46 | 47 | public void testCRUDContent() throws Exception { |
47 | 48 | GHContentUpdateResponse created = repo.createContent("this is an awesome file I created\n", "Creating a file for integration tests.", createdFilename); |
48 | 49 | GHContent createdContent = created.getContent(); |
|
0 commit comments