Skip to content

Commit

Permalink
Add smoke tests, fix issues #14 #15
Browse files Browse the repository at this point in the history
  • Loading branch information
stadub committed Sep 9, 2019
1 parent d869856 commit 855d4f0
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 241 deletions.
9 changes: 9 additions & 0 deletions 7Zip/7zip-Archive.SmokeTests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Import-Module .\7zip-Archive.psm1


ls -Exclude .git | New-ZipFile "scripts"
Test-ZipFileContent .\scripts.7z
Get-ZipFileContent -Archive .\scripts.7z
Remove-ZipFileContent -Archive .\scripts.7z -File "temp.log"
Read-ZipFile -Archive .\scripts.7z
Add-ZipFileContent -Path .\scripts.7z -FileName .\7zip-Archive.psd1
2 changes: 1 addition & 1 deletion 7Zip/7zip-Archive.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# RootModule = ''

# Version number of this module.
ModuleVersion = '1.0.4'
ModuleVersion = '1.1.0'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
2 changes: 1 addition & 1 deletion 7Zip/7zip-Archive.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

. $PSScriptRoot\Functions.ps1

CheckPsGalleryUpdate 7Zip "1.0.4"
szCheckPsGalleryUpdate 7Zip "1.1.0"

_Initalize

Expand Down
23 changes: 11 additions & 12 deletions 7Zip/Functions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

function _Initalize() {

$script:_binDir = Get-ProfileDir "7zip" "bin"
$script:_binDir = szGet-ProfileDir "7zip" "bin"
Write-Debug "The 7-zip is dir set to $_binDir"
$script:_7zWin = Join-Path $_binDir "7za.exe"
$script:_7zWinDownloadDir='https://www.7-zip.org/a/7za920.zip'
Expand All @@ -25,16 +25,16 @@ function Test-7ZipInstall {
Write-Output '7Zip didn''t downloaded.'
Write-Output 'Now script going to try to download it.'

$file = Get-TempFileName
$file = szGet-TempFileName
Write-Debug "Temp file: ${file}"

Receive-File "7-Zip" $file $_7zWinDownloadDir
szReceive-File "7-Zip" $file $_7zWinDownloadDir
Write-Debug "Extracting to directory ${_binDir}"
if ( -not (Test-Path $_binDir )) {
New-Item -Path $_binDir -ItemType 'Directory'
}

Extract-ZipFile -FileName "$file" -Path "$_binDir"
szExtract-ZipFile -FileName "$file" -Path "$_binDir"
}
$script:_7zPath = $script:_7zWin

Expand All @@ -56,7 +56,7 @@ function AddKeyArg {
$AllArgs = $null,
[string]$Key = $null
)
if( -not (Test-Empty $Key)){
if( -not (szTest-Empty $Key)){
$AllArgs += "-p$Key"
}
return $AllArgs
Expand Down Expand Up @@ -206,7 +206,6 @@ function Remove-ZipFileContent {
[Alias("Path","Name", "Archive", "p")]
[string]$ArchiveName,

[ValidateScript( { Test-Path $_ -pathType leaf })]
[Parameter(Position = 1, Mandatory = $true)]
[Alias("File", "f")]
[string]$FileName,
Expand Down Expand Up @@ -364,7 +363,7 @@ function New-ZipFile {
process {

$FileNames| ForEach-Object{
if( -not (Test-Empty $_) ){
if( -not (szTest-Empty $_) ){
Write-Debug "Adding file ""$_"""
$files += $_
}
Expand Down Expand Up @@ -432,7 +431,7 @@ function New-ZipFile {
}


if( -not (Test-Empty $([string]$SplitSize) )){
if( -not (szTest-Empty $([string]$SplitSize) )){

$factorName="b"
switch ( $SplitSizeFactor )
Expand Down Expand Up @@ -518,7 +517,7 @@ function Test-ZipFileContent {
$AllArgs = @('t', "$ArchiveName")


if( -not (Test-Empty $FileName) ){
if( -not (szTest-Empty $FileName) ){
$AllArgs += "$FileName"
}

Expand Down Expand Up @@ -586,12 +585,12 @@ function Get-ZipFileContent {

$AllArgs = @('e', "$ArchiveName")

if( -not (Test-Empty $FileName) ){
if( -not (szTest-Empty $FileName) ){
$AllArgs += "$FileName"
}

if( -not (Test-Empty $destFolder) ){
CreateFolderIfNotExist "${destFolder}"
if( -not (szTest-Empty $destFolder) ){
szCreateFolderIfNotExist "${destFolder}"
$AllArgs += "-o$destFolder"
}

Expand Down
7 changes: 7 additions & 0 deletions 7Zip/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,13 @@ Test-ZipFileContent - Perform zip file check

## Changelog


### [v1.1.0](https://github.com/stadub/PowershellScripts/releases/tag/v0.9.5) Spet 9, 2019

* Fix Remove-ZipFileContent error #15
* Fix szc Allias #14
* Add smoke tests

### [v1.0.0](https://github.com/stadub/PowershellScripts/releases/tag/v0.4.0)

*First public release.
Expand Down
Loading

0 comments on commit 855d4f0

Please sign in to comment.