-
Notifications
You must be signed in to change notification settings - Fork 40
Description
This is a mega-issue that divides the tests to be added to Compress-Archive. This list is not complete, and more tests will be added over time.
[x] indicates the test has been added to Compress-Archive.Tests.ps1.
[ ] indices the test has not yet been added.
All tests will be written in Pester 5. Old tests will be updated.
Parameter set validation tests
-
Validate errors from empty or null
-Pathand-DestinationPathparameters -
Validate errors from non-existent
-Path -
Validate errors from non-existent
-LiteralPath -
Validate error when duplicate paths are supplied to
-Path -
Validate error when duplicate paths are supplied to
-LiteralPath -
Validate source path can be at SystemDrive location
-
Validate error when
-Pathcontains duplicate paths [Duplicate Paths] -
Validate error when
-LiteralPathcontains duplicate paths [Duplicate Paths] -
Throws an error when Path and DestinationPath are the same and -Update is specified
-
Throws an error when Path and DestinationPath are the same and -Overwrite is specified
-
Throws an error when LiteralPath and DestinationPath are the same and -Update is specified
-
Throws an error when LiteralPath and DestinationPath are the same and -Overwrite is specified
Can't be tested:
- Throws an error when LiteralPath and DestinationPath are the same (cannot be tested -- others error will be thrown)
- Throws an error when Path and DestinationPath are the same (cannot be tested -- others error will be thrown)
-DestinationPath and -WriteMode Overwrite Tests
-
Throws a terminating error when archive file already exists and -Update and -Overwrite parameters are not specified
-
Throws a terminating error when archive file exists and -Update is specified but the archive is read-only
-
Throws a terminating error when archive already exists as a directory and -Update and -Overwrite parameters are not specified
-
Throws a terminating error when DestinationPath is a directory and -Update is specified
-
Throws a terminating error when DestinationPath is a folder containing at least 1 item and Overwrite is specified
-
Throws a terminating error when archive does not exist and -Update mode is specified
-
Overwrites a directory containing no items when -Overwrite is specified
-
Overwrites an archive that already exists
- Ensure all previous contents of the archive are not retained unless passed
-
Throws a terminating error when trying to overwrite DestinationPath which is the empty working directory
-Action tests
- Throws a terminating error when an incorrect value is supplied to -Action
- -Action Create works
Not needed:
- -Action Update works (not needed since we have tests for update)
- -Action Overwrite works (not needed since we have tests for overwrite)
Special and Wildcard Characters
-
Accepts DestinationPath parameter with wildcard characters that resolves to one path
-
Accepts LiteralPath parameter for a directory with wildcard characters in the directory name
-
[NEEDED] Accepts DestinationPath parameter with [ but no matching ]
-
Accepts LiteralPath parameter for a file with wildcards in the filename
Basic functional tests
- Compresses a single file
- Compresses a non-empty directory
- Compresses an empty directory
- Compresses multiple files
- Compresses multiple files and a single empty directory
- Compresses multiple files and a single non-empty directory
- Compresses multiple files and non-empty directories
- Compresses multiple files, non-empty directories, and an empty directory
- Compresses a directory containing files, non-empty directories, and an empty directory can be compressed"
- Compresses a zero-byte file
Zip-specific tests
- Compresses a file whose last write time is <1980
- Compresses a directory whose last write time is <1980
- Writes a warning when compressing a file whose last write time is before 1980
- Writes a warning when compressing a directory whose last write time is before 1980
- Creates an archive containing files > 4GB
- Creates an archive > 4GB in size
-PassThru parameter
- Returns an object of type System.IO.FileInfo when PassThru is specified
- Does not return an object when PassThru is not specified
- Does not return an object when PassThru is false
-Update parameter
- Does not throw an error when -Update is specified and the archive already exists
- Appends a file to an archive when -WriteMode Update is specified
- Modifies a pre-existing file in an archive when -WriteMode Update is specified
- Adds directory's children when updating a directory in the archive
Notes:
- Ensure pre-existing files and directories are not replaced when updating an archive
-CompressionLevel parameter
- Throws an error when an invalid value is supplied to CompressionLevel"
File permissions, locked files, hidden files, symbolic links, etc.
-
Skips archiving a file in use
-
Compresses a read-only file
-
Compresses a hidden file
-
Compresses a hidden directory
-
Compresses a directory containing a hidden file and directory
Pipelining
- Creates an archives when paths are passed via pipeline
- Creates an archives when paths are passed to -Path via pipeline by name
- Creates an archives when paths are passed to -LiteralPath via pipeline by name
Archive formats and -Format parameter
- Throws an error when an invalid value is supplied to -Format
- Creates a zip archive when -Format is not specified and the destination path does not have a matching extension
- Emits a warning when DestinationPath does not have an extension that matches the value of -Format
- Emits a warning when DestinationPath does not have an extension that matches any extension for a supported archive format
- Emits a warning when DestinationPath has no extension and -Format is specified
- Emits a warning when DestinationPath has no extension and -Format is not specified
- Does not emit a warning when DestinationPath has an extension that matches the value supplied to -Format
- Does not emit a warning when DestinationPath has a .zip extension and -Format is not specified
Path Structure Preservation Tests
- Creates an archive containing only a file when the path to that file is not relative to the working directory
- Compressing a relative path to a file creates an archive containing that file and its parent directories
- Compressing a relative path containing .. behaves like compressing an absolute path
- Compressing a relative path containing ~ works when the home directory is relative to the working directory
- Compressing a relative path containing wildcard characters preserves the relative directory structure
- Validate
-Pathcan be a relative path - Validate
-LiteralPathcan be a relative path - Validate
-DestinatonPathcan be a relative path