Skip to content

Commit

Permalink
Moved tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSkrypnyk committed Jan 2, 2024
1 parent 37c0878 commit d0d292d
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 11 deletions.
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
/.gitattributes export-ignore
/.github export-ignore
/.gitignore export-ignore
/package.json export-ignore
/renovate.json export-ignore
/tests export-ignore
6 changes: 2 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,5 @@ jobs:
env:
SHFMT_OPTS: -i 2 -ci -s -d
- uses: actions/setup-node@v4
- name: Test
run: |
npm install
npm run test
- run: npm --prefix=tests ci
- run: npm --prefix=tests run test
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,11 @@ curl -SsL https://github.com/AlexSkrypnyk/drupal-module-renamer/raw/main/drupal-
```bash
bash drupal-module-renamer.sh /path/to/dir "old_name" "old_prefix" "new_name" "new_prefix"
```

## Maintenance

```bash
npm --prefix=tests ci

npm --prefix=tests run test
```
3 changes: 1 addition & 2 deletions .gitignore → tests/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# To ignore OS temporary files use global .gitignore
# https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files#configuring-ignored-files-for-all-repositories-on-your-computer

/node_modules
/package-lock.json
node_modules
8 changes: 6 additions & 2 deletions tests/bats/_helper.bash → tests/_helper.bash
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ setup() {
# @see https://bats-core.readthedocs.io/en/stable/writing-tests.html#special-variables

# Register a path to libraries.
export BATS_LIB_PATH="${BATS_TEST_DIRNAME}/../../node_modules"
export BATS_LIB_PATH="${BATS_TEST_DIRNAME}/node_modules"

# Load 'bats-helpers' library.
bats_load_library bats-helpers
Expand All @@ -36,8 +36,12 @@ setup() {
# Fixture directory for bats fixtures.
export FIXTURE_DIR="${BUILD_DIR}/bats-fixture"

# Copy code at the last commit.
fixture_prepare_dir "${BUILD_DIR}"
fixture_export_codebase "${BUILD_DIR}" "${CUR_DIR}/.."

fixture_prepare_dir "${FIXTURE_DIR}"
cp -Rf "${CUR_DIR}/tests/fixtures/." "${FIXTURE_DIR}/"
cp -Rf "${CUR_DIR}/fixtures/." "${FIXTURE_DIR}/"

echo "BUILD_DIR dir: ${BUILD_DIR}" >&3
}
Expand Down
52 changes: 52 additions & 0 deletions tests/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json → tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"bats-helpers": "npm:@drevops/bats-helpers@^1.2"
},
"scripts": {
"test": "bats tests/bats/rename.bats"
"test": "bats --no-tempdir-cleanup rename.bats"
}
}
4 changes: 3 additions & 1 deletion tests/bats/rename.bats → tests/rename.bats
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

load _helper

export BATS_FIXTURE_EXPORT_CODEBASE_ENABLED=1

@test "Rename" {
assert_dir_exists "${FIXTURE_DIR}/ys_core"
assert_file_exists "${FIXTURE_DIR}/ys_core/ys_core.info.yml"
Expand All @@ -28,7 +30,7 @@ load _helper
assert_file_contains "${FIXTURE_DIR}/ys_core/tests/src/Functional/YsCoreExampleFunctionalTest.php" "YsCoreExampleFunctionalTest"
assert_file_contains "${FIXTURE_DIR}/ys_core/tests/src/Functional/YsCoreFunctionalTestBase.php" "YsCoreFunctionalTestBase"

run ./drupal-module-renamer.sh "${FIXTURE_DIR}" "ys_core" "Ys" "sw_core" "Sw"
run "${BUILD_DIR}/drupal-module-renamer.sh" "${FIXTURE_DIR}" "ys_core" "Ys" "sw_core" "Sw"
assert_success

assert_output_contains "${FIXTURE_DIR}"
Expand Down

0 comments on commit d0d292d

Please sign in to comment.