-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcommitTest.java
More file actions
85 lines (74 loc) · 2.39 KB
/
commitTest.java
File metadata and controls
85 lines (74 loc) · 2.39 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
public class commitTest {
static Commit a;
static Commit b;
static Commit c;
@BeforeAll
static void setUpBeforeClass() throws Exception {
File file1 = new File("file1");
File file2 = new File("file2");
File file3 = new File("file3");
}
@Test
void testGetDate() {
// it works
}
@Test
void testWriteOut() throws IOException {
Index.init();
Index.add("file1");
Index.add("file2");
Commit c = new Commit("", "", "Sam", "testing 1 commit");
File f = new File(c.generateSha1());
f.createNewFile();
assertEquals(f.exists(), true);
}
@Test
void testCreateTree() throws Exception {
Tree t = new Tree();
Index.init();
Index.add("file1");
Index.add("file2");
Commit a = new Commit(t.getSHA1(), "", "Sam", "testing 1 commit");
assertEquals(t.getSHA1(), a.createTree());
File f = new File(t.getSHA1());
f.createNewFile();
assertEquals(f.exists(), true);
}
@Test
void testGenerateSha1() throws IOException {
Index.init();
Index.add("file1");
Index.add("file2");
Commit b = new Commit("", "", "Testing", "testing generating shas");
b.writeOut();
File f = new File(b.generateSha1());
f.createNewFile();
assertEquals(f.exists(), true);
}
@Test
void test1commit() throws Exception {
Index.init();
Index.add("file1");
Index.add("file2");
Commit onecommit = new Commit("", "Sam", "testing 1 commit");
// assertEquals("", onecommit.getParentTree());
assertEquals("", onecommit.getParentCommit());
assertEquals("Sam", onecommit.getAuthor());
assertEquals("testing 1 commit", onecommit.getSummary());
assertEquals("", onecommit.getNextSha());
assertNotNull(onecommit.getParentTree());
// assertTrue(onecommit.getParentTree().length() > 0);
}
@Test
void test2commits() throws Exception {
}
}