|
1 | | -test_that("Checking extension with approval prompt mocked y", { |
| 1 | +test_that("Checking non interactive approval", { |
| 2 | + rlang::local_interactive(FALSE) |
| 3 | + expect_snapshot(expect_true(check_approval(TRUE, "My thing"))) |
| 4 | + expect_snapshot(error = TRUE, { |
| 5 | + check_approval(FALSE, "My thing") |
| 6 | + }) |
| 7 | + expect_snapshot(error = TRUE, { |
| 8 | + check_approval(FALSE, "My thing", see_more_at = "https://example.com") |
| 9 | + }) |
| 10 | +}) |
| 11 | + |
| 12 | + |
| 13 | +test_that("Checking interactive approval with prompt mocked y", { |
2 | 14 | local_mocked_bindings( |
3 | | - readline = function(...) "y", |
4 | | - is_interactive = function() TRUE |
| 15 | + readline = function(...) "y" |
5 | 16 | ) |
| 17 | + rlang::local_interactive(TRUE) |
6 | 18 | expect_true({ |
7 | | - check_extension_approval( |
8 | | - FALSE, |
9 | | - "Quarto extensions", |
10 | | - "https://quarto.org/docs/extensions/managing.html" |
11 | | - ) |
| 19 | + check_approval(FALSE, "my-thing") |
12 | 20 | }) |
13 | 21 | }) |
14 | 22 |
|
15 | | -test_that("Checking extension with approval prompt mocked n", { |
| 23 | +test_that("Checking interactive approval with prompt mocked n", { |
16 | 24 | local_mocked_bindings( |
17 | | - readline = function(...) "n", |
18 | | - is_interactive = function() TRUE |
| 25 | + readline = function(...) "n" |
19 | 26 | ) |
20 | | - expect_false({ |
| 27 | + rlang::local_interactive(TRUE) |
| 28 | + expect_snapshot(expect_false({ |
| 29 | + check_approval(FALSE, "my-thing", see_more_at = "https://example.com") |
| 30 | + })) |
| 31 | +}) |
| 32 | + |
| 33 | +test_that("Checking non interactive extension approval", { |
| 34 | + rlang::local_interactive(FALSE) |
| 35 | + expect_snapshot(expect_true(check_extension_approval(TRUE, "My thing"))) |
| 36 | + expect_snapshot(error = TRUE, { |
| 37 | + check_extension_approval(FALSE, "My thing") |
| 38 | + }) |
| 39 | + expect_snapshot(error = TRUE, { |
21 | 40 | check_extension_approval( |
22 | 41 | FALSE, |
23 | | - "Quarto extensions", |
24 | | - "https://quarto.org/docs/extensions/managing.html" |
| 42 | + "My thing", |
| 43 | + see_more_at = "https://example.com" |
25 | 44 | ) |
26 | 45 | }) |
27 | 46 | }) |
28 | 47 |
|
29 | | -test_that("Checking extension approval", { |
30 | | - skip_if_no_quarto() |
31 | | - skip_if_offline("github.com") |
| 48 | +test_that("Checking interactive extension approval with prompt mocked y", { |
| 49 | + local_mocked_bindings( |
| 50 | + readline = function(...) "y" |
| 51 | + ) |
| 52 | + rlang::local_interactive(TRUE) |
| 53 | + expect_snapshot(expect_true({ |
| 54 | + check_extension_approval(FALSE, "my-thing") |
| 55 | + })) |
| 56 | +}) |
32 | 57 |
|
33 | | - expect_true(check_extension_approval( |
34 | | - TRUE, |
35 | | - "Quarto extensions", |
36 | | - "https://quarto.org/docs/extensions/managing.html" |
37 | | - )) |
38 | | - expect_true(check_extension_approval( |
39 | | - TRUE, |
40 | | - "Quarto templates", |
41 | | - "https://quarto.org/docs/extensions/formats.html#distributing-formats" |
42 | | - )) |
| 58 | +test_that("Checking interactive extension approval with prompt mocked n", { |
| 59 | + local_mocked_bindings( |
| 60 | + readline = function(...) "n" |
| 61 | + ) |
| 62 | + rlang::local_interactive(TRUE) |
| 63 | + expect_snapshot(expect_false({ |
| 64 | + check_extension_approval(FALSE, "my-thing") |
| 65 | + })) |
| 66 | +}) |
43 | 67 |
|
44 | | - expect_error({ |
45 | | - local_reproducible_output(rlang_interactive = FALSE) |
46 | | - check_extension_approval( |
47 | | - FALSE, |
48 | | - "Quarto extensions", |
49 | | - "https://quarto.org/docs/extensions/managing.html" |
50 | | - ) |
| 68 | +test_that("Checking non interactive removal approval", { |
| 69 | + rlang::local_interactive(FALSE) |
| 70 | + expect_snapshot(expect_true(check_removal_approval(TRUE, "My thing"))) |
| 71 | + expect_snapshot(error = TRUE, { |
| 72 | + check_removal_approval(FALSE, "My thing") |
51 | 73 | }) |
52 | | - expect_error({ |
53 | | - local_reproducible_output(rlang_interactive = FALSE) |
54 | | - check_extension_approval( |
55 | | - TRUE, |
56 | | - "Quarto extensions", |
57 | | - "https://quarto.org/docs/extensions/managing.html" |
| 74 | + expect_snapshot(error = TRUE, { |
| 75 | + check_removal_approval( |
| 76 | + FALSE, |
| 77 | + "My thing", |
| 78 | + see_more_at = "https://example.com" |
58 | 79 | ) |
59 | 80 | }) |
60 | 81 | }) |
| 82 | + |
| 83 | +test_that("Checking interactive removal approval with prompt mocked y", { |
| 84 | + local_mocked_bindings( |
| 85 | + readline = function(...) "y" |
| 86 | + ) |
| 87 | + rlang::local_interactive(TRUE) |
| 88 | + expect_snapshot(expect_true({ |
| 89 | + check_removal_approval(FALSE, "my-thing") |
| 90 | + })) |
| 91 | +}) |
| 92 | + |
| 93 | +test_that("Checking interactive removal approval with prompt mocked n", { |
| 94 | + local_mocked_bindings( |
| 95 | + readline = function(...) "n" |
| 96 | + ) |
| 97 | + rlang::local_interactive(TRUE) |
| 98 | + expect_snapshot(expect_false({ |
| 99 | + check_removal_approval(FALSE, "my-thing") |
| 100 | + })) |
| 101 | +}) |
0 commit comments