From 5200dc280ee4e09a2dcc153208f566418978a969 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Tue, 25 Aug 2015 22:45:21 -0500 Subject: [PATCH] fix/improve Scoop-Alias and Scoop-Core tests * Scoop-Alias: remove erroneous output from dot-sourcing the source file * Scoop-Alias: using "TestDrive:\" for mocked shimdir - reduced cleanup - improved robustness; excution is now independent of CWD * Scoop-Core: corrected directory location code - improved robustness; execution is now independent of CWD --- test/Scoop-Alias.Tests.ps1 | 22 +++++++++------------- test/Scoop-Core.Tests.ps1 | 6 +++++- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/test/Scoop-Alias.Tests.ps1 b/test/Scoop-Alias.Tests.ps1 index f70cfcd9a..e8ca8bcf0 100644 --- a/test/Scoop-Alias.Tests.ps1 +++ b/test/Scoop-Alias.Tests.ps1 @@ -1,12 +1,14 @@ -. "$psscriptroot\..\libexec\scoop-alias.ps1" +. "$psscriptroot\..\libexec\scoop-alias.ps1" | out-null reset_aliases describe "add_alias" { - mock shimdir { "test\fixtures\shim" } + mock shimdir { "TestDrive:\shim" } mock set_config { } mock get_config { @{} } + $shimdir = shimdir + mkdir $shimdir context "alias doesn't exist" { it "creates a new alias" { @@ -28,18 +30,16 @@ describe "add_alias" { $alias_file | should contain "" } } - - aftereach { - rm "test\fixtures\shim\scoop-rm.ps1" -ea ignore - } } describe "rm_alias" { - mock shimdir { "test\fixtures\shim" } - $shimdir = shimdir + mock shimdir { "TestDrive:\shim" } mock set_config { } mock get_config { @{} } + $shimdir = shimdir + mkdir $shimdir + context "alias exists" { it "removes an existing alias" { $alias_file = "$shimdir\scoop-rm.ps1" @@ -52,8 +52,4 @@ describe "rm_alias" { $alias_file | should not exist } } - - afterall { - rm "test\fixtures\shim\scoop-rm.ps1" -ea ignore - } -} \ No newline at end of file +} diff --git a/test/Scoop-Core.Tests.ps1 b/test/Scoop-Core.Tests.ps1 index 0dc785791..5925071ba 100644 --- a/test/Scoop-Core.Tests.ps1 +++ b/test/Scoop-Core.Tests.ps1 @@ -2,6 +2,8 @@ . "$psscriptroot\..\lib\install.ps1" . "$psscriptroot\Scoop-TestLib.ps1" +$repo_dir = (Get-Item $MyInvocation.MyCommand.Path).directory.parent.FullName + describe "movedir" { $extract_dir = "subdir" $extract_to = $null @@ -59,7 +61,9 @@ describe "unzip_old" { it "unzips file with zero bytes without error" { $to = test-unzip $zerobyte + $to | should not be $null $to | should exist + (gci $to).count | should be 0 } } @@ -136,7 +140,7 @@ describe "rm_shim" { describe "ensure_robocopy_in_path" { $shimdir = shimdir $false - mock versiondir { ".\" } + mock versiondir { $repo_dir } beforeall { reset_aliases