Skip to content

Commit

Permalink
Another approach to try and get vignettes building
Browse files Browse the repository at this point in the history
  • Loading branch information
richfitz committed Nov 9, 2023
1 parent c22866f commit d55b861
Showing 1 changed file with 3 additions and 22 deletions.
25 changes: 3 additions & 22 deletions vignettes_src/packages.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -84,41 +84,22 @@ failure to start a vault server. This could be for reasons such as:
* the binary is not in place
* a port could not be opened

``` {r include = FALSE}
rm(list = "server_manager", envir = vaultr:::vault_env)
```

By default this calls `testthat::skip`, which interactively will
appear to cause an error but if called within a `test_that` block
in a test will gracefully skip a test

```{r, include = FALSE}
.vaultr_test_server_bin_path <- Sys.getenv("VAULTR_TEST_SERVER_BIN_PATH")
```

``` {r }
Sys.setenv("VAULTR_TEST_SERVER_BIN_PATH" = NA_character_)
```

<!-- can't use error=TRUE on the block here, as testthat::skip() still fails the vignette build -->

```r
srv <- vaultr::vault_test_server()
## Error: vault is not enabled
```


Alternatively, provide your own handler:
``` {r }
srv <- vaultr::vault_test_server(if_disabled = message)
srv
```

```{r, include = FALSE}
Sys.setenv("VAULTR_TEST_SERVER_BIN_PATH" = .vaultr_test_server_bin_path)
```r
srv <- vaultr::vault_test_server(if_disabled = message)
```

With that approach, you might wrap vault-requiring tests with
In this case, `vaultr::vault_test_server` will return `NULL` and you might wrap vault-requiring tests with:

```r
if (!is.null(srv)) {
Expand Down

0 comments on commit d55b861

Please sign in to comment.