From c2cc574d44c3d46e736dac9d82a91013dc44a6bd Mon Sep 17 00:00:00 2001 From: merakor Date: Mon, 14 Nov 2022 18:42:03 +0000 Subject: spec: create tests for version control FossilOrigin-Name: 0150630c7b4905b33a04c8841b53c304d92fb841428c6ddee6953e78a32e3a8c --- spec/01_lib_spec.sh | 58 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/spec/01_lib_spec.sh b/spec/01_lib_spec.sh index 6612618..e505f21 100644 --- a/spec/01_lib_spec.sh +++ b/spec/01_lib_spec.sh @@ -112,16 +112,16 @@ Describe 'CPT Library' Describe '_readlinkf()' mklink() { :> tests/testfile; ln -s testfile tests/testfile2 ;} - rmlink() { rm -f tests/testfile tests/testfile2 ;} + rmlink() { rm tests/testfile tests/testfile2 ;} RPWD=$(cd -P .||:; printf %s "$PWD") - Before mklink - After rmlink + BeforeEach mklink + AfterEach rmlink Parameters "#1" . "$RPWD" - "#2" "$PWD/tests/testfile2" "$RPWD/tests/testfile" + "#2" "./tests/testfile2" "$RPWD/tests/testfile" End - It "outputs the real location of the given file ($1)" - When call _readlinkf "$2" + It "outputs the real location of the given file [$1] ($2 -> $3)" + When run _readlinkf "$2" The output should eq "$3" End End @@ -151,6 +151,52 @@ Describe 'CPT Library' End End + Describe 'version control functions' + check_internet_connection() { ! curl -L git.carbslinux.org >/dev/null 2>&1 ;} + Skip if "no internet connection" check_internet_connection + Describe 'pkg_vcs_clone_git()' + setup() { mkdir test_repository && cd test_repository || return ;} + cleanup() { cd .. && rm -rf test_repository ;} + check_version() { [ "$1" = "$(sed -n '/^version=/s/.*=//p' configure)" ] ;} + BeforeEach setup + AfterEach cleanup + It "clones the given git repository to the current directory" + When call pkg_vcs_clone_git https://git.carbslinux.org/cpt + The output should not eq "" + The stderr should not eq "" + The status should be success + Assert [ ! -d test_repository ] + Assert [ -f README.md ] + Assert check_version Fossil + End + It "clones the given tag when asked for it" + When call pkg_vcs_clone_git https://git.carbslinux.org/cpt @6.2.4 + The output should not eq "" + The stderr should not eq "" + The status should be success + Assert [ ! -d test_repository ] + Assert [ -f README.md ] + Assert check_version 6.2.4 + End + End + Describe 'pkg_vcs_clone_fossil()' + tmpfos=$$ + setup() { mkdir "/tmp/test_repository.$tmpfos" && cd "/tmp/test_repository.$tmpfos" || return ;} + cleanup() { cd /tmp && rm -rf "test_repository.$tmpfos" ;} + check_version() { [ "$1" = "$(sed -n '/^version=/s/.*=//p' configure)" ] ;} + BeforeEach setup + AfterEach cleanup + It "clones the given fossil repository to the current directory" + When call pkg_vcs_clone_fossil https://fossil.carbslinux.org/cpt + The output should not eq "" + The stderr should eq "" + The status should be success + Assert [ ! -d test_repository ] + Assert [ -f README.md ] + Assert check_version Fossil + End + End + End Describe 'package functions' Describe 'run_hook()' CPT_HOOK=$PWD/tests/hook-file -- cgit v1.2.3