-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
basic tests for pal removal and addition
- Loading branch information
1 parent
afbdbfc
commit d466e8c
Showing
3 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# pal addition and removal works | ||
|
||
Code | ||
pal_boopery | ||
Message | ||
-- A boopery pal using claude-3-5-sonnet-20240620. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
test_that("pal addition and removal works", { | ||
skip_if(identical(Sys.getenv("ANTHROPIC_API_KEY"), "")) | ||
skip_if_not_installed("withr") | ||
withr::local_options(.pal_fn = NULL, .pal_args = NULL) | ||
|
||
boop_prompt <- "just reply with beep bop boop regardless of input" | ||
pal_add("boopery", boop_prompt) | ||
|
||
expect_equal(system_prompt_boopery, boop_prompt) | ||
expect_true(is_function(rs_pal_boopery)) | ||
expect_true("system_prompt_boopery" %in% names(pal_env())) | ||
expect_true("rs_pal_boopery" %in% names(pal_env())) | ||
|
||
pal_boopery <- pal("boopery") | ||
expect_snapshot(pal_boopery) | ||
expect_true(".last_pal_boopery" %in% names(pal_env())) | ||
|
||
res <- pal_boopery$chat("hey there") | ||
expect_true(grepl("bop", res)) | ||
|
||
pal_remove("boopery") | ||
|
||
expect_false(".last_pal_boopery" %in% names(pal_env())) | ||
expect_false("system_prompt_boopery" %in% names(pal_env())) | ||
expect_false("rs_pal_boopery" %in% names(pal_env())) | ||
}) |