Skip to content

Commit

Permalink
change duplicated file function and test (CI issue)
Browse files Browse the repository at this point in the history
  • Loading branch information
eviecarter33 committed Oct 17, 2024
1 parent 3b614cd commit 4ffc22e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions R/gen_tibble.R
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ change_duplicated_file_name <- function(file){

if(file.exists(bk) && !file.exists(rds)){

version <- 1
version <- 2

base_name <- basename(file)

Expand All @@ -533,7 +533,7 @@ change_duplicated_file_name <- function(file){
return(new_file)
} else if (file.exists(bk) && file.exists(rds)){

version <- 1
version <- 2

base_name <- basename(file)

Expand Down
19 changes: 12 additions & 7 deletions tests/testthat/test_gen_tibble.R
Original file line number Diff line number Diff line change
Expand Up @@ -436,32 +436,37 @@ test_gt <- gen_tibble(x = test_genotypes, loci = test_loci,

test_that("versioning if .bk already exists",{

# get the gt filenames
files <- gt_get_file_names(test_gt)

file.remove(files[1])
# remove the .rds
expect_true(file.remove(files[1]))

file <- gsub(".bk","",files[2],)

# create gt using the same backingfile name
test_gt <- gen_tibble(x = test_genotypes, loci = test_loci,
indiv_meta = test_indiv_meta, quiet = TRUE,
backingfile = file)

# get new file names
new_files <- gt_get_file_names(test_gt)

expect_equal(new_files[2], paste0(file,"_v1.bk"))
# new_files has the same name as original file, plus a version extension
expect_equal(new_files[2], paste0(file,"_v2.bk"))

file.remove(new_files[1])

file.exists(new_files[1])
file.exists(new_files[2])
# repeating the process creates another version
expect_true(file.remove(new_files[1]))
expect_false(file.exists(new_files[1]))
expect_true(file.exists(new_files[2]))

test_gt <- gen_tibble(x = test_genotypes, loci = test_loci,
indiv_meta = test_indiv_meta, quiet = TRUE,
backingfile = file)

new_version_files <- gt_get_file_names(test_gt)

expect_equal(new_version_files[2], paste0(file,"_v2.bk"))
expect_equal(new_version_files[2], paste0(file,"_v3.bk"))

})

Expand Down

0 comments on commit 4ffc22e

Please sign in to comment.