Skip to content

Commit

Permalink
Improve test usage and clarity (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
nizarmah authored Mar 17, 2024
1 parent b956ad1 commit 225d1c6
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 24 deletions.
37 changes: 18 additions & 19 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,36 @@ jobs:
- name: Checkout the repository
uses: actions/checkout@v4

- name: Targets specific directory
- name: Test on affected directory
uses: ./
with:
directory: "tests/action/directory/a/*"
directory: "tests/directory/affected/*"

- name: Compare the minified files
run: git diff --exit-code
- name: Assert not affected result does not exist
run: |
! test -e tests/directory/not-affected/main.min.js
- name: Assert affected result matches expected
run: |
git diff --exit-code --no-index \
tests/directory/affected/main.expected.js \
tests/directory/affected/main.min.js
overwrite:
runs-on: ubuntu-latest

steps:
- name: Checkout the repository
uses: actions/checkout@v4

- name: Test successful overwrite
uses: ./
with:
directory: "tests/action/overwrite/overwritten/*"
overwrite: true

- name: Assert successful overwrite
run: |
git diff --exit-code tests/action/overwrite/overwritten/*
- name: Test failed overwrite

- name: Test overwrite
uses: ./
with:
directory: "tests/action/overwrite/not-overwritten/*"
directory: "tests/overwrite/*"
overwrite: true

- name: Assert failed overwrite
- name: Assert overwrite result matches expected
run: |
! git diff --exit-code tests/action/overwrite/not-overwritten/*
git diff --exit-code --no-index \
tests/overwrite/main.expected.js \
tests/overwrite/main.js
1 change: 0 additions & 1 deletion tests/action/directory/a/a.min.js

This file was deleted.

1 change: 0 additions & 1 deletion tests/action/overwrite/overwritten/main.js

This file was deleted.

1 change: 1 addition & 0 deletions tests/directory/affected/main.expected.js

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

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function print_hello() {
console.log('hello world from b');
console.log('hello world from directory/affected');
}

window.addEventListener('load', function () {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function print_hello() {
console.log('hello world from overwrite/not-overwritten');
console.log('hello world from directory/not-affected');
}

window.addEventListener('load', function () {
Expand Down
1 change: 1 addition & 0 deletions tests/overwrite/main.expected.js

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

2 changes: 1 addition & 1 deletion tests/action/directory/a/a.js → tests/overwrite/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function print_hello() {
console.log('hello world from a');
console.log('hello world from overwrite');
}

window.addEventListener('load', function () {
Expand Down

0 comments on commit 225d1c6

Please sign in to comment.