diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 04d5d0e..128df11 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,13 +15,20 @@ 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 @@ -29,23 +36,15 @@ jobs: 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 diff --git a/tests/action/directory/a/a.min.js b/tests/action/directory/a/a.min.js deleted file mode 100644 index e939a8a..0000000 --- a/tests/action/directory/a/a.min.js +++ /dev/null @@ -1 +0,0 @@ -function print_hello(){console.log("hello world from a")}window.addEventListener("load",function(){print_hello()}); \ No newline at end of file diff --git a/tests/action/overwrite/overwritten/main.js b/tests/action/overwrite/overwritten/main.js deleted file mode 100644 index 9a47705..0000000 --- a/tests/action/overwrite/overwritten/main.js +++ /dev/null @@ -1 +0,0 @@ -function print_hello(){console.log("hello world from overwrite/overwritten")}window.addEventListener("load",function(){print_hello()}); \ No newline at end of file diff --git a/tests/directory/affected/main.expected.js b/tests/directory/affected/main.expected.js new file mode 100644 index 0000000..666eca3 --- /dev/null +++ b/tests/directory/affected/main.expected.js @@ -0,0 +1 @@ +function print_hello(){console.log("hello world from directory/affected")}window.addEventListener("load",function(){print_hello()}); \ No newline at end of file diff --git a/tests/action/directory/b/b.js b/tests/directory/affected/main.js similarity index 63% rename from tests/action/directory/b/b.js rename to tests/directory/affected/main.js index 1bdde8d..8a489b2 100644 --- a/tests/action/directory/b/b.js +++ b/tests/directory/affected/main.js @@ -1,5 +1,5 @@ function print_hello() { - console.log('hello world from b'); + console.log('hello world from directory/affected'); } window.addEventListener('load', function () { diff --git a/tests/action/overwrite/not-overwritten/main.js b/tests/directory/not-affected/main.js similarity index 61% rename from tests/action/overwrite/not-overwritten/main.js rename to tests/directory/not-affected/main.js index 1364af7..8e64803 100644 --- a/tests/action/overwrite/not-overwritten/main.js +++ b/tests/directory/not-affected/main.js @@ -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 () { diff --git a/tests/overwrite/main.expected.js b/tests/overwrite/main.expected.js new file mode 100644 index 0000000..0c898c0 --- /dev/null +++ b/tests/overwrite/main.expected.js @@ -0,0 +1 @@ +function print_hello(){console.log("hello world from overwrite")}window.addEventListener("load",function(){print_hello()}); \ No newline at end of file diff --git a/tests/action/directory/a/a.js b/tests/overwrite/main.js similarity index 68% rename from tests/action/directory/a/a.js rename to tests/overwrite/main.js index 1fd79f6..511392b 100644 --- a/tests/action/directory/a/a.js +++ b/tests/overwrite/main.js @@ -1,5 +1,5 @@ function print_hello() { - console.log('hello world from a'); + console.log('hello world from overwrite'); } window.addEventListener('load', function () {