aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--spec/02_src_spec.sh34
-rw-r--r--spec/03_contrib_spec.sh42
2 files changed, 75 insertions, 1 deletions
diff --git a/spec/02_src_spec.sh b/spec/02_src_spec.sh
index 561bfe5..c5584ec 100644
--- a/spec/02_src_spec.sh
+++ b/spec/02_src_spec.sh
@@ -93,4 +93,38 @@ Describe 'Main toolchain'
The output should eq "$2"
End
End
+ Describe 'cpt-search'
+ It "searches packages inside the \$CPT_PATH and the system database"
+ When run script src/cpt-search dummy-pkg
+ The line 1 of output should eq "$CPT_PATH/dummy-pkg"
+ The line 2 of output should eq "$CPT_ROOT/var/db/cpt/installed/dummy-pkg"
+ End
+ It "only shows the first instance of a package with the '-s' flag"
+ When run script src/cpt-search -s dummy-pkg
+ The output should eq "$CPT_PATH/dummy-pkg"
+ End
+ It "only shows the first instance of a package with the '--single' flag"
+ When run script src/cpt-search --single dummy-pkg
+ The output should eq "$CPT_PATH/dummy-pkg"
+ End
+ It "shows other locations of the package inside a package directory with the '-o' flag"
+ cd "$CPT_PATH/dummy-pkg" || return 1
+ When run script "$(command -v cpt-search)" -o
+ The output should eq "$CPT_ROOT/var/db/cpt/installed/dummy-pkg"
+ End
+ It "shows other locations of the package inside a package directory with the '--others' flag"
+ cd "$CPT_PATH/dummy-pkg" || return 1
+ When run script "$(command -v cpt-search)" --others
+ The output should eq "$CPT_ROOT/var/db/cpt/installed/dummy-pkg"
+ End
+ Parameters
+ 'd*'
+ 'd???y-?kg'
+ '[Dd][uU]*-?*g*'
+ End
+ It "accepts regular expressions"
+ When run script src/cpt-search -s "$1"
+ The output should eq "$CPT_PATH/dummy-pkg"
+ End
+ End
End
diff --git a/spec/03_contrib_spec.sh b/spec/03_contrib_spec.sh
index a3fce8e..9c7589b 100644
--- a/spec/03_contrib_spec.sh
+++ b/spec/03_contrib_spec.sh
@@ -72,11 +72,51 @@ Describe 'contrib scripts'
End
End
Describe 'cpt-export'
+ chtmp() { cd "$CPT_ROOT/tmp" || return 1 ;}
+ cleanpkg() { rm -f "$CPT_PATH/contrib-dummy-pkg/contrib-dummy-pkg#1-1.tar.gz" ;}
+ Before chtmp
+ AfterAll cleanpkg
firstpkg=$(getfirstpkg)
It "exports a tarball of the given package"
- cd "$CPT_ROOT/tmp" || return 1
When run script "$(command -v cpt-export)" contrib-dummy-pkg
The stdout should eq "tarball created in $CPT_ROOT/tmp/contrib-dummy-pkg#1-1.tar.gz"
End
+ It "exports the package of the current directory when called without arguments"
+ cd "$CPT_PATH/contrib-dummy-pkg" || return 1
+ When run script "$(command -v cpt-export)"
+ The stdout should eq "tarball created in $CPT_PATH/contrib-dummy-pkg/contrib-dummy-pkg#1-1.tar.gz"
+ End
+ It "prints usage information when called with --help"
+ When run script "$(command -v cpt-export)" --help
+ The word 1 of stdout should eq usage:
+ End
+ It "fallbacks to gz when CPT_COMPRESS has a typo"
+ export CPT_COMPRESS=typo
+ When run script "$(command -v cpt-export)" contrib-dummy-pkg
+ The stdout should eq "tarball created in $CPT_ROOT/tmp/contrib-dummy-pkg#1-1.tar.gz"
+ End
+ Parameters
+ bz2 bzip2
+ gz gzip
+ xz xz
+ zst zstd
+ End
+ Mock bzip2
+ cat
+ End
+ Mock gzip
+ cat
+ End
+ Mock xz
+ cat
+ End
+ Mock zstd
+ cat
+ End
+ It "uses the given CPT_COMPRESS value ($1)"
+ export "CPT_COMPRESS=$1"
+ When run script "$(command -v cpt-export)" contrib-dummy-pkg
+ The stdout should eq "tarball created in $CPT_ROOT/tmp/contrib-dummy-pkg#1-1.tar.$1"
+ End
End
End