tests/testthat/test-add_metadata.R

test_that("metadata is added to content", {
  mocked_files_content <- dplyr::tibble(
    repo_name = c("TestRepo", "TestRepo"),
    repo_id = c("repo_id", "repo_id"),
    organization = c("org", "org"),
    file_path = c("file1.md", "file2.md"),
    file_content = c("test1", "test2"),
    file_size = c(1, 1),
    repo_url = c("test_URL", "test_URL"),
    api_url = c("test_URL", "test_URL")
  )
  result_with_metadata <- "result" |>
    test_mocker$use() |>
    add_metadata(
      content = mocked_files_content,
      timestamp = Sys.Date()
    )
  expect_true("metadata" %in% names(result_with_metadata))
  expect_type(result_with_metadata[["metadata"]], "list")
  expect_equal(names(result_with_metadata[["metadata"]]), c("repo_url", "files", "timestamp"))
})

Try the GitAI package in your browser

Any scripts or data that you put into this service are public.

GitAI documentation built on April 3, 2025, 7:57 p.m.