-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTermbin4PS.Tests.ps1
69 lines (61 loc) · 2.57 KB
/
Termbin4PS.Tests.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<#
Termbin4ps.Tests.ps1, tests for the Termbin4PS module
Copyright (C) 2020-2024 Colin Cogle
Online at <https://github.com/rhymeswithmogul/Termbin4PS>
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
#>
Context 'Validate the module files' {
BeforeAll {
$dir = Split-Path -Parent $PSCommandPath
$psm1File = Join-Path -Path $dir -ChildPath 'Termbin4PS.psm1'
$enUSHelpFolder = Join-Path -Path $dir -ChildPath 'en-US'
$ModuleHelpFile = Join-Path -Path $enUSHelpFolder -ChildPath 'Termbin4PS-help.xml'
}
It 'has a module manifest' {
Join-Path -Path $dir -ChildPath 'Termbin4PS.psd1' | Should -Exist
}
It 'has a root module' {
$psm1File | Should -Exist
}
It 'has a valid root module' {
$code = Get-Content -Path $psm1File -ErrorAction Stop
$errors = $null
$null = [Management.Automation.PSParser]::Tokenize($code, [ref]$errors)
$errors.Count | Should -Be 0
}
It 'has a conceptual help file' {
Join-Path -Path $enUSHelpFolder -ChildPath 'about_Termbin4PS.help.txt' | Should -Exist
}
It 'has a module help file' {
$ModuleHelpFile | Should -Exist
}
It 'has a valid module help file' {
$code = [Xml](Get-Content -Path $ModuleHelpFile -ErrorAction Stop)
$code.Count | Should -Be 1
}
}
Describe 'Out-Termbin' {
BeforeAll {
$psd1File = Join-Path -Path (Split-Path -Parent $PSCommandPath) -ChildPath 'Termbin4PS.psd1'
Import-Module -Name $psd1File
$TestString = 'This is a Pester test.'
}
It 'Returns a URL on success' {
$TestString | Out-Termbin | Should -BeLike 'https://termbin.com/*'
}
It 'Returns nothing when the timeout is exceeded' {
$TestString | Out-Termbin -Timeout 1 -ErrorAction SilentlyContinue | Should -Be ''
}
}
AfterAll {
Remove-Module -Name 'Termbin4PS' -Force
}