Skip to content

Commit

Permalink
Merge pull request #2220 from olivroy/mockr
Browse files Browse the repository at this point in the history
chore: Drop crayon and mockr dependencies
  • Loading branch information
aviator-app[bot] authored Sep 24, 2024
2 parents c8400ba + 02d7c99 commit 65d312d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
4 changes: 1 addition & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ Suggests:
brio,
colourpicker,
covr,
crayon,
DBI (>= 1.2.0),
dbplyr (>= 2.3.4),
DiagrammeR,
Expand All @@ -83,7 +82,6 @@ Suggests:
knitr,
labelled (>= 2.12.0),
magrittr,
mockr,
nycflights13,
odbc (>= 1.4.2),
pillar,
Expand All @@ -99,7 +97,7 @@ Suggests:
shiny,
shinyAce,
shinydashboard,
testthat (>= 3.1.2),
testthat (>= 3.2.0),
waldo,
withr
Remotes:
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/helper-src.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ my_test_src_name <- {
src <- "df"
}
name <- gsub("^.*-", "", src)
inform(crayon::green(paste0("Testing on ", name)))
cli::cli_inform(cli::col_green("Testing on {name}"))
name
}

Expand Down
18 changes: 7 additions & 11 deletions tests/testthat/test-db-interface.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ test_that("copy_dm_to() fails with duplicate table names", {
})

test_that("default table repair works", {
skip_if_not_installed("mockr")

con <- con_from_src_or_con(my_db_test_src())

table_names <- c("t1", "t2", "t3")
Expand All @@ -65,16 +63,14 @@ test_that("default table repair works", {
glue::glue("{table_name}_2020_05_15_10_45_29_0")
}

mockr::with_mock(
unique_db_table_name = my_unique_db_table_name,
{
repair_table_names_for_db(table_names, temporary = FALSE, con)
expect_equal(calls, 0)
repair_table_names_for_db(table_names, temporary = TRUE, con)
expect_gt(calls, 0)
},
.env = asNamespace("dm")
local_mocked_bindings(
unique_db_table_name = function(table_name) my_unique_db_table_name(table_name)
)
repair_table_names_for_db(table_names, temporary = FALSE, con)
expect_equal(calls, 0)
repair_table_names_for_db(table_names, temporary = TRUE, con)
expect_gt(calls, 0)

})

test_that("copy_dm_to() fails legibly if target schema missing for MSSQL & Postgres", {
Expand Down

0 comments on commit 65d312d

Please sign in to comment.