Skip to content

Commit

Permalink
fixing the test runner after the new changes in the ontoportal script
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Nov 28, 2023
1 parent 2e04896 commit df91a61
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ GIT

GIT
remote: https://github.com/ontoportal-lirmm/ontologies_linked_data.git
revision: a199eff007f5d7f18205d61194f3823445aa6460
revision: 82fffaaeb52016c1c7b335952c80ce0256d57d33
branch: development
specs:
ontologies_linked_data (0.0.1)
Expand Down
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ Goals:
```
### Configuration
```
cp .env.sample .env
```


### Run dev
```bash
Expand Down
48 changes: 38 additions & 10 deletions bin/ontoportal
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,40 @@

# Function to display script usage information
show_help() {
cat <<EOL
cat << EOL
Usage: $0 {dev|test|run|help} [--reset-cache] [--api-url API_URL] [--api-key API_KEY] [--old-path OLD_PATH] [--goo-path GOO_PATH] [--sparql-client-path SPARQL_CLIENT_PATH]
dev : Start the OntoPortal API development server.
dev : Start the Ontoportal API development server.
Example: $0 dev --api-url http://localhost:9393
Use --reset-cache to remove volumes: $0 dev --reset-cache
test : Run tests.
run : Run a command in the OntoPortal API Docker container.
test : Run tests. Specify either a test file or use 'all'.
Example: $0 test test/controllers/test_users_controller.rb -v --name=name_of_the_test
Example (run all tests): $0 test all -v
run : Run a command in the Ontoportal API Docker container.
help : Show this help message.
Description:
This script provides convenient commands for managing an OntoPortal API
This script provides convenient commands for managing an Ontoportal API
application using Docker Compose. It includes options for starting the development server,
running tests, and executing commands within the OntoPortal API Docker container.
running tests, and executing commands within the Ontoportal API Docker container.
Options:
--reset-cache : Remove Docker volumes (used with 'dev').
--api-url API_URL : Specify the API URL.
--api-key API_KEY : Specify the API key.
--old-path OLD_PATH : Specify the path for ontologies_linked_data.
--goo-path GOO_PATH : Specify the path for goo.
--sparql-client-path : Specify the path for sparql-client.
--sparql-client-path SPARQL_CLIENT_PATH : Specify the path for sparql-client.
test_file | all : Specify either a test file or use 'all' to run all tests.
-v : Enable verbosity.
--name=name_of_the_test : Specify the name of the test.
Goals:
- Simplify common tasks related to OntoPortal API development using Docker.
- Simplify common tasks related to Ontoportal API development using Docker.
- Provide a consistent and easy-to-use interface for common actions.
EOL
}


# Function to update or create the .env file with API_URL and API_KEY
update_env_file() {
# Update the .env file with the provided values
Expand Down Expand Up @@ -177,9 +184,30 @@ dev() {
# Function to handle the "test" option
test() {
echo "Running tests..."
local test_path=""
local test_options=""
local all_arguments=()
# Check for command line arguments
while [ "$#" -gt 0 ]; do
case "$1" in
--api-url | --reset-cache | --old-path | --goo-path | --sparql-client-path)
all_arguments+=("$1" "$2")
shift 2
;;
*)
if [ -z "$test_path" ]; then
test_path="$1"
else
test_options="$test_options $1"
fi
;;
esac
shift
done

local custom_command="API_URL=$api_url bundle exec rake test TEST=\"$test_path\" TESTOPTS=\"$test_options\""
run_command "$custom_command" "$@"
local custom_command="bundle exec rake test TEST='$test_path' TESTOPTS='$test_options'"
echo "run : $custom_command"
run_command "$custom_command" "${all_arguments[@]}"
}

# Function to handle the "run" option
Expand Down

0 comments on commit df91a61

Please sign in to comment.