capture_mockdb: Capture a function call to a production database in mock...

View source: R/dev_helpers.R

capture_mockdbR Documentation

Capture a function call to a production database in mock fixtures.

Description

This is a wrapper for capturing database fixtures with dittodb. It connects to the production database, captures the query, and disconnects from the production database.

Usage

capture_mockdb(production_db, mock_db = "./tests/testthat/mock_db/", f)

Arguments

production_db

The production database with the full data

mock_db

The path to the mock database containing the fixtures for dittodb. Default is ⁠tests/testthat/mock_db/⁠.

f

The function with SQL calls to be captured with all options set inside.

Value

Saves fixtures to ⁠mock_db/dir/⁠ where dir is created and defined by dittodb based on name of production_db. For instance, "/mypath/database.sqlite" becomes "_mypath_database.sqlite/".


f-hafner/magutils documentation built on Sept. 20, 2023, 5:05 a.m.