.path_to_tilde converts home directory paths to tilde

Expected `grepl("inputs/intermediate/my_data\\.rds$", record$path)` to be TRUE.
Differences:
`actual`:   FALSE
`expected`: TRUE

test_that("data_save creates data file and updates database", {
test_data <- data.frame(x = 1:5, y = letters[1:5])
# Save as CSV using direct path (force = TRUE to create directory structure)
suppressMessages(data_save(test_data, "outputs/public/sample.csv", force = TRUE))
record <- DBI::dbGetQuery(conn, "SELECT * FROM data WHERE name = 'outputs/public/sample.csv'")
test_that("data_save creates RDS files", {
suppressMessages(data_save(test_data, "outputs/private/rds_data.rds", force = TRUE))
test_that("data_read reads saved CSV data", {
# Create directory and save test data using direct path
dir.create("inputs/raw", recursive = TRUE, showWarnings = FALSE)
original_data <- data.frame(x = 1:5, y = letters[1:5])
test_that("data_read reads saved RDS data", {
dir.create("inputs/intermediate", recursive = TRUE, showWarnings = FALSE)
test_that("data_read reads direct file paths", {
test_data <- data.frame(a = 1:3, b = 4:6)
write.csv(test_data, "data/direct/file.csv", row.names = FALSE)
test_that("data_read fails for non-existent file", {
test_that("data_spec_get retrieves data specification from config", {
# Path is normalized to absolute, so check it ends with the expected relative path
test_that("data_read reads Excel files directly", {
test_data <- data.frame(x = 1:5, y = letters[1:5], z = 10:14)
test_that("data_read reads Excel files from config", {
test_data <- data.frame(name = c("Alice", "Bob"), age = c(25, 30))
test_that("data_spec_get detects Excel file type", {
test_that("data_save resolves dot notation to configured directories", {
# Save using 3-part dot notation (inputs.intermediate.filename)
# Should resolve to inputs/intermediate/test_file.rds
test_that("data_save accepts direct file paths", {
test_that("data_save auto-detects type from file extension", {
test_that("data_save errors when directory doesn't exist without force", {
# Should error because inputs/nonexistent doesn't exist
"Directory.*does not exist.*force = TRUE"
test_that("data_save creates directory with force = TRUE", {
data_save(test_data, "inputs/new_dir/file.rds", force = TRUE)
test_that("data_save errors for simple filename without directory", {
"has no directory.*dot notation.*full path"
test_that("data_save updates database with normalized name", {
# Check database record uses original path as name
record <- DBI::dbGetQuery(conn, "SELECT * FROM data WHERE name = 'inputs.intermediate.my_data'")
# Path may be absolute or relative depending on the platform
test_that("data_add registers existing CSV file", {
# Create a CSV file manually (simulating external data)
write.csv(test_data, "inputs/raw/external_data.csv", row.names = FALSE)
record <- DBI::dbGetQuery(conn, "SELECT * FROM data WHERE name = 'raw.external_data'")
test_that("data_add auto-detects file type from extension", {
record <- DBI::dbGetQuery(conn, "SELECT * FROM data WHERE name = 'intermediate.processed'")
test_that("data_add errors for non-existent file", {
test_that("data_add allows reading via data_read after registration", {
original_data <- data.frame(a = 1:3, b = c("x", "y", "z"))
write.csv(original_data, "inputs/raw/readable.csv", row.names = FALSE)
# Now read it using data_read with dot notation
test_that("data_add respects locked parameter", {
write.csv(data.frame(x = 1), "inputs/raw/locked.csv", row.names = FALSE)
data_add("inputs/raw/locked.csv", name = "raw.locked_file", locked = FALSE)
record <- DBI::dbGetQuery(conn, "SELECT * FROM data WHERE name = 'raw.locked_file'")
expect_equal(record$locked, 0)  # SQLite stores FALSE as 0
test_that("data_add can skip config update", {
write.csv(data.frame(x = 1), "inputs/raw/no_config.csv", row.names = FALSE)
data_add("inputs/raw/no_config.csv", name = "raw.no_config", update_config = FALSE)
record <- DBI::dbGetQuery(conn, "SELECT * FROM data WHERE name = 'raw.no_config'")
spec <- tryCatch(data_spec_get("raw.no_config"), error = function(e) NULL)