@@ -486,4 +486,60 @@ class CodeLongevityTest : Spek({
486486 testRepo.destroy()
487487 }
488488 }
489+
490+ given("'longevity stats #2'") {
491+ val testRepoPath = " ../CodeLongevity_lngstats2"
492+ val testRepo = TestRepo (testRepoPath)
493+ val testRehash = " rehash_lngstats1"
494+ val fileName = " test1.txt"
495+ val author1 = Author (testRepo.userName, testRepo.userEmail)
496+ val author2 =
Author ("
Vasya Pupkin ", "
[email protected] ")
497+ val emails = hashSetOf(author1.email, author2.email)
498+
499+ var serverRepo = Repo (rehash = testRehash)
500+ val mockApi = MockApi (mockRepo = serverRepo)
501+
502+ testRepo.createFile(fileName, listOf("line1", "line2"))
503+ testRepo.commit(message = "initial commit",
504+ author = author1,
505+ date = Calendar .Builder ().setTimeOfDay(0, 0, 0).build().time)
506+
507+ testRepo.deleteLines(fileName, 1, 1)
508+ testRepo.commit(message = "delete line",
509+ author = author2,
510+ date = Calendar .Builder ().setTimeOfDay(0, 1, 0).build().time)
511+
512+ CodeLongevity (serverRepo, emails, testRepo.git,
513+ { _ -> fail("exception") }).updateStats(mockApi)
514+
515+ it("'t1'") {
516+ println(mockApi.receivedFacts)
517+ assertTrue(mockApi.receivedFacts.contains(
518+ Fact (repo = serverRepo,
519+ code = FactCodes .LINE_LONGEVITY_REPO ,
520+ value = (60).toString())
521+ ))
522+
523+ assertTrue(mockApi.receivedFacts.contains(
524+ Fact (repo = serverRepo,
525+ code = FactCodes .LINE_LONGEVITY ,
526+ author = author1,
527+ value = (60).toString())
528+ ))
529+
530+ assertTrue(mockApi.receivedFacts.contains(
531+ Fact (repo = serverRepo,
532+ code = FactCodes .LINE_LONGEVITY ,
533+ author = author2,
534+ value = (0).toString())
535+ ))
536+ }
537+
538+ afterGroup {
539+ CodeLongevity (
540+ Repo (rehash = testRehash), emails, testRepo.git,
541+ { _ -> fail("exception") }).dropSavedData()
542+ testRepo.destroy()
543+ }
544+ }
489545})
0 commit comments