expect_is_file: Return an error if a string represents an existent file.

Description Usage Arguments Value Examples

View source: R/expect_is_file.R

Description

Return an error if a string represents an existent file.

Return an error if a string represents an existent directory.

Usage

1
2
3
expect_is_file(potential_filepath, ...)

expect_is_directory(potential_filepath, ...)

Arguments

potential_filepath

character. The name of the file path to check.

...

additional arguments to pass to expect_true.

Value

TRUE or FALSE according as potential_filepath is or is not a file.

TRUE or FALSE according as potential_path is or is not a directory.

Examples

1
2
3
4
5
6
7
8
9
library(testthat)
# expect_error(expect_is_file('not/a/file')) # will error
tmp <- tempfile(); writeLines('', tmp)
expect_is_file(tmp) # will not error
## Not run: 
# expect_is_directory('not/a/dir') # will error
expect_is_directory(dirname(tempfile())) # will not error

## End(Not run)

robertzk/testthatsomemore documentation built on Aug. 15, 2017, 7:45 a.m.