This repository has been archived by the owner on Dec 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from brokenpip3/feat_extend_tests
feat(tests): update and add more tests
- Loading branch information
Showing
6 changed files
with
260 additions
and
71 deletions.
There are no files selected for viewing
50 changes: 27 additions & 23 deletions
50
.github/workflows/test-local-action-with-conditionals.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,34 @@ | ||
on: [push] | ||
|
||
jobs: | ||
local_test: | ||
runs-on: ubuntu-latest | ||
name: Install Bats common libs | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Setup BATS | ||
uses: mig4/setup-bats@v1 | ||
- name: Install Bats-libs | ||
uses: ./ | ||
with: | ||
support-clean: "false" | ||
assert-clean: "false" | ||
detik-install: "false" | ||
file-install: "false" | ||
- name: Execute test to check Bats-support | ||
run: | | ||
local_test_options: | ||
runs-on: ubuntu-latest | ||
env: | ||
BATS_LIB_PATH: "/usr/lib" | ||
TERM: xterm | ||
name: local with options | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Setup BATS | ||
uses: mig4/setup-bats@v1 | ||
with: | ||
bats-version: 1.10.0 | ||
- name: Setup Bats-libs | ||
uses: ./ | ||
with: | ||
support-clean: "false" | ||
assert-clean: "false" | ||
detik-install: "true" | ||
file-install: "true" | ||
- name: Execute test to check Bats-support | ||
run: | | ||
cd /tmp/bats-support/ | ||
bats test | ||
- name: Execute test to check Bats-assert | ||
run: | | ||
- name: Execute test to check Bats-assert | ||
run: | | ||
cd /tmp/bats-assert/ | ||
sed "s:load \"${BATS_TEST_DIRNAME}.*:load \"/usr/lib/bats-assert\":g" test/test_helper.bash | ||
bats test | ||
- name: Execute test to check the installed library | ||
run: | | ||
ls -l /usr/lib/bats* | ||
- name: Execute example tests | ||
run: | ||
bats -T -p tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,84 @@ | ||
on: [push] | ||
|
||
jobs: | ||
local_test: | ||
runs-on: ubuntu-latest | ||
name: Install Bats common libs | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Setup BATS | ||
uses: mig4/setup-bats@v1 | ||
- name: Install Bats-libs | ||
uses: ./ | ||
with: | ||
support-clean: "false" | ||
assert-clean: "false" | ||
detik-clean: "false" | ||
file-clean: "false" | ||
- name: Execute test to check Bats-support | ||
run: | | ||
local_test: | ||
runs-on: ubuntu-latest | ||
env: | ||
BATS_LIB_PATH: "/usr/lib" | ||
TERM: xterm | ||
name: local default | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Setup BATS | ||
uses: mig4/setup-bats@v1 | ||
with: | ||
bats-version: 1.10.0 | ||
- name: Setup Bats-libs | ||
uses: ./ | ||
with: | ||
support-clean: "false" | ||
assert-clean: "false" | ||
detik-clean: "false" | ||
file-clean: "false" | ||
- name: Execute test to check Bats-support | ||
run: | | ||
cd /tmp/bats-support/ | ||
bats test | ||
- name: Execute test to check Bats-assert | ||
run: | | ||
- name: Execute test to check Bats-assert | ||
run: | | ||
cd /tmp/bats-assert/ | ||
sed "s:load \"${BATS_TEST_DIRNAME}.*:load \"/usr/lib/bats-assert\":g" test/test_helper.bash | ||
bats test | ||
- name: Execute test to check Bats-detik | ||
run: | | ||
- name: Execute test to check Bats-detik | ||
run: | | ||
cd /tmp/bats-detik/ | ||
bats tests | ||
- name: Execute test to check Bats-file | ||
run: | | ||
- name: Execute test to check Bats-file | ||
# Currently the bats-file tests are broken | ||
# in gh runner env | ||
continue-on-error: true | ||
run: | | ||
cd /tmp/bats-file/ | ||
bats test | ||
- name: Execute example tests | ||
run: | ||
bats -T -p tests | ||
local_test_trigger_cache: | ||
needs: [local_test] | ||
runs-on: ubuntu-latest | ||
env: | ||
BATS_LIB_PATH: "/usr/lib/bats" | ||
name: local default | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Setup BATS | ||
uses: mig4/setup-bats@v1 | ||
with: | ||
bats-version: 1.9.0 | ||
- name: Setup Bats-libs | ||
uses: ./ | ||
with: | ||
support-clean: "false" | ||
assert-clean: "false" | ||
detik-clean: "false" | ||
file-clean: "false" | ||
- name: Execute test to check Bats-support | ||
run: | | ||
cd /tmp/bats-support/ | ||
bats test | ||
- name: Execute test to check Bats-assert | ||
run: | | ||
cd /tmp/bats-assert/ | ||
bats test | ||
- name: Execute test to check Bats-detik | ||
run: | | ||
cd /tmp/bats-detik/ | ||
bats tests | ||
- name: Execute test to check Bats-file | ||
# Currently the bats-file tests are broken | ||
# in gh runner env | ||
continue-on-error: true | ||
run: | | ||
cd /tmp/bats-file/ | ||
bats test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,81 @@ | ||
on: [push] | ||
|
||
jobs: | ||
public_test: | ||
runs-on: ubuntu-latest | ||
name: Install Bats common libs | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Setup BATS | ||
uses: mig4/setup-bats@v1 | ||
- name: Setup Bats libs | ||
uses: brokenpip3/[email protected] | ||
with: | ||
support-clean: "false" | ||
assert-clean: "false" | ||
detik-clean: "false" | ||
file-clean: "false" | ||
- name: Execute test to check Bats-support | ||
run: | | ||
public_test: | ||
runs-on: ubuntu-latest | ||
env: | ||
BATS_LIB_PATH: "/usr/lib" | ||
TERM: xterm | ||
name: Install Bats common libs | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Setup BATS | ||
uses: mig4/setup-bats@v1 | ||
with: | ||
bats-version: 1.10.0 | ||
- name: Setup Bats-libs | ||
uses: brokenpip3/setup-bats-libs@main | ||
with: | ||
support-clean: "false" | ||
assert-clean: "false" | ||
detik-clean: "false" | ||
file-clean: "false" | ||
- name: Execute test to check Bats-support | ||
run: | | ||
cd /tmp/bats-support/ | ||
bats test | ||
- name: Execute test to check Bats-assert | ||
run: | | ||
- name: Execute test to check Bats-assert | ||
run: | | ||
cd /tmp/bats-assert/ | ||
sed "s:load \"${BATS_TEST_DIRNAME}.*:load \"/usr/lib/bats-assert\":g" test/test_helper.bash | ||
bats test | ||
- name: Execute test to check Bats-detik | ||
run: | | ||
- name: Execute test to check Bats-detik | ||
run: | | ||
cd /tmp/bats-detik/ | ||
bats tests | ||
- name: Execute test to check Bats-file | ||
run: | | ||
- name: Execute test to check Bats-file | ||
continue-on-error: true | ||
run: | | ||
cd /tmp/bats-file/ | ||
bats test | ||
- name: Execute example tests | ||
run: | ||
bats -T -p tests | ||
public_test_trigger_cache: | ||
# Run the test again to eventually trigger the cache in the future | ||
needs: [public_test] | ||
runs-on: ubuntu-latest | ||
env: | ||
BATS_LIB_PATH: "/usr/lib" | ||
name: Install Bats common libs | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Setup BATS | ||
uses: mig4/setup-bats@v1 | ||
with: | ||
bats-version: 1.9.0 | ||
- name: Setup Bats-libs | ||
uses: brokenpip3/[email protected] | ||
with: | ||
support-clean: "false" | ||
assert-clean: "false" | ||
detik-clean: "false" | ||
file-clean: "false" | ||
- name: Execute test to check Bats-support | ||
run: | | ||
cd /tmp/bats-support/ | ||
bats test | ||
- name: Execute test to check Bats-assert | ||
run: | | ||
cd /tmp/bats-assert/ | ||
bats test | ||
- name: Execute test to check Bats-detik | ||
run: | | ||
cd /tmp/bats-detik/ | ||
bats tests | ||
- name: Execute test to check Bats-file | ||
continue-on-error: true | ||
run: | | ||
cd /tmp/bats-file/ | ||
bats test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
repos: | ||
- repo: https://github.com/sirosen/check-jsonschema | ||
rev: 0.22.0 | ||
hooks: | ||
- id: check-github-workflows | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.4.0 | ||
hooks: | ||
- id: detect-private-key | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
setup() { | ||
load 'tests_helper' | ||
_tests_helper | ||
} | ||
|
||
|
||
@test "0: Pre: Create file and dir" { | ||
run mkdir testing | ||
run touch testing/example | ||
assert_success | ||
} | ||
|
||
#bats test_tags=github:true | ||
@test "1: Testing file existence" { | ||
run ls testing/example | ||
assert_success | ||
[ -f "testing/example" ] | ||
assert_success | ||
} | ||
|
||
#bats test_tags=github:true | ||
@test "2: Testing file permissions" { | ||
run stat -c "%a" testing/example | ||
assert_success | ||
assert_output 644 | ||
assert_file_permission 644 /path/to/permission | ||
assert_success | ||
} | ||
|
||
#bats test_tags=github:true | ||
@test "3: Testing file content" { | ||
run cat testing/example | ||
assert_success | ||
refute_output "Expected content" | ||
assert_file_empty testing/example | ||
assert_success | ||
} | ||
|
||
#bats test_tags=github:true | ||
@test "4: Testing directory creation" { | ||
run mkdir testing/newdir | ||
[ -d "testing/newdir" ] | ||
assert_success | ||
} | ||
|
||
#bats test_tags=github:true | ||
@test "5: Testing file creation inside directory" { | ||
run touch testing/newdir/newfile | ||
[ -f "testing/newdir/newfile" ] | ||
assert_success | ||
} | ||
|
||
#bats test_tags=github:true | ||
@test "6: Testing file deletion" { | ||
run rm testing/newdir/newfile | ||
[ ! -f "testing/newdir/newfile" ] | ||
assert_success | ||
} | ||
|
||
#bats test_tags=github:true | ||
@test "7: Testing directory deletion" { | ||
run rmdir testing/newdir | ||
[ ! -d "testing/newdir" ] | ||
assert_success | ||
} | ||
|
||
#bats test_tags=github:true | ||
@test "8: Testing file deletion" { | ||
run rm testing/example | ||
[ ! -f "testing/example" ] | ||
assert_success | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
_tests_helper() { | ||
export BATS_LIB_PATH=${BATS_LIB_PATH:-"/usr/lib"} | ||
bats_load_library bats-support | ||
bats_load_library bats-assert | ||
bats_load_library bats-file | ||
bats_load_library bats-detik/detik.bash | ||
} |