tests/testthat/test-calculate_cow_liveweight.R

test_that("testing function calculate_cow_liveweight()", {

  s_input_file_flp <- file.path(here::here(),"inst","extdata","ewbc","test","test_zws_muku_flp.csv")
  s_start_flp_date <- 20050101
  s_end_flp_date <- 20211231
  b_log <- TRUE
  s_input_file_ped <- file.path(here::here(),"inst","extdata","ewbc","test","test_pedigree.txt")
  s_dambreed <- "LM"
  tbl_flp <- read_file_input_flp(ps_input_file_flp = s_input_file_flp,
                                 ps_start_flp_date = s_start_flp_date,
                                 ps_end_flp_date = s_end_flp_date,
                                 pb_log = b_log)
  tbl_ped <- read_file_input_ped(ps_input_file_ped = s_input_file_ped,
                                 pb_log = b_log)
  ### # Merge progeny-flp data and pedigree files
  tbl_merged_data <- tbl_flp %>% dplyr::inner_join(tbl_ped, by = c("NakoTVD" = "TVDid"))


  mature_weight_cow_expected <- 751
  mature_weight_cow <- calculate_cow_liveweight(ps_input_flp_tibble = tbl_merged_data,
                                                ps_first_calvingweight = FALSE,
                                                ps_second_calvingweight = FALSE,
                                                ps_dambreed = s_dambreed,
                                                pb_log = b_log)
  expect_equal(mature_weight_cow, mature_weight_cow_expected)



})
sknqualitasag/qp4ewc documentation built on Sept. 27, 2022, 3:31 p.m.