Skip to content

Commit

Permalink
formatting changes to test-get_gutenberg_data
Browse files Browse the repository at this point in the history
  • Loading branch information
francojc committed Aug 16, 2024
1 parent b89bbfa commit 8c897c1
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions tests/testthat/test-get_gutenberg_data.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

library(dplyr)

test_that("get_gutenberg_data function works correctly", {
Expand All @@ -19,15 +18,23 @@ test_that("get_gutenberg_data function works correctly", {
confirmed = confirmed
)
# Define the expected output file path
expected_file <- file.path(temp_dir, paste0("works_", tolower(lcc_subject), ".csv"))
expected_file <-
file.path(temp_dir, paste0("works_", tolower(lcc_subject), ".csv"))
# Check if the output file was created
expect_true(file.exists(expected_file))
# Read the output file
output_data <- read.csv(expected_file)
# Check if the output data has the expected number of rows
expect_equal(length(unique(output_data$gutenberg_id)), n_works)
# Check if the output data has the expected columns
expected_columns <- c("gutenberg_id", "lcc", "gutenberg_bookshelf", "gutenberg_author_id", "author", "title", "text")
expected_columns <-
c("gutenberg_id",
"lcc",
"gutenberg_bookshelf",
"gutenberg_author_id",
"author",
"title",
"text")
expect_equal(colnames(output_data), expected_columns)
file.remove(expected_file)
})

0 comments on commit 8c897c1

Please sign in to comment.