Skip to content

Commit

Permalink
Enhancement (ci): Add integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
leojonathanoh committed Sep 8, 2023
1 parent 979dd36 commit d067b67
Show file tree
Hide file tree
Showing 4 changed files with 234 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/PSModulePublisher/Invoke-PSModulePublisher.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Describe "Invoke-PSModulePublisher" -Tag 'Integration' {
$moduleDir = $PSScriptRoot
$mockModuleRepoDir = Resolve-Path "$PSScriptRoot/../../test/Mock-Module"
$mockModuleManifest = "$mockModuleRepoDir/src/Mock-Module/Mock-Module.psd1"

BeforeEach {
Push-Location $mockModuleRepoDir
}
AfterEach {
Pop-Location
}
It "Runs Invoke-Build.ps1" {
$moduleManifest = & "$moduleDir/Public/Invoke-Build.ps1"
$moduleManifest | Should -Be $mockModuleManifest
}
It "Runs Invoke-Publish.ps1" {
$env:MODULE_VERSION = '0.0.0'
$env:NUGET_API_KEY = 'xxx'
& "$moduleDir/Public/Invoke-Publish.ps1" -ModuleManifestPath $mockModuleManifest -Repository PSGallery -DryRun
}
It "Runs Invoke-Test.ps1" {
& "$moduleDir/Public/Invoke-Test.ps1" -ModuleManifestPath $mockModuleManifest
}
}
62 changes: 62 additions & 0 deletions test/Mock-Module/build/definitions/modulemanifest.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# - Initial setup: Fill in the GUID value. Generate one by running the command 'New-GUID'. Then fill in all relevant details.
# - Ensure all relevant details are updated prior to publishing each version of the module.
# - To simulate generation of the manifest based on this definition, run the included development entrypoint script Invoke-PSModulePublisher.ps1.
# - To publish the module, tag the associated commit and push the tag.
@{
RootModule = 'Mock-Module.psm1'
# ModuleVersion = '' # Value will be set for each publication based on the tag ref. Defaults to '0.0.0' in development environments and regular CI builds
GUID = 'e3df9fcc-9f83-4c93-9d06-4d2523376af7'
Author = 'The Oh Brothers'
CompanyName = 'The Oh Brothers'
Copyright = '(c) 2023 The Oh Brothers'
Description = 'Some description'
PowerShellVersion = '3.0'
# PowerShellHostName = ''
# PowerShellHostVersion = ''
# DotNetFrameworkVersion = ''
# CLRVersion = ''
# ProcessorArchitecture = ''
# RequiredModules = @(
# @{
# ModuleName = "PSMockModule"
# RequiredVersion = '0.0.2'
# }
# )
# RequiredAssemblies = @()
# ScriptsToProcess = @()
# TypesToProcess = @()
# FormatsToProcess = @()
# NestedModules = @()
FunctionsToExport = @(
Get-ChildItem $PSScriptRoot/../../src/Mock-Module/Public -Exclude *.Tests.ps1 | % { $_.BaseName }
)
CmdletsToExport = @()
VariablesToExport = @()
AliasesToExport = @()
# DscResourcesToExport = @()
# ModuleList = @()
# FileList = @(
# & {
# Set-Location $PSScriptRoot/../../../src/Generate-DockerImageVariants/
# Get-ChildItem -File -Recurse -Force | Resolve-Path -Relative
# Set-Location -
# }
# )
PrivateData = @{
# PSData = @{ # Properties within PSData will be correctly added to the manifest via Update-ModuleManifest without the PSData key. Leave the key commented out.
Tags = @(
'mock'
'module'
)
LicenseUri = 'https://raw.githubusercontent.com/theohbrothers/Mock-Module/master/LICENSE'
ProjectUri = 'https://github.com/theohbrothers/Mock-Module'
# IconUri = ''
# ReleaseNotes = ''
# Prerelease = ''
# RequireLicenseAcceptance = $false
ExternalModuleDependencies = @()
# }
# HelpInfoURI = ''
# DefaultCommandPrefix = ''
}
}
132 changes: 132 additions & 0 deletions test/Mock-Module/src/Mock-Module/Mock-Module.psd1
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
#
# Module manifest for module 'Mock-Module'
#
# Generated by: The Oh Brothers
#
# Generated on: 09/08/2023
#

@{

# Script module or binary module file associated with this manifest.
RootModule = 'Mock-Module.psm1'

# Version number of this module.
ModuleVersion = '0.0.0'

# Supported PSEditions
# CompatiblePSEditions = @()

# ID used to uniquely identify this module
GUID = 'e3df9fcc-9f83-4c93-9d06-4d2523376af7'

# Author of this module
Author = 'The Oh Brothers'

# Company or vendor of this module
CompanyName = 'The Oh Brothers'

# Copyright statement for this module
Copyright = '(c) 2023 The Oh Brothers'

# Description of the functionality provided by this module
Description = 'Some description'

# Minimum version of the PowerShell engine required by this module
PowerShellVersion = '3.0'

# Name of the PowerShell host required by this module
# PowerShellHostName = ''

# Minimum version of the PowerShell host required by this module
# PowerShellHostVersion = ''

# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# DotNetFrameworkVersion = ''

# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# ClrVersion = ''

# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
# RequiredModules = @()

# Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @()

# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()

# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @()

# Format files (.ps1xml) to be loaded when importing this module
# FormatsToProcess = @()

# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
# NestedModules = @()

# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = @()

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @()

# Variables to export from this module
# VariablesToExport = @()

# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = @()

# DSC resources to export from this module
# DscResourcesToExport = @()

# List of all modules packaged with this module
# ModuleList = @()

# List of all files packaged with this module
# FileList = @()

# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{

PSData = @{

# Tags applied to this module. These help with module discovery in online galleries.
Tags = 'mock','module'

# A URL to the license for this module.
LicenseUri = 'https://raw.githubusercontent.com/theohbrothers/Mock-Module/master/LICENSE'

# A URL to the main website for this project.
ProjectUri = 'https://github.com/theohbrothers/Mock-Module'

# A URL to an icon representing this module.
# IconUri = ''

# ReleaseNotes of this module
# ReleaseNotes = ''

# Prerelease string of this module
# Prerelease = ''

# Flag to indicate whether the module requires explicit user acceptance for install/update/save
# RequireLicenseAcceptance = $false

# External dependent modules of this module
# ExternalModuleDependencies = @()

} # End of PSData hashtable

} # End of PrivateData hashtable

# HelpInfo URI of this module
# HelpInfoURI = ''

# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''

}

16 changes: 16 additions & 0 deletions test/Mock-Module/src/Mock-Module/Mock-Module.psm1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
$script:MODULE_BASE_DIR = Split-Path $MyInvocation.MyCommand.Path -Parent
# $script:MODULE_HELPER_DIR = Join-Path $MODULE_BASE_DIR 'Helper'
# $script:MODULE_PRIVATE_DIR = Join-Path $MODULE_BASE_DIR 'Private'
# $script:MODULE_PUBLIC_DIR = Join-Path $MODULE_BASE_DIR 'Public'

# Get-ChildItem "$script:MODULE_HELPER_DIR/*.ps1" -Exclude *.Tests.ps1 | % {
# . $_.FullName
# }

# Get-ChildItem "$script:MODULE_PRIVATE_DIR/*.ps1" -Exclude *.Tests.ps1 | % {
# . $_.FullName
# }

# Get-ChildItem "$script:MODULE_PUBLIC_DIR/*.ps1" -Exclude *.Tests.ps1 | % {
# . $_.FullName
# }

0 comments on commit d067b67

Please sign in to comment.