Skip to content

Commit

Permalink
test: Add E2E test for RHINO_NPM env var
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilzyla committed Jan 18, 2024
1 parent bf594c4 commit 7923778
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ jobs:
cd RhinoApp
Rscript ../test-dependencies.R
- name: Node.js commands should respect RHINO_NPM
if: always()
run: |
cd RhinoApp
Rscript ../test-custom-npm.R
- name: lint_r() should detect lint errors in R scripts
if: always()
run: |
Expand Down
22 changes: 22 additions & 0 deletions tests/e2e/test-custom-npm.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
local({
tmp <- withr::local_tempdir()
wrapper_path <- fs::path(tmp, "wrapper")
touch_path <- fs::path(tmp, "it_works")

# Prepare a wrapper script which creates an "it_works" file and runs npm.
fs::file_create(wrapper_path, mode = "u=rwx")
writeLines(
c(
'#!/bin/sh',
paste('touch', touch_path),
'exec npm "$@"'
),
wrapper_path
)

# Use the wrapper script instead of npm.
withr::local_envvar(RHINO_NPM = wrapper_path)
rhino:::npm("--version")

testthat::expect_true(fs::file_exists(touch_path))
})

0 comments on commit 7923778

Please sign in to comment.