Merge branch 'develop' into dev/112-split-path-pester
This commit is contained in:
commit
5bdae5f77e
|
@ -595,6 +595,15 @@ internal class ParserStrings {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to convert the value of CimProperty {0} to the property value of class {1}..
|
||||
/// </summary>
|
||||
internal static string ConvertCimPropertyToObjectPropertyFailed {
|
||||
get {
|
||||
return ResourceManager.GetString("ConvertCimPropertyToObjectPropertyFailed", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Could not get dispatch ID for {0} (error: {1})..
|
||||
/// </summary>
|
||||
|
@ -838,6 +847,15 @@ internal class ParserStrings {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Keyword '{0}' already defined in the configuration..
|
||||
/// </summary>
|
||||
internal static string DuplicateKeywordDefinition {
|
||||
get {
|
||||
return ResourceManager.GetString("DuplicateKeywordDefinition", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Duplicate named arguments '{0}' are not allowed..
|
||||
/// </summary>
|
||||
|
@ -1090,6 +1108,15 @@ internal class ParserStrings {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Property {0} of PowerShell class {1} is not declared as array type, but defined in its configuration instance as instance array type..
|
||||
/// </summary>
|
||||
internal static string ExpectArrayTypeOfPropertyInPSClass {
|
||||
get {
|
||||
return ResourceManager.GetString("ExpectArrayTypeOfPropertyInPSClass", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to An expression was expected after '('..
|
||||
/// </summary>
|
||||
|
@ -1430,6 +1457,15 @@ internal class ParserStrings {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to create an object of PowerShell class {0}..
|
||||
/// </summary>
|
||||
internal static string InstantiatePSClassObjectFailed {
|
||||
get {
|
||||
return ResourceManager.GetString("InstantiatePSClassObjectFailed", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to '{0}': Interface name expected..
|
||||
/// </summary>
|
||||
|
@ -1538,6 +1574,15 @@ internal class ParserStrings {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The hashtable supplied to the Desired State Configuration resource {0} is not valid. The key or value cannot be null or empty..
|
||||
/// </summary>
|
||||
internal static string InvalidHashtable {
|
||||
get {
|
||||
return ResourceManager.GetString("InvalidHashtable", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The member '{0}' is not valid. Valid members are
|
||||
///'{1}'..
|
||||
|
@ -1602,6 +1647,15 @@ internal class ParserStrings {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The username supplied to the Desired State Configuration resource {0} is not valid. The username cannot be null or empty..
|
||||
/// </summary>
|
||||
internal static string InvalidPassword {
|
||||
get {
|
||||
return ResourceManager.GetString("InvalidPassword", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The PowerShell data file '{0}' is invalid since it cannot be evaluated into a Hashtable object..
|
||||
/// </summary>
|
||||
|
@ -1665,6 +1719,15 @@ internal class ParserStrings {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The username supplied to the Desired State Configuration resource {0} is not valid. The username cannot be null or empty..
|
||||
/// </summary>
|
||||
internal static string InvalidUserName {
|
||||
get {
|
||||
return ResourceManager.GetString("InvalidUserName", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Expression is not allowed in a Using expression..
|
||||
/// </summary>
|
||||
|
@ -2925,6 +2988,15 @@ internal class ParserStrings {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Property {0} is not declared in PowerShell class {1}, but defined in its configuration instance..
|
||||
/// </summary>
|
||||
internal static string PropertyNotDeclaredInPSClass {
|
||||
get {
|
||||
return ResourceManager.GetString("PropertyNotDeclaredInPSClass", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The property '{0}' cannot be found on this object. Verify that the property exists and can be set..
|
||||
/// </summary>
|
||||
|
|
Binary file not shown.
|
@ -250,6 +250,15 @@ internal class RemotingErrorIdStrings {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to find vmcompute.dll. The Hyper-V role may not be enabled on this machine..
|
||||
/// </summary>
|
||||
internal static string CannotFindVmComputeDll {
|
||||
get {
|
||||
return ResourceManager.GetString("CannotFindVmComputeDll", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The call to Windows API GetStdHandle to get the Standard Error handle resulted in an error code: {0}..
|
||||
/// </summary>
|
||||
|
@ -538,6 +547,15 @@ internal class RemotingErrorIdStrings {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Could not find the toolkit, '{0}'. The toolkit must be a file named '{1}' within a 'Toolkits' directory in a module in the current module path..
|
||||
/// </summary>
|
||||
internal static string CouldNotFindToolkit {
|
||||
get {
|
||||
return ResourceManager.GetString("CouldNotFindToolkit", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to {0} is not a valid value for the parameter {1}. The value must be greater than or equal to 0..
|
||||
/// </summary>
|
||||
|
@ -767,6 +785,15 @@ internal class RemotingErrorIdStrings {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Could not parse visible command defintion for '{0}'. The visible command definition must be a hashtable with the keys of 'Name' and 'Parameters'. The value of the 'Parameters' key must be a collection of hashtables with the keys 'Name', and optionally either 'ValidateSet' or 'ValidatePattern'..
|
||||
/// </summary>
|
||||
internal static string DISCCommandModificationSyntax {
|
||||
get {
|
||||
return ResourceManager.GetString("DISCCommandModificationSyntax", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Company associated with this session configuration.
|
||||
/// </summary>
|
||||
|
@ -956,6 +983,15 @@ internal class RemotingErrorIdStrings {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to User roles (security groups), and the additional configuration settings that should be applied to them.
|
||||
/// </summary>
|
||||
internal static string DISCRoleDefinitionsComment {
|
||||
get {
|
||||
return ResourceManager.GetString("DISCRoleDefinitionsComment", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Version number of the schema used for this configuration file.
|
||||
/// </summary>
|
||||
|
@ -974,6 +1010,15 @@ internal class RemotingErrorIdStrings {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Toolkits to apply to this session configuration. This toolkit must be defined as a session configuration file named after that toolkit within a 'Toolkits' directory in a module in the current module path..
|
||||
/// </summary>
|
||||
internal static string DISCToolkitsToLoadComment {
|
||||
get {
|
||||
return ResourceManager.GetString("DISCToolkitsToLoadComment", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Specifies the transport options for this session configuration.
|
||||
/// </summary>
|
||||
|
@ -1629,6 +1674,33 @@ internal class RemotingErrorIdStrings {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The 'Roles' entry must be a hashtable, but was a {0}..
|
||||
/// </summary>
|
||||
internal static string InvalidRoleEntry {
|
||||
get {
|
||||
return ResourceManager.GetString("InvalidRoleEntry", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The key '{0}' is not valid in a toolkit or role definition..
|
||||
/// </summary>
|
||||
internal static string InvalidRoleToolkitKey {
|
||||
get {
|
||||
return ResourceManager.GetString("InvalidRoleToolkitKey", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Could not convert the value of the '{0}' role entry to a hashtable. The 'Roles' entry must be a hashtable with group names for keys, where the value associated with each key is another hashtable of session configuration properties for that role..
|
||||
/// </summary>
|
||||
internal static string InvalidRoleValue {
|
||||
get {
|
||||
return ResourceManager.GetString("InvalidRoleValue", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to {0} is not a valid schema value. Valid values are "http" and "https"..
|
||||
/// </summary>
|
||||
|
@ -3053,6 +3125,15 @@ internal class RemotingErrorIdStrings {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to create an instance of RemoteSessionHyperVSocketServer..
|
||||
/// </summary>
|
||||
internal static string RemoteSessionHyperVSocketServerConstructorFailure {
|
||||
get {
|
||||
return ResourceManager.GetString("RemoteSessionHyperVSocketServerConstructorFailure", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Remote transport error: {0}.
|
||||
/// </summary>
|
||||
|
@ -3837,6 +3918,15 @@ internal class RemotingErrorIdStrings {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to WSMan Initialization failed with error code: {0}..
|
||||
/// </summary>
|
||||
internal static string WSManInitFailed {
|
||||
get {
|
||||
return ResourceManager.GetString("WSManInitFailed", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The maximum number of WS-Man URI redirections to allow while connecting to a remote computer.
|
||||
/// </summary>
|
||||
|
|
Binary file not shown.
|
@ -1 +1 @@
|
|||
Subproject commit a1a05637ebc40bdbfef51f8435e8592587a4eb5d
|
||||
Subproject commit 8e014f44d72765f086fe516e870602d5a476076e
|
|
@ -1,15 +1,34 @@
|
|||
Describe "Test-Environment-Variables" {
|
||||
It "Should have environment variable" {
|
||||
It "Should have environment variables" {
|
||||
Get-Item ENV: | Should Not BeNullOrEmpty
|
||||
}
|
||||
|
||||
It "Should be able to access the members of the environment variable in two ways" {
|
||||
(Get-Item ENV:HOME).Value | Should be "/root"
|
||||
(Get-Item ENV:HOSTNAME).Value | Should Not BeNullOrEmpty
|
||||
(Get-Item ENV:PATH).Value | Should Not BeNullOrEmpty
|
||||
It "Should have a nonempty PATH" {
|
||||
$ENV:PATH | Should Not BeNullOrEmpty
|
||||
}
|
||||
|
||||
(ls ENV:HOME).Value | Should be "/root"
|
||||
(ls ENV:HOSTNAME).Value | Should Not BeNullOrEmpty
|
||||
(ls ENV:PATH).Value | Should Not BeNullOrEmpty
|
||||
It "Should contain /bin in the PATH" {
|
||||
$ENV:PATH | Should Match "/bin"
|
||||
}
|
||||
|
||||
It "Should be able to access the members of the environment variable" {
|
||||
$expected = /bin/bash -c "cd ~ && pwd"
|
||||
|
||||
(Get-Item ENV:HOME).Value | Should Be $expected
|
||||
}
|
||||
|
||||
It "Should be able to set the environment variables" {
|
||||
$expected = "this is a test environment variable"
|
||||
{ $ENV:TESTENVIRONMENTVARIABLE = $expected } | Should Not Throw
|
||||
|
||||
$ENV:TESTENVIRONMENTVARIABLE | Should Not BeNullOrEmpty
|
||||
$ENV:TESTENVIRONMENTVARIABLE | Should Be $expected
|
||||
|
||||
}
|
||||
|
||||
It "Should have the correct HOSTNAME" {
|
||||
$expected = /bin/hostname
|
||||
|
||||
$ENV:HOSTNAME | Should Be $expected
|
||||
}
|
||||
}
|
||||
|
|
139
src/pester-tests/Test-Remove-Item.Tests.ps1
Normal file
139
src/pester-tests/Test-Remove-Item.Tests.ps1
Normal file
|
@ -0,0 +1,139 @@
|
|||
Describe "Test-Remove-Item" {
|
||||
$testpath = "/tmp/"
|
||||
$testfile = "testfile.txt"
|
||||
$testfilepath = $testpath + $testfile
|
||||
Context "File removal Tests" {
|
||||
BeforeEach {
|
||||
New-Item -Name $testfile -Path $testpath -ItemType "file" -Value "lorem ipsum" -Force
|
||||
|
||||
Test-Path $testfilepath | Should Be $true
|
||||
|
||||
}
|
||||
|
||||
It "Should be able to be called on a regular file without error using the Path switch" {
|
||||
{ Remove-Item -Path $testfilepath } | Should Not Throw
|
||||
|
||||
Test-Path $testfilepath | Should Be $false
|
||||
}
|
||||
|
||||
It "Should be able to be called on a file without the Path switch" {
|
||||
{ Remove-Item $testfilepath } | Should Not Throw
|
||||
|
||||
Test-Path $testfilepath | Should Be $false
|
||||
}
|
||||
|
||||
It "Should be able to call the rm alias" {
|
||||
{ rm $testfilepath } | Should Not Throw
|
||||
|
||||
Test-Path $testfilepath | Should Be $false
|
||||
}
|
||||
|
||||
It "Should be able to call the del alias" {
|
||||
{ del $testfilepath } | Should Not Throw
|
||||
|
||||
Test-Path $testfilepath | Should Be $false
|
||||
}
|
||||
|
||||
It "Should be able to call the erase alias" {
|
||||
{ erase $testfilepath } | Should Not Throw
|
||||
|
||||
Test-Path $testfilepath | Should Be $false
|
||||
}
|
||||
|
||||
It "Should be able to call the ri alias" {
|
||||
{ ri $testfilepath } | Should Not Throw
|
||||
|
||||
Test-Path $testfilepath | Should Be $false
|
||||
}
|
||||
|
||||
It "Should not be able to remove a read-only document without using the force switch" {
|
||||
# Set to read only
|
||||
Set-ItemProperty -Path $testfilepath -Name IsReadOnly -Value $true
|
||||
|
||||
# attempt to remove the file
|
||||
{ Remove-Item $testfilepath -ErrorAction SilentlyContinue } | Should Not Throw
|
||||
|
||||
# validate
|
||||
Test-Path $testfilepath | Should Be $true
|
||||
|
||||
# remove using the -force switch on the readonly object
|
||||
Remove-Item $testfilepath -Force
|
||||
|
||||
# Validate
|
||||
Test-Path $testfilepath | Should Be $false
|
||||
}
|
||||
|
||||
It "Should be able to remove all files matching a regular expression with the include switch" {
|
||||
# Create multiple files with specific string
|
||||
New-Item -Name file1.txt -Path $testpath -ItemType "file" -Value "lorem ipsum"
|
||||
New-Item -Name file2.txt -Path $testpath -ItemType "file" -Value "lorem ipsum"
|
||||
New-Item -Name file3.txt -Path $testpath -ItemType "file" -Value "lorem ipsum"
|
||||
# Create a single file that does not match that string - already done in BeforeEach
|
||||
|
||||
# Delete the specific string
|
||||
Remove-Item /tmp/* -Include file*.txt
|
||||
# validate that the string under test was deleted, and the nonmatching strings still exist
|
||||
Test-path /tmp/file1.txt | Should Be $false
|
||||
Test-path /tmp/file2.txt | Should Be $false
|
||||
Test-path /tmp/file3.txt | Should Be $false
|
||||
Test-Path $testfilepath | Should Be $true
|
||||
|
||||
# Delete the non-matching strings
|
||||
Remove-Item $testfilepath
|
||||
|
||||
Test-Path $testfilepath | Should Be $false
|
||||
}
|
||||
|
||||
It "Should be able to not remove any files matching a regular expression with the exclude switch" {
|
||||
# Create multiple files with specific string
|
||||
New-Item -Name file1.wav -Path $testpath -ItemType "file" -Value "lorem ipsum"
|
||||
New-Item -Name file2.wav -Path $testpath -ItemType "file" -Value "lorem ipsum"
|
||||
|
||||
# Create a single file that does not match that string
|
||||
New-Item -Name file1.txt -Path $testpath -ItemType "file" -Value "lorem ipsum"
|
||||
|
||||
# Delete the specific string
|
||||
Remove-Item /tmp/file* -Exclude *.wav -Include *.txt
|
||||
|
||||
# validate that the string under test was deleted, and the nonmatching strings still exist
|
||||
Test-Path /tmp/file1.wav | Should Be $true
|
||||
Test-Path /tmp/file2.wav | Should Be $true
|
||||
Test-Path /tmp/file1.txt | Should Be $false
|
||||
|
||||
# Delete the non-matching strings
|
||||
Remove-Item /tmp/file1.wav
|
||||
Remove-Item /tmp/file2.wav
|
||||
|
||||
Test-Path /tmp/file1.wav | Should Be $false
|
||||
Test-Path /tmp/file2.wav | Should Be $false
|
||||
}
|
||||
}
|
||||
|
||||
Context "Directory Removal Tests" {
|
||||
$testdirectory = "/tmp/testdir"
|
||||
$testsubdirectory = $testdirectory + "/subd"
|
||||
BeforeEach {
|
||||
New-Item -Name "testdir" -Path "/tmp/" -ItemType "directory" -Force
|
||||
|
||||
Test-Path $testdirectory | Should Be $true
|
||||
}
|
||||
|
||||
It "Should be able to remove a directory" {
|
||||
{ Remove-Item $testdirectory } | Should Not Throw
|
||||
|
||||
Test-Path $testdirectory | Should Be $false
|
||||
}
|
||||
|
||||
It "Should be able to recursively delete subfolders" {
|
||||
New-Item -Name "subd" -Path $testdirectory -ItemType "directory"
|
||||
New-Item -Name $testfile -Path $testsubdirectory -ItemType "file" -Value "lorem ipsum"
|
||||
|
||||
$complexDirectory = $testsubdirectory + "/" + $testfile
|
||||
test-path $complexDirectory | Should Be $true
|
||||
|
||||
{ Remove-Item $testdirectory -Recurse} | Should Not Throw
|
||||
|
||||
Test-Path $testdirectory | Should Be $false
|
||||
}
|
||||
}
|
||||
}
|
|
@ -65,5 +65,30 @@ namespace PSTests
|
|||
Assert.Equal(username, Platform.NonWindowsGetUserName());
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void TestGetMachineName()
|
||||
{
|
||||
var startInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = @"/usr/bin/env",
|
||||
Arguments = "hostname",
|
||||
RedirectStandardOutput = true,
|
||||
UseShellExecute = false
|
||||
};
|
||||
using (Process process = Process.Start(startInfo))
|
||||
{
|
||||
// Get output of call to hostname without trailing newline
|
||||
string hostname = process.StandardOutput.ReadToEnd().Trim();
|
||||
process.WaitForExit();
|
||||
|
||||
// The process should return an exit code of 0 on success
|
||||
Assert.Equal(0, process.ExitCode);
|
||||
// It should be the same as what our platform code returns
|
||||
Assert.Equal(hostname, Platform.NonWindowsGetMachineName());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue