test_that("The new data must be a data frame", { expect_error( SSCD2( newData = 1, currentData = tibble()) ) }) test_that("The current data must be a data frame", { expect_error( SSCD2( newData = tibble(), currentData = 1) ) }) test_that("The function must output as expected", { currentData_ <- tibble::tribble( ~id, ~colA, ~colB, ~colC, 1, "a1", "b1", "c1", 2, "a2", "b2", "c2", 3, "a3", "b3", "c3" ) currentData_ <- .activate(dataframe = currentData_) newData_ <- tibble::tribble( ~id, ~colA, ~colB, ~colC, 1, "a1", "b1", "c1", # Identical row. 2, "a2", "b2", "c20", # Almost identical row. 3, "a4", "b4", "c4" # Different row. ) mergedData_ <- SSCD2(newData = newData_, currentData = currentData_) expectedResult_ <- tibble::tribble( ~id, ~colA, ~colB, ~colC, ~IS_ACTIVE, 1, "a1", "b1", "c1", FALSE, 2, "a2", "b2", "c2", FALSE, 3, "a3", "b3", "c3", FALSE, 1, "a1", "b1", "c1", TRUE, 2, "a2", "b2", "c20", TRUE, 3, "a4", "b4", "c4", TRUE) |> dplyr::arrange(id) arrangedMergedData_ <- mergedData_ |> dplyr::select(-ends_with("DATE")) |> dplyr::arrange(id) expect_equal(expectedResult_, arrangedMergedData_) })