Skip to content

Commit

Permalink
change: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomeriko96 committed Jan 25, 2023
1 parent bc23709 commit b0f7ff9
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
^renv$
^renv\.lock$
^LICENSE\.md$
^.*\.Rproj$
^\.Rproj\.user$
Expand Down
Empty file added .Rprofile
Empty file.
9 changes: 6 additions & 3 deletions R/google_translate.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#' Translate text using google translate
#'
#' @param text Text to translate.
#' @param target_language Language to translate text to.
#' @param source_language Language to translate text from
#' @param text This is the text that you want to translate.
#' @param target_language This is the language that you want to translate the text into.
#' The default value for this argument is "en" for English.
#' @param source_language This is the language of the text that you want to translate.
#' The default value for this argument is "auto",
#' which means that the function will try to automatically detect the language of the text.
#'
#' @return Translated text.
#' @export
Expand Down
8 changes: 5 additions & 3 deletions build_package.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
options(repos = c(PkgMgr="https://packagemanager.rstudio.com/all/__linux__/focal/latest"))
## Set project name
package_name <- basename(rstudioapi::getActiveProject())
## =============================================== ==============================
Expand All @@ -7,11 +8,13 @@ build_packages <- c("devtools",
"renv",
"qpdf")


## install the packages that are not installed yet
lapply(build_packages[which(!build_packages %in% installed.packages())],
install.packages)



## load the packages
invisible(lapply(build_packages,
library,
Expand All @@ -25,14 +28,13 @@ invisible(lapply(build_packages,
## Check if the package is correct and can be built.
devtools::document()
devtools::check(manual = T)
devtools::build_manual(path = ".")

devtools::build_manual(path = "~/Downloads/")

## Increment the version number and check in that change in Git
usethis::use_version()

## Build the package, and release it to the correct folder
devtools::build(path = "../../../Downloads/")
devtools::build(path = "~/Downloads/")

## Make use of the development version again
usethis::use_dev_version()
9 changes: 6 additions & 3 deletions man/google_translate.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions renv/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
library/
local/
cellar/
lock/
python/
staging/
4 changes: 2 additions & 2 deletions tests/testthat/test-google_translate.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
test_that("translation works", {
expect_equal(google_translate("hello world",
expect_equal(google_translate("hello",
target_language = "es"),
"Hola Mundo")
"Hola")
})
4 changes: 2 additions & 2 deletions tests/testthat/test-mymemory_translate.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
test_that("translation workds", {
expect_equal(mymemory_translate(text = "Hello World",
expect_equal(mymemory_translate(text = "Hello",
target_language = "es",
source_language = "en"),
"Hola Mundo")
"Hola")
})

0 comments on commit b0f7ff9

Please sign in to comment.