diff --git a/tests/mod.nu b/tests/mod.nu index d11ea75..7f30c83 100644 --- a/tests/mod.nu +++ b/tests/mod.nu @@ -6,10 +6,20 @@ use ../nupm const TEST_REGISTRY_PATH = ([tests packages registry.nuon] | path join) -def with-nupm-home [closure: closure]: nothing -> nothing { - let dir = tmp-dir test --ensure - with-env { NUPM_HOME: $dir } $closure - rm --recursive $dir +def with-test-env [closure: closure]: nothing -> nothing { + let home = tmp-dir nupm_test --ensure + let cache = tmp-dir 'nupm_test/cache' --ensure + let temp = tmp-dir 'nupm_test/temp' --ensure + + with-env { + NUPM_HOME: $home + NUPM_CACHE: $cache + NUPM_TEMP: $temp + } $closure + + rm --recursive $temp + rm --recursive $cache + rm --recursive $home } # Examples: @@ -20,7 +30,7 @@ def "assert installed" [path_tokens: list] { } export def install-script [] { - with-nupm-home { + with-test-env { nupm install --path tests/packages/spam_script assert installed [scripts spam_script.nu] @@ -29,7 +39,7 @@ export def install-script [] { } export def install-module [] { - with-nupm-home { + with-test-env { nupm install --path tests/packages/spam_module assert installed [scripts script.nu] @@ -39,7 +49,7 @@ export def install-module [] { } export def install-custom [] { - with-nupm-home { + with-test-env { nupm install --path tests/packages/spam_custom assert installed [plugins nu_plugin_test] @@ -52,19 +62,19 @@ export def install-from-local-registry [] { assert ($contents | str contains '0.2.0') } - with-nupm-home { + with-test-env { $env.NUPM_REGISTRIES = {} nupm install --registry $TEST_REGISTRY_PATH spam_script check-file } - with-nupm-home { + with-test-env { $env.NUPM_REGISTRIES = { test: $TEST_REGISTRY_PATH } nupm install --registry test spam_script check-file } - with-nupm-home { + with-test-env { $env.NUPM_REGISTRIES = { test: $TEST_REGISTRY_PATH } nupm install spam_script check-file