From a4b79490d6492e7ec65e94f8ea910c6f5e427ab3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20L=C3=B6ffler?= Date: Wed, 16 Oct 2024 16:33:33 +0200 Subject: [PATCH] Test 'get.data.cut.to.same.date' in presence of an empty data source MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This test fails without the previous fix by Thomas Bock but does not fail when the fix is in place. This works towards fixing #269. Signed-off-by: Maximilian Löffler --- tests/test-data-cut.R | 55 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/tests/test-data-cut.R b/tests/test-data-cut.R index d1f3ef2ad..874839a82 100644 --- a/tests/test-data-cut.R +++ b/tests/test-data-cut.R @@ -82,3 +82,58 @@ test_that("Cut commit and mail data to same date range.", { expect_identical(mail.data, mail.data.expected, info = "Cut mail data.") }) + +test_that("Cut data to same date range with one empty data source.", { + + ## configurations + + proj.conf = ProjectConf$new(CF.DATA, CF.SELECTION.PROCESS, CASESTUDY, ARTIFACT) + proj.conf$update.value("issues.locked", TRUE) + data.sources = c("issues", "mails", "commits") + + ## construct objects + + x.data = ProjectData$new(proj.conf) + x.data$set.issues(NULL) + + commit.data.expected = data.frame(commit.id = sprintf("", c(32712, 32713)), + date = get.date.from.string(c("2016-07-12 15:58:59", "2016-07-12 16:00:45")), + author.name = c("Björn", "Olaf"), + author.email = c("bjoern@example.org", "olaf@example.org"), + committer.date = get.date.from.string(c("2016-07-12 15:58:59", "2016-07-20 10:00:44")), + committer.name = c("Björn", "Björn"), + committer.email = c("bjoern@example.org", "bjoern@example.org"), + hash = c("72c8dd25d3dd6d18f46e2b26a5f5b1e2e8dc28d0", "5a5ec9675e98187e1e92561e1888aa6f04faa338"), + changed.files = as.integer(c(1, 1)), + added.lines = as.integer(c(1, 1)), + deleted.lines = as.integer(c(1, 0)), + diff.size = as.integer(c(2, 1)), + file = c("test.c", "test.c"), + artifact = c("A", "A"), + artifact.type = c("Feature", "Feature"), + artifact.diff.size = as.integer(c(1, 1))) + + mail.data.expected = data.frame(author.name = c("Thomas", "Olaf"), + author.email = c("thomas@example.org", "olaf@example.org"), + message.id = c("<65a1sf31sagd684dfv31@mail.gmail.com>", "<9b06e8d20801220234h659c18a3g95c12ac38248c7e0@mail.gmail.com>"), + date = get.date.from.string(c("2016-07-12 16:04:40", "2016-07-12 16:05:37")), + date.offset = as.integer(c(100, 200)), + subject = c("Re: Fw: busybox 2 tab", "Re: Fw: busybox 10"), + thread = sprintf("", c("13#9", "13#9")), + artifact.type = c("Mail", "Mail")) + + issue.data.expected = create.empty.issues.list() + + commit.data = x.data$get.data.cut.to.same.date(data.sources = data.sources)$get.commits.unfiltered() + rownames(commit.data) = 1:nrow(commit.data) + + mail.data = x.data$get.data.cut.to.same.date(data.sources = data.sources)$get.mails() + rownames(mail.data) = 1:nrow(mail.data) + + issue.data = x.data$get.data.cut.to.same.date(data.sources = data.sources)$get.issues() + + expect_identical(commit.data, commit.data.expected, info = "Cut Raw commit data.") + expect_identical(mail.data, mail.data.expected, info = "Cut mail data.") + expect_identical(issue.data, issue.data.expected, info = "Cut issue data.") + +})