Skip to content

Commit

Permalink
Issue-dsccommunity#333 Add default values for settings in unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob-S committed Jun 17, 2020
1 parent 20f0b89 commit 2ba9fff
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 2 deletions.
Expand Up @@ -1833,7 +1833,7 @@ function Get-CurrentResource
{
if ($task.settings.CimInstanceProperties.Item('MultipleInstances').Value -eq 3)
{
$MultpleInstances = 'StopExisting'
$MultipleInstances = 'StopExisting'
}
}

Expand Down
99 changes: 98 additions & 1 deletion tests/Unit/DSC_ScheduledTask.Tests.ps1
Expand Up @@ -186,6 +186,10 @@ try
CimClassName = 'MSFT_TaskTimeTrigger'
}
})
Settings = [pscustomobject] @{
Enabled = $true
MultipleInstances = 'IgnoreNew'
}
Principal = @{
UserId = 'SYSTEM'
}
Expand Down Expand Up @@ -348,6 +352,10 @@ try
}
}
)
Settings = [pscustomobject] @{
Enabled = $true
MultipleInstances = 'IgnoreNew'
}
Principal = [pscustomobject] @{
UserId = 'SYSTEM'
}
Expand Down Expand Up @@ -398,6 +406,10 @@ try
}
}
)
Settings = [pscustomobject] @{
Enabled = $true
MultipleInstances = 'IgnoreNew'
}
Principal = [pscustomobject] @{
UserId = 'SYSTEM'
}
Expand Down Expand Up @@ -443,6 +455,10 @@ try
}
}
)
Settings = [pscustomobject] @{
Enabled = $true
MultipleInstances = 'IgnoreNew'
}
Principal = [pscustomobject] @{
UserId = 'SYSTEM'
}
Expand Down Expand Up @@ -493,6 +509,10 @@ try
}
}
)
Settings = [pscustomobject] @{
Enabled = $true
MultipleInstances = 'IgnoreNew'
}
Principal = [pscustomobject] @{
UserId = 'SYSTEM'
}
Expand Down Expand Up @@ -537,6 +557,10 @@ try
}
}
)
Settings = [pscustomobject] @{
Enabled = $true
MultipleInstances = 'IgnoreNew'
}
Principal = [pscustomobject] @{
UserId = 'SYSTEM'
}
Expand Down Expand Up @@ -583,6 +607,10 @@ try
}
}
)
Settings = [pscustomobject] @{
Enabled = $true
MultipleInstances = 'IgnoreNew'
}
Principal = [pscustomobject] @{
UserId = 'SYSTEM'
}
Expand Down Expand Up @@ -629,6 +657,10 @@ try
}
}
)
Settings = [pscustomobject] @{
Enabled = $true
MultipleInstances = 'IgnoreNew'
}
Principal = [pscustomobject] @{
UserId = 'WrongUser'
}
Expand Down Expand Up @@ -681,6 +713,10 @@ try
}
}
)
Settings = [pscustomobject] @{
Enabled = $true
MultipleInstances = 'IgnoreNew'
}
Principal = [pscustomobject] @{
UserId = 'DEMO\RightUser'
LogonType = 'Password'
Expand Down Expand Up @@ -735,6 +771,10 @@ try
}
}
)
Settings = [pscustomobject] @{
Enabled = $true
MultipleInstances = 'IgnoreNew'
}
Principal = [pscustomobject] @{
UserId = 'DEMO\RightUser'
RunLevel = 'Limited'
Expand Down Expand Up @@ -789,6 +829,10 @@ try
}
}
)
Settings = [pscustomobject] @{
Enabled = $true
MultipleInstances = 'IgnoreNew'
}
Principal = [pscustomobject] @{
UserId = 'SYSTEM'
}
Expand Down Expand Up @@ -841,6 +885,10 @@ try
}
}
)
Settings = [pscustomobject] @{
Enabled = $true
MultipleInstances = 'IgnoreNew'
}
Principal = [pscustomobject] @{
UserId = 'SYSTEM'
}
Expand Down Expand Up @@ -893,8 +941,9 @@ try
}
}
)
Settings = [pscustomobject] @{
Settings = [pscustomobject] @{
Enabled = $true
MultipleInstances = 'IgnoreNew'
}
Principal = [pscustomobject] @{
UserId = 'SYSTEM'
Expand Down Expand Up @@ -953,6 +1002,7 @@ try
Settings = [pscustomobject] @{
Enabled = $true
ExecutionTimeLimit = "PT$([System.TimeSpan]::Parse($testParameters.RepeatInterval).TotalSeconds + 60)S"
MultipleInstances = 'IgnoreNew'
}
Principal = [pscustomobject] @{
UserId = 'SYSTEM'
Expand Down Expand Up @@ -1020,6 +1070,7 @@ try
}
ExecutionTimeLimit = "PT$([System.TimeSpan]::Parse($testParameters.ExecutionTimeLimit).TotalMinutes)M"
RestartInterval = "PT$([System.TimeSpan]::Parse($testParameters.RestartInterval).TotalMinutes)M"
MultipleInstances = 'IgnoreNew'
}
Principal = [pscustomobject] @{
UserId = 'SYSTEM'
Expand Down Expand Up @@ -1070,6 +1121,7 @@ try
)
Settings = [pscustomobject] @{
Enabled = $false
MultipleInstances = 'IgnoreNew'
}
Principal = [pscustomobject] @{
UserId = 'SYSTEM'
Expand Down Expand Up @@ -1120,6 +1172,7 @@ try
)
Settings = [pscustomobject] @{
Enabled = $false
MultipleInstances = 'IgnoreNew'
}
Principal = [pscustomobject] @{
UserId = 'SYSTEM'
Expand Down Expand Up @@ -1174,6 +1227,7 @@ try
)
Settings = [pscustomobject] @{
Enabled = $false
MultipleInstances = 'IgnoreNew'
}
Principal = [pscustomobject] @{
UserId = 'SYSTEM'
Expand Down Expand Up @@ -1256,6 +1310,7 @@ try
}
ExecutionTimeLimit = "PT$([System.TimeSpan]::Parse($testParameters.ExecutionTimeLimit).TotalMinutes)M"
RestartInterval = "PT$([System.TimeSpan]::Parse($testParameters.RestartInterval).TotalMinutes)M"
MultipleInstances = 'IgnoreNew'
}
Principal = [pscustomobject] @{
UserId = 'SYSTEM'
Expand Down Expand Up @@ -1321,6 +1376,7 @@ try
}
ExecutionTimeLimit = "PT$([System.TimeSpan]::Parse($testParameters.ExecutionTimeLimit).TotalMinutes)M"
RestartInterval = "PT$([System.TimeSpan]::Parse($testParameters.RestartInterval).TotalMinutes)M"
MultipleInstances = 'IgnoreNew'
}
Principal = [pscustomobject] @{
UserId = 'SYSTEM'
Expand Down Expand Up @@ -1373,6 +1429,10 @@ try
}
}
)
Settings = [pscustomobject] @{
Enabled = $true
MultipleInstances = 'IgnoreNew'
}
Principal = [pscustomobject] @{
UserId = 'SYSTEM'
}
Expand Down Expand Up @@ -1424,6 +1484,10 @@ try
}
}
)
Settings = [pscustomobject] @{
Enabled = $true
MultipleInstances = 'IgnoreNew'
}
Principal = [pscustomobject] @{
UserId = 'SYSTEM'
}
Expand Down Expand Up @@ -1475,6 +1539,10 @@ try
}
}
)
Settings = [pscustomobject] @{
Enabled = $true
MultipleInstances = 'IgnoreNew'
}
Principal = [pscustomobject] @{
UserId = 'SYSTEM'
}
Expand Down Expand Up @@ -1760,6 +1828,10 @@ try
}
}
)
Settings = [pscustomobject] @{
Enabled = $true
MultipleInstances = 'IgnoreNew'
}
Principal = [pscustomobject] @{
UserId = 'NT AUTHORITY\' + $testParameters.BuiltInAccount
LogonType = 'ServiceAccount'
Expand Down Expand Up @@ -1830,6 +1902,10 @@ try
}
}
)
Settings = [pscustomobject] @{
Enabled = $true
MultipleInstances = 'IgnoreNew'
}
Principal = [pscustomobject] @{
UserId = 'gMSA$'
}
Expand Down Expand Up @@ -1877,6 +1953,10 @@ try
}
}
)
Settings = [pscustomobject] @{
Enabled = $true
MultipleInstances = 'IgnoreNew'
}
Principal = [pscustomobject] @{
UserId = 'update_gMSA$'
}
Expand Down Expand Up @@ -1930,6 +2010,10 @@ try
}
}
)
Settings = [pscustomobject] @{
Enabled = $true
MultipleInstances = 'IgnoreNew'
}
}
}

Expand Down Expand Up @@ -1960,6 +2044,10 @@ try
}
}
)
Settings = [pscustomobject] @{
Enabled = $true
MultipleInstances = 'IgnoreNew'
}
}
}

Expand Down Expand Up @@ -2004,6 +2092,10 @@ try
}
}
)
Settings = [pscustomobject] @{
Enabled = $true
MultipleInstances = 'IgnoreNew'
}
}
}

Expand Down Expand Up @@ -2034,6 +2126,10 @@ try
}
}
)
Settings = [pscustomobject] @{
Enabled = $true
MultipleInstances = 'IgnoreNew'
}
}
}

Expand Down Expand Up @@ -2198,6 +2294,7 @@ try
)
Settings = [pscustomobject] @{
Enabled = $testParameters.Enable
MultipleInstances = 'IgnoreNew'
}
}
}
Expand Down

0 comments on commit 2ba9fff

Please sign in to comment.