Skip to content

Commit

Permalink
Add new tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bpvgoncalves committed Apr 9, 2024
1 parent b6eb1ff commit 8d9924f
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/testthat/test-databaseKeyAdd.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,26 @@ test_that("it is posible to add a key", {
expect_identical(dbListTables(con), dbListTables(con2))

})

test_that("fails with invalid key", {
on.exit({
dbDisconnect(con)
})

tmp_file <- tempfile()
con <- dbConnect(SQLCipher(), tmp_file)
dbWriteTable(con, "mtcars", mtcars)

# wrong size, right type
key <- "0123456789ABCDEF0123456789ABCDEF012345"
expect_warning(newDB <- databaseKeyAdd(con, key),
"invalid length")
expect_false(newDB$result)

# right size, wrong type (not hex)
key <- "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEG"
expect_warning(newDB <- databaseKeyAdd(con, key),
"invalid type")
expect_false(newDB$result)

})

0 comments on commit 8d9924f

Please sign in to comment.