This function reads R code with at least one function definition (a file, a URL or a character string) and generates testthat tests for it.
Arguments
- file
A file path, URL or character string with the R function(s) to test (see
read_text()).- ...
Additional arguments to pass to the chat_completion() function.
- overwrite
Logical. If
FALSE(default), the function stops before calling the API when the test file already exists; ifTRUE, it replaces it. Only used for file input.
Value
For literal text or a URL: the generated test code as a character
string, returned visibly; nothing is written. For a file: the path of the
test file written (see Details), returned invisibly; in an interactive
session the file is also opened with utils::file.edit(). Input that is
empty (error class openair_empty_input) or holds no R function stops
before any API call. For file input, test code that does not parse as R is
not written: the function stops with an error of class
openair_invalid_output whose output field holds the code. Literal or URL
input returns such code all the same, with a message that it may be
invalid.
