@@ -8,6 +8,7 @@ import app.FactCodes
8
8
import app.hashers.CodeLine
9
9
import app.hashers.CodeLineAges
10
10
import app.hashers.CodeLongevity
11
+ import app.hashers.CommitCrawler
11
12
import app.hashers.RevCommitLine
12
13
import app.model.*
13
14
@@ -40,31 +41,32 @@ class ColleaguesTest : Spek({
40
41
val emails = hashSetOf(author1.email, author2.email)
41
42
42
43
val serverRepo = Repo (rehash = testRehash)
43
- val mockApi = MockApi (mockRepo = serverRepo)
44
-
45
- testRepo.createFile(fileName, listOf("line1", "line2"))
46
- testRepo.commit(message = "initial commit",
47
- author = author1,
48
- date = Calendar .Builder ().setTimeOfDay(0, 0, 0)
49
- .build().time)
50
-
51
- testRepo.deleteLines(fileName, 1, 1)
52
- testRepo.commit(message = "delete line",
53
- author = author1,
54
- date = Calendar .Builder ().setTimeOfDay(0, 1, 0)
55
- .build().time)
56
-
57
- testRepo.deleteLines(fileName, 0, 0)
58
- testRepo.commit(message = "delete line #2",
59
- author = author2,
60
- date = Calendar .Builder ().setTimeOfDay(0, 1, 0)
61
- .build().time)
62
-
63
- val cl = CodeLongevity (serverRepo, emails, testRepo.git)
64
- cl.updateFromObservable(onError = { _ -> fail("exception") },
65
- api = mockApi)
66
44
67
45
it("'t1'") {
46
+ val mockApi = MockApi (mockRepo = serverRepo)
47
+
48
+ testRepo.createFile(fileName, listOf("line1", "line2"))
49
+ testRepo.commit(message = "initial commit",
50
+ author = author1,
51
+ date = Calendar .Builder ().setTimeOfDay(0, 0, 0)
52
+ .build().time)
53
+
54
+ testRepo.deleteLines(fileName, 1, 1)
55
+ testRepo.commit(message = "delete line",
56
+ author = author1,
57
+ date = Calendar .Builder ().setTimeOfDay(0, 1, 0)
58
+ .build().time)
59
+
60
+ testRepo.deleteLines(fileName, 0, 0)
61
+ testRepo.commit(message = "delete line #2",
62
+ author = author2,
63
+ date = Calendar .Builder ().setTimeOfDay(0, 1, 0)
64
+ .build().time)
65
+
66
+ val cl = CodeLongevity (serverRepo, emails, testRepo.git)
67
+ cl.updateFromObservable(onError = { _ -> fail("exception") },
68
+ api = mockApi)
69
+
68
70
val triple1 = cl.colleagues.get(author1.email)[0 ]
69
71
assertEquals(triple1.first, author2.email,
70
72
"Wrong colleague email #1")
@@ -95,40 +97,39 @@ class ColleaguesTest : Spek({
95
97
val emails = hashSetOf(author1.email, author2.email)
96
98
97
99
val serverRepo = Repo (rehash = testRehash)
98
- val mockApi = MockApi (mockRepo = serverRepo)
99
-
100
- testRepo.createFile(fileName, listOf("line1", "line2"))
101
- testRepo.commit(message = "initial commit",
102
- author = author1,
103
- date = Calendar .Builder ().setTimeOfDay(0, 0, 0)
104
- .build().time)
105
-
106
- testRepo.deleteLines(fileName, 1, 1)
107
- testRepo.commit(message = "delete line",
108
- author = author2,
109
- date = Calendar .Builder ().setTimeOfDay(0, 1, 0)
110
- .build().time)
111
-
112
- testRepo.insertLines(fileName, 1, listOf("line in the end"))
113
- testRepo.commit(message = "insert line",
114
- author = author2,
115
- date = Calendar .Builder ().setTimeOfDay(0, 10, 0)
116
- .build().time)
117
-
118
- testRepo.deleteLines(fileName, 1, 1)
119
- testRepo.commit(message = "delete line #2",
120
- author = author1,
121
- date = Calendar .Builder ().setTimeOfDay(0, 20, 0)
122
- .build().time)
123
-
124
- CodeLongevity (serverRepo, emails, testRepo.git)
125
- .updateFromObservable(onError = { _ -> fail("exception") },
126
- api = mockApi)
127
100
128
101
it("'t1'") {
129
- for (f in mockApi.receivedFacts) {
130
- println(f)
131
- }
102
+ val mockApi = MockApi (mockRepo = serverRepo)
103
+
104
+ testRepo.createFile(fileName, listOf("line1", "line2"))
105
+ testRepo.commit(message = "initial commit",
106
+ author = author1,
107
+ date = Calendar .Builder ().setTimeOfDay(0, 0, 0)
108
+ .build().time)
109
+
110
+ testRepo.deleteLines(fileName, 1, 1)
111
+ testRepo.commit(message = "delete line",
112
+ author = author2,
113
+ date = Calendar .Builder ().setTimeOfDay(0, 1, 0)
114
+ .build().time)
115
+
116
+ testRepo.insertLines(fileName, 1, listOf("line in the end"))
117
+ testRepo.commit(message = "insert line",
118
+ author = author2,
119
+ date = Calendar .Builder ().setTimeOfDay(0, 10, 0)
120
+ .build().time)
121
+
122
+ testRepo.deleteLines(fileName, 1, 1)
123
+ testRepo.commit(message = "delete line #2",
124
+ author = author1,
125
+ date = Calendar .Builder ().setTimeOfDay(0, 20, 0)
126
+ .build().time)
127
+
128
+ CodeLongevity (serverRepo, emails, testRepo.git)
129
+ .updateFromObservable(
130
+ onError = { _ -> fail("exception") },
131
+ api = mockApi)
132
+
132
133
assertTrue(mockApi.receivedFacts.contains(
133
134
Fact (repo = serverRepo,
134
135
code = FactCodes .COLLEAGUES ,
0 commit comments