Skip to content

Commit

Permalink
Add check for name length (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonmcalder authored and maelle committed Dec 28, 2018
1 parent c0fd68d commit 23bccb8
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions R/createAnalysisProject.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ createAnalysisProject <- function(name, title = NULL,
dirs = c("data", "analysis", "outputs")) {
if (missing(name)) stop("name is required")
if (!is.character(name)) stop("name has to be a character")
if (nchar(name) < 2) stop("name needs to have at least two characters")

packagedeps <- match.arg(packagedeps, okpackagedeps())

Expand Down
1 change: 1 addition & 0 deletions R/createBasicProject.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ createBasicProject <- function(name,
reset = TRUE) {
if (missing(name)) stop("name is required")
if (!is.character(name)) stop("name has to be a character")
if (nchar(name) < 2) stop("name needs to have at least two characters")

packagedeps <- match.arg(packagedeps, okpackagedeps())

Expand Down
1 change: 1 addition & 0 deletions R/createPackageProject.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ createPackageProject <- function(name, title = NULL,
)) {
if (missing(name)) stop("name is required")
if (!is.character(name)) stop("name has to be a character")
if (nchar(name) < 2) stop("name needs to have at least two characters")

# create title
if (is.null(title)) {
Expand Down
1 change: 1 addition & 0 deletions R/createTrainingProject.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ createTrainingProject <- function(name, folder = getwd(),
reset = TRUE) {
if (missing(name)) stop("name is required")
if (!is.character(name)) stop("name has to be a character")
if (nchar(name) < 2) stop("name needs to have at least two characters")

packagedeps <- match.arg(packagedeps, okpackagedeps())
# Supported packages
Expand Down
8 changes: 8 additions & 0 deletions tests/testthat/test-AAA-createBasicProject.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ test_that("createBasicProject() errors if name missing or not correct", {
git = TRUE,
external_setup = NULL
))

expect_error(createBasicProject(
name = "a",
folder = tmp,
packagedeps = "packrat",
git = TRUE,
external_setup = NULL
))
})


Expand Down
8 changes: 8 additions & 0 deletions tests/testthat/test-createAnalysisProject.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ test_that("createAnalysisProject() errors if name missing or not correct", {
git = TRUE,
external_setup = NULL
))

expect_error(createAnalysisProject(
name = "a",
folder = tmp,
packagedeps = "packrat",
git = TRUE,
external_setup = NULL
))
})


Expand Down
8 changes: 8 additions & 0 deletions tests/testthat/test-createPackageProject.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ test_that("createPackageProject() errors if name missing or not correct", {
git = TRUE,
external_setup = NULL
))

expect_error(createPackageProject(
name = "a",
folder = tmp,
packagedeps = "packrat",
git = TRUE,
external_setup = NULL
))
})


Expand Down
8 changes: 8 additions & 0 deletions tests/testthat/test-createTrainingProject.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ test_that("createTrainingProject() errors if name missing or not correct", {
git = TRUE,
external_setup = NULL
))

expect_error(createTrainingProject(
name = "a",
folder = tmp,
packagedeps = "packrat",
git = TRUE,
external_setup = NULL
))
})


Expand Down

0 comments on commit 23bccb8

Please sign in to comment.