mirror of
https://github.com/ScoopInstaller/Scoop.git
synced 2026-08-29 01:26:44 +00:00
Add Pester tests for Config and Versions
Add Scoop-Config.Tests Add Scoop-Versions.Tests Remove old tests
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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
@@ -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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user