Error in `gsub(paste0("^", path, "/?"), "", file)`: invalid regular expression '^D:\temp\2026_03_09_22_45_17_3640\RtmpO2n193/large_file_test2/?', reason 'Invalid back reference'

# Tests for publish.R internal helper functions
# Note: We test the internal helper functions that don't require
test_that(".get_gitignore_patterns returns character vector", {
test_that(".get_gitignore_patterns includes R-specific patterns", {
test_that(".get_gitignore_patterns includes Quarto patterns", {
test_that(".get_gitignore_patterns includes data file patterns", {
test_that(".get_gitignore_patterns includes OS-specific patterns", {
test_that(".get_gitignore_patterns includes IDE patterns", {
test_that(".get_gitignore_patterns includes data directories", {
test_that(".glob_to_regex converts simple patterns", {
expect_true(grepl("\\[\\^/\\]\\*", pattern))  # * becomes [^/]*
test_that(".glob_to_regex handles dot escaping", {
test_that(".glob_to_regex handles directory patterns", {
# Directory pattern should match at start or after /
test_that(".glob_to_regex handles ** for recursive matching", {
test_that(".glob_to_regex handles ? for single character", {
test_that(".find_large_files returns character vector", {
result <- dashboardr:::.find_large_files(temp_dir, size_mb = 100)
test_that(".find_large_files finds files above threshold", {
# Create a small file (under any reasonable threshold)
# Look for files > 100MB (our small file won't be found)
test_that(".find_large_files with small threshold finds files", {
writeLines(rep("x", 1000), test_file)  # Small but not empty
# Use very small threshold (basically 0 MB) to find it
result <- dashboardr:::.find_large_files(temp_dir, size_mb = 0.00001)
expect_true(length(result) > 0 || file.size(test_file) < 10)
test_that(".get_committable_files returns character vector", {
# Create .gitignore that excludes .csv files
# Note: the gitignore filtering is complex and may not work perfectly
# in all cases - this test verifies the function runs without error
test_that(".get_committable_files excludes .git directory", {
dir.create(file.path(temp_dir, ".git"), showWarnings = FALSE)
writeLines("git file", file.path(temp_dir, ".git", "config"))
test_that(".print_file_tree produces console output", {
dir.create(file.path(temp_dir, "subdir"), showWarnings = FALSE)
expect_true(any(grepl("Files to be committed", output)))
test_that(".print_file_tree handles empty directory", {
test_that(".display_pre_review_info produces console output", {
test_that(".cleanup_review_folder removes the review folder", {
test_that(".cleanup_review_folder handles non-existent folder", {
# Should not error when folder doesn't exist
# Skip this test as it requires a usethis project context
test_that(".create_review_folder requires project context", {