import/export functions handle errors gracefully

Error in `boilerplate_export(db = test_db, data_path = temp_dir, output_file = "preserved.rds", 
    quiet = TRUE, confirm = FALSE)`: Directory does not exist: D:\temp\2025_06_12_16_45_17_25820\RtmpwPIMz6\file2dbac3bce7e4a/projects/default/data. Set create_dirs=TRUE to create it.

Error in `boilerplate_import(data_path = test_data_dir, quiet = TRUE)`: Data path does not exist: D:\temp\2025_06_12_16_45_17_25820\RtmpwPIMz6/test_json_import/projects/default/data

test_that("read_boilerplate_db can read both JSON and RDS formats", {
db_from_rds <- boilerplate:::read_boilerplate_db(temp_rds, format = "rds")
temp_json <- tempfile(fileext = ".json")
jsonlite::write_json(test_db, temp_json, auto_unbox = TRUE)
db_from_json <- boilerplate:::read_boilerplate_db(temp_json, format = "json")
test_that("write_boilerplate_db can write both JSON and RDS formats", {
boilerplate:::write_boilerplate_db(test_db, rds_path, format = "rds")
boilerplate:::write_boilerplate_db(test_db, json_path, format = "json")
base_path2 <- file.path(temp_dir, "test_db2.rds")  # Provide extension for both
boilerplate:::write_boilerplate_db(test_db, base_path2, format = "both")
unlink(list.files(temp_dir, pattern = "test_db", full.names = TRUE))
test_that("boilerplate_import handles JSON files", {
# Test importing specific category - returns unwrapped content
# When importing single category, it returns the content directly
test_that("boilerplate_save handles JSON format", {
json_files <- list.files(test_data_dir, pattern = "\\.json$")
test_that("boilerplate_rds_to_json converts files correctly", {
result <- boilerplate_rds_to_json(rds_file, quiet = TRUE)
json_file <- sub("\\.rds$", ".json", rds_file)
saveRDS(list(methods_db = list(a = 1)), file.path(test_dir, "methods_db.rds"))
saveRDS(list(measures_db = list(b = 2)), file.path(test_dir, "measures_db.rds"))
result2 <- boilerplate_rds_to_json(test_dir, quiet = TRUE)
json_files <- list.files(test_dir, pattern = "\\.json$")
test_that("boilerplate_batch_edit works with JSON files", {
temp_json,  # Can pass file path directly
test_that("boilerplate_standardise_measures with json_compatible preserves JSON structure", {
description = "Gender"  # Missing name field
expect_equal(names(std_db), names(measures_db))  # Structure preserved
# Check that the field still exists (base function doesn't remove extra fields)
# Check metadata preserved - base function keeps all fields
test_that("JSON databases maintain compatibility with RDS workflows", {
text = "The sample size was {{n}} participants",
files <- list.files(test_path, full.names = TRUE)