Add Pester tests for Config and Versions

Add Scoop-Config.Tests
Add Scoop-Versions.Tests
Remove old tests
This commit is contained in:
Simon Hartcher
2015-04-12 12:10:06 +10:00
parent fb074f2c63
commit 47544c9e77
4 changed files with 37 additions and 29 deletions
+17
View File
@@ -0,0 +1,17 @@
. "$psscriptroot\..\lib\core.ps1"
. "$psscriptroot\..\lib\config.ps1"
describe "hashtable" {
$json = '{ "one": 1, "two": [ { "a": "a" }, "b", 2 ], "three": { "four": 4 } }'
it "converts pscustomobject to hashtable" {
$obj = convertfrom-json $json
$ht = hashtable $obj
$ht.one | should beexactly 1
$ht.two[0].a | should be "a"
$ht.two[1] | should be "b"
$ht.two[2] | should beexactly 2
$ht.three.four | should beexactly 4
}
}
+20
View File
@@ -0,0 +1,20 @@
. "$psscriptroot\tests.ps1"
. "$psscriptroot\..\lib\versions.ps1"
describe "versions" {
it 'compares versions with integer-string mismatch' {
$a = '1.8.9'
$b = '1.8.5-1'
$res = compare_versions $a $b
$res | should be 1
}
it 'handles plain string version comparison to int version' {
$a = 'latest'
$b = '20150405'
$res = compare_versions $a $b
$res | should be 1
}
}
-11
View File
@@ -1,11 +0,0 @@
# testing converting json -> pscustomobject > hashtable
. "$psscriptroot\..\lib\core.ps1"
. "$psscriptroot\..\lib\config.ps1"
$json = '{ "one": 1, "two": [ { "a": "a" }, "b", 2 ], "three": { "four": 4 } }'
$global:obj = convertfrom-json $json
$a = $obj.two[0]
$global:res = hashtable $obj
-18
View File
@@ -1,18 +0,0 @@
. "$psscriptroot\tests.ps1"
. "$psscriptroot\..\lib\versions.ps1"
test 'compare version with integer-string mismatch' {
$a = '1.8.9'
$b = '1.8.5-1'
$res = compare_versions $a $b
assert $res -eq 1
}
test 'handle plain string version comparison to int version' {
$a = 'latest'
$b = '20150405'
$res = compare_versions $a $b
assert $res -eq 1
}
test_results