tests/testthat/test-check_can_create_screenlog_file.R

test_that("all is fine", {
  beast2_input_filename <- get_beastier_tempfilename()
  screenlog_filename <- get_beastier_tempfilename("screenlog")
  beautier::create_beast2_input_file_from_model(
    input_filename = beautier::get_beautier_path("test_output_0.fas"),
    output_filename = beast2_input_filename,
    inference_model = create_test_inference_model(
      mcmc = create_test_mcmc(
        screenlog = create_screenlog(filename = screenlog_filename)
      )
    )
  )
  beast2_options <- create_beast2_options(
    input_filename = beast2_input_filename
  )
  expect_silent(
    check_can_create_screenlog_file(beast2_options)
  )
  file.remove(beast2_input_filename)
})

test_that("use", {
  skip_on_os(os = "windows")

  beast2_input_filename <- get_beastier_tempfilename()
  beautier::create_beast2_input_file_from_model(
    input_filename = beautier::get_beautier_path("test_output_0.fas"),
    output_filename = beast2_input_filename,
    inference_model = create_test_inference_model(
      mcmc = create_test_mcmc(
        screenlog = create_screenlog(filename = "/cannot_write_to_root.trees")
      )
    )
  )
  beast2_options <- create_beast2_options(
    input_filename = beast2_input_filename
  )
  expect_error(
    check_can_create_screenlog_file(beast2_options),
    "Cannot create screenlog file"
  )
  file.remove(beast2_input_filename)
})
richelbilderbeek/beastier documentation built on Nov. 8, 2023, 9:29 p.m.