File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # $projectRoot = Resolve-Path "F:\rdcinmotiv\Plumber\Tests\.."
2+ $projectRoot = Resolve-Path " $PSScriptRoot \.."
3+ $moduleRoot = Split-Path (Resolve-Path " $projectRoot \*\*.psm1" )
4+ $moduleName = Split-Path $moduleRoot - Leaf
5+
6+ Write-Host " Testing Project $moduleName "
7+ Describe " PSScriptAnalyzer rule-sets" - Tag Build {
8+ $IgnoreRules = @ (
9+ ' PSAvoidUsingWriteHost'
10+ ' PSAvoidUsingPositionalParameters'
11+ ' PSAvoidUsingConvertToSecureStringWithPlainText'
12+ ' PSAvoidTrailingWhitespace'
13+ ' PSUseShouldProcessForStateChangingFunctions'
14+ )
15+ $Rules = Get-ScriptAnalyzerRule | Where-Object { $_.RuleName -notin $IgnoreRules }
16+ $scriptfiles = Get-ChildItem - Path $projectRoot - File - recurse - Include ' *.ps1' | Where-Object { ($_.Directory ).Name -ne ' TestSets' }
17+ foreach ( $Script in $scriptfiles ) {
18+ Context " Script '$ ( $script.FullName ) '" {
19+ $results = Invoke-ScriptAnalyzer - Path $script.FullName - includeRule $Rules
20+ if ($results ) {
21+ foreach ($rule in $results ) {
22+ It $rule.RuleName {
23+ $message = " {0} Line {1}: {2}" -f $rule.Severity , $rule.Line , $rule.message
24+ $message | Should - Be " "
25+ }
26+
27+ }
28+ } else {
29+ It " Should not fail any rules" {
30+ $results | Should BeNullOrEmpty
31+ }
32+ }
33+ }
34+ }
35+ }
36+
37+
Original file line number Diff line number Diff line change 1+ # region Formalities
2+
3+ # Get Module Paths
4+
5+ # Do this if running in an IDE
6+ # $here = 'F:\rdcinmotiv\<ModuleName>\Tests'
7+ $here = Split-Path - Parent $MyInvocation.MyCommand.Path
8+
9+ $projectRoot = Resolve-Path $here \..
10+ $ModuleManifest = Resolve-Path " $projectRoot \*\*.psd1"
11+ $ModuleRoot = Split-Path $ModuleManifest - Parent
12+ $moduleName = Split-Path $ModuleRoot - Leaf
13+
14+ # Import Module
15+ # Module Root [ProjectRoot]\ModuleName\ should contain file ModuleName.psm1
16+ Write-host " Loading Module $moduleName "
17+ Remove-Module $moduleName - Force - ErrorAction SilentlyContinue
18+ Import-Module $ModuleRoot - force
19+
20+ $MockSplat = @ {ModuleName = $moduleName }
21+
22+ Write-Verbose $MockSplat
23+
24+
25+ # endregion
Original file line number Diff line number Diff line change 1+ Key;Development;Test;Acceptance;Staging;Production
2+ SqlServerinstance;imb-app-d-001.westeurope.cloudapp.azure.com;imb-app-d-001.westeurope.cloudapp.azure.com;uat001.inmotiv.combell;uat001.inmotiv.combell;sql001.inmotiv.combell
3+ DatabaseName;NissanCRMDevelopment;NissanCRMTest;NissanCRMAcceptance;NissanCRMStaging;NissanCRM
4+ DataWarehouseName;NissanCRMDatawarehouseDevelopment;NissanCRMDatawarehouseTest;NissanCRMDatawarehouseAcceptance;NissanCRMDatawarehouseStaging;NissanCRMDatawarehouse
5+ SmtpServer;localhost;localhost;uatmail.inmotiv.combell;uatmail.inmotiv.combell;mail.inmotiv.combell
6+ LeadErrorsSender;[Dev] Leads Errors;[Test] Leads Errors;[Acc] Leads Errors;[Stg] Leads Errors;Leads Errors
7+ LeadErrorsSenderAddress;noreply@inmotiv.be;noreply@inmotiv.be;noreply@inmotiv.be;noreply@inmotiv.be;noreply@inmotiv.be
Original file line number Diff line number Diff line change 1+ # Settings
2+ $ModuleName = ' PSSMit'
3+ $ModulePath = ' \\localhost\Nissan.Components\'
4+ $ModuleVersion = ' '
5+
6+ $global :ServerParams = @ {
7+ ServerInstance = ' #SqlServerInstance#'
8+ Database = ' #DatabaseName#'
9+ }
10+
11+ $InputFolder = " \\localhost\Nissan.FileRepository\Leads\in\FTP"
12+ $TargetFolder = " \\localhost\Nissan.FileRepository\Leads\in"
13+ $errorFolder = " \\localhost\Nissan.FileRepository\Leads\in\error"
14+
15+
16+ $log = " \\localhost\Nissan.FileRepository\Leads\Logs\$ ( ($MyInvocation.MyCommand ).Name) _$ ( Get-Date - format FileDateTime) .log"
17+
18+ # Start Log and Commands
19+ Start-Transcript - Path $log
20+
21+ Import-Module " $ModulePath$ModuleName " - force
22+
23+ Write-Host " $ModuleName $ ( (Get-Module $ModuleName ).Version) Loaded..."
24+
25+ Get-SmitDataSourceFiles - SourcePath $InputFolder - DataFileType 7 | New-SmitDataFile - TargetFolder $TargetFolder
26+
27+ Stop-Transcript
28+
Original file line number Diff line number Diff line change 1+ HostName =# SqlServerinstance#
2+ DatabaseName =# DatabaseName#
3+ DataWarehouseName =# DataWarehouseName#
4+ InputFolder =InputFolder
5+ OutputFolder =OutputFolder
6+ TemplateFile =TemplateFile
7+ SmtpServer =# SmtpServer#
8+ EmailSenderName =# LeadErrorsSender#
9+ EmailSenderAddress =# LeadErrorsSenderAddress#
10+ sadfasdf =asdf
11+ as =dasdf
12+ asfsadfsasdfasdf
You can’t perform that action at this time.
0 commit comments