|
| 1 | +test_that("querychat_tool_starts_open respects default behavior", { |
| 2 | + withr::local_options(querychat.tool_details = NULL) |
| 3 | + withr::local_envvar(QUERYCHAT_TOOL_DETAILS = NA) |
| 4 | + |
| 5 | + expect_true(querychat_tool_starts_open("query")) |
| 6 | + expect_true(querychat_tool_starts_open("update")) |
| 7 | + expect_false(querychat_tool_starts_open("reset")) |
| 8 | +}) |
| 9 | + |
| 10 | +test_that("querychat_tool_starts_open respects 'expanded' setting via option", { |
| 11 | + withr::local_options(querychat.tool_details = "expanded") |
| 12 | + |
| 13 | + expect_true(querychat_tool_starts_open("query")) |
| 14 | + expect_true(querychat_tool_starts_open("update")) |
| 15 | + expect_true(querychat_tool_starts_open("reset")) |
| 16 | +}) |
| 17 | + |
| 18 | +test_that("querychat_tool_starts_open respects 'collapsed' setting via option", { |
| 19 | + withr::local_options(querychat.tool_details = "collapsed") |
| 20 | + |
| 21 | + expect_false(querychat_tool_starts_open("query")) |
| 22 | + expect_false(querychat_tool_starts_open("update")) |
| 23 | + expect_false(querychat_tool_starts_open("reset")) |
| 24 | +}) |
| 25 | + |
| 26 | +test_that("querychat_tool_starts_open respects 'default' setting via option", { |
| 27 | + withr::local_options(querychat.tool_details = "default") |
| 28 | + |
| 29 | + expect_true(querychat_tool_starts_open("query")) |
| 30 | + expect_true(querychat_tool_starts_open("update")) |
| 31 | + expect_false(querychat_tool_starts_open("reset")) |
| 32 | +}) |
| 33 | + |
| 34 | +test_that("querychat_tool_starts_open respects 'expanded' setting via envvar", { |
| 35 | + withr::local_options(querychat.tool_details = NULL) |
| 36 | + withr::local_envvar(QUERYCHAT_TOOL_DETAILS = "expanded") |
| 37 | + |
| 38 | + expect_true(querychat_tool_starts_open("query")) |
| 39 | + expect_true(querychat_tool_starts_open("update")) |
| 40 | + expect_true(querychat_tool_starts_open("reset")) |
| 41 | +}) |
| 42 | + |
| 43 | +test_that("querychat_tool_starts_open respects 'collapsed' setting via envvar", { |
| 44 | + withr::local_options(querychat.tool_details = NULL) |
| 45 | + withr::local_envvar(QUERYCHAT_TOOL_DETAILS = "collapsed") |
| 46 | + |
| 47 | + expect_false(querychat_tool_starts_open("query")) |
| 48 | + expect_false(querychat_tool_starts_open("update")) |
| 49 | + expect_false(querychat_tool_starts_open("reset")) |
| 50 | +}) |
| 51 | + |
| 52 | +test_that("querychat_tool_starts_open is case-insensitive", { |
| 53 | + withr::local_options(querychat.tool_details = "EXPANDED") |
| 54 | + expect_true(querychat_tool_starts_open("query")) |
| 55 | + |
| 56 | + withr::local_options(querychat.tool_details = "Collapsed") |
| 57 | + expect_false(querychat_tool_starts_open("query")) |
| 58 | +}) |
| 59 | + |
| 60 | +test_that("querychat_tool_starts_open warns on invalid setting", { |
| 61 | + withr::local_options(querychat.tool_details = "invalid") |
| 62 | + |
| 63 | + expect_warning( |
| 64 | + querychat_tool_starts_open("query"), |
| 65 | + "Invalid value for" |
| 66 | + ) |
| 67 | +}) |
| 68 | + |
| 69 | +test_that("option takes precedence over environment variable", { |
| 70 | + withr::local_options(querychat.tool_details = "collapsed") |
| 71 | + withr::local_envvar(QUERYCHAT_TOOL_DETAILS = "expanded") |
| 72 | + |
| 73 | + expect_false(querychat_tool_starts_open("query")) |
| 74 | +}) |
0 commit comments