mockPaths: Set an alternate directory for mock API fixtures

Description Usage Arguments Details Value Examples

Description

By default, with_mock_api will look for mocks relative to the current working directory (or the test directory). If you want to look in other places, you can call .mockPaths to add directories to the search path.

Usage

1

Arguments

new

Either a character vector of path(s) to add, or NULL to reset to the default.

Details

It works like base::.libPaths(): any directories you specify will be added to the list and searched first. The default directory will be searched last. Only unique values are kept: if you provide a path that is already found in .mockPaths, the result effectively moves that path to the first position.

For finer-grained control, or to completely override the default behavior of searching in the current working directory, you can set the option "dbtest.mock.paths" directly.

This function is an extension of httptest::.mockPaths() from httptest

Value

If new is omitted, the function returns the current search paths, a a character vector. If new is provided, the updated value will be returned invisibly.

Examples

1
2
3
4
5
identical(.mockPaths(), c("tests/testthat/", "."))
.mockPaths("/var/somewhere/else")
identical(.mockPaths(), c("/var/somewhere/else", "tests/testthat/", "."))
.mockPaths(NULL)
identical(.mockPaths(), c("tests/testthat/", "."))

pachamaltese/dbtest documentation built on Dec. 3, 2019, 11:08 p.m.