Skip to content

Commit dbb82d1

Browse files
authored
test: publishing (#67)
* add publishing tests * lint
1 parent c85b27c commit dbb82d1

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
testResults.xml
2+
temp

tests/publishing.tests.ps1

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Describe 'Publishing' {
2+
It 'Test-ModuleManifest' {
3+
Test-ModuleManifest -Path "$PSScriptRoot/../modules/Sentry/Sentry.psd1" -Verbose
4+
}
5+
6+
It 'Publish-Module' {
7+
$tempModuleDir = "$PSScriptRoot/temp/Sentry"
8+
Remove-Item $tempModuleDir -Recurse -ErrorAction SilentlyContinue
9+
Copy-Item "$PSScriptRoot/../modules/Sentry" -Destination $tempModuleDir -Recurse
10+
11+
# Update version in the module manifest
12+
$content = Get-Content "$tempModuleDir/Sentry.psd1"
13+
$changes = 0
14+
for ($i = 0; $i -lt $content.Length; $i++)
15+
{
16+
if ($content[$i] -match "^(\s*ModuleVersion\s*=\s*)'[^']*'\s*$")
17+
{
18+
$content[$i] = $matches[1] + "'9.9.9'"
19+
$changes++
20+
}
21+
if ($content[$i] -match "^(\s*Prerelease\s*=\s*)'[^']*'\s*$")
22+
{
23+
$content[$i] = $matches[1] + "'test'"
24+
$changes++
25+
}
26+
}
27+
$changes | Should -Be 2
28+
$content | Out-File "$tempModuleDir/Sentry.psd1"
29+
30+
Publish-Module -Path $tempModuleDir -NuGetApiKey 'test' -Verbose -WhatIf
31+
}
32+
}

0 commit comments

Comments
 (0)