Skip to content

Commit

Permalink
✅ Update smoke tests with generic-representer
Browse files Browse the repository at this point in the history
- Add test on expected_representation.json
- Remove smoke tests that expect errors (not supported anymore)
  • Loading branch information
homersimpsons committed Jan 12, 2024
1 parent c6b5ca4 commit 4b64a6e
Show file tree
Hide file tree
Showing 20 changed files with 13 additions and 91 deletions.
31 changes: 5 additions & 26 deletions bin/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,17 @@ exit_code=0
for test_dir in tests/*; do
test_dir_name=$(basename "${test_dir}")
test_dir_path=$(realpath "${test_dir}")
representation_file_path="${test_dir_path}/representation.txt"
expected_representation_file_path="${test_dir_path}/expected_representation.txt"
mapping_file_path="${test_dir_path}/mapping.json"
expected_mapping_file_path="${test_dir_path}/expected_mapping.json"
expected_error_file_path="${test_dir_path}/expected_representation.txt"
expect_error="${test_dir_path}/.expect-error"

bin/run.sh "${test_dir_name}" "${test_dir_path}" "${test_dir_path}"
test_exit_code=$?

if [[ -f "${expect_error}" ]]; then
if [[ $test_exit_code -eq 0 ]]; then
echo 'Expected non-zero exit code'
exit_code=1
fi
else
echo "${test_dir_name}: comparing representation.txt to expected_representation.txt"
diff "${representation_file_path}" "${expected_representation_file_path}"

if [ $? -ne 0 ]; then
echo "FAILED"
exit_code=1
fi

echo "${test_dir_name}: comparing mapping.json to expected_mapping.json"
diff "${mapping_file_path}" "${expected_mapping_file_path}"
for file in representation.txt representation.json mapping.json; do
expected_file="expected_${file}"
echo "${test_dir_name}: comparing ${file} to ${expected_file}"

if [ $? -ne 0 ]; then
echo "FAILED"
if ! diff "${test_dir_path}/${file}" "${test_dir_path}/${expected_file}"; then
exit_code=1
fi
fi
done
done

exit ${exit_code}
1 change: 1 addition & 0 deletions bin/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ mkdir -p "${output_dir}"

echo "${slug}: creating representation..."

# Create the representation for the solution
/usr/local/bin/php /opt/representer/main.php "$@"
2 changes: 1 addition & 1 deletion src/DirectoryRepresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function represent(): Result

return new Result(
$filesRepresentation,
'{"version":2}',
'{"version": 2}',
$mapping->toJson(),
);
}
Expand Down
1 change: 1 addition & 0 deletions tests/example-empty-file/expected_representation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version": 2}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version": 2}
1 change: 0 additions & 1 deletion tests/example-multiple-files-missing/.expect-error

This file was deleted.

5 changes: 0 additions & 5 deletions tests/example-multiple-files-missing/.meta/config.json

This file was deleted.

10 changes: 0 additions & 10 deletions tests/example-multiple-files-missing/LeapTests.php

This file was deleted.

9 changes: 0 additions & 9 deletions tests/example-multiple-files-missing/Tools.php

This file was deleted.

This file was deleted.

This file was deleted.

11 changes: 0 additions & 11 deletions tests/example-multiple-files-partially-missing/Leap.php

This file was deleted.

9 changes: 0 additions & 9 deletions tests/example-multiple-files-partially-missing/Tools.php

This file was deleted.

1 change: 1 addition & 0 deletions tests/example-multiple-files/expected_representation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version": 2}
1 change: 0 additions & 1 deletion tests/example-single-file-missing/.expect-error

This file was deleted.

5 changes: 0 additions & 5 deletions tests/example-single-file-missing/.meta/config.json

This file was deleted.

7 changes: 0 additions & 7 deletions tests/example-single-file-missing/LeapTests.php

This file was deleted.

1 change: 1 addition & 0 deletions tests/example-single-file/expected_representation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version": 2}
1 change: 1 addition & 0 deletions tests/example-syntax-error/expected_representation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version": 2}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version": 2}

0 comments on commit 4b64a6e

Please sign in to comment.