Build A World Cup Database Issue

Hello,

I am stuck to a problem that I dont understand at step insert_data.sh :

I ve that code bellow in my insert_data.sh :

cat games.csv | while IFS="," read -r YEAR ROUND WINNER OPPONENT WINNER_GOALS OPPONENT_GOALS
  do
    if [[ $WINNER != "winner" ]]
    then 
      SELECT_WINNER_TEAM=$($PSQL "SELECT name FROM teams WHERE name='$WINNER'")
      if [[ -z $SELECT_WINNER_TEAM ]]
      then
        ADD_WINNER=$($PSQL "INSERT INTO teams(name) VALUES('$WINNER')")
        echo $ADD_WINNER
      fi

      SELECT_OPPONENT_TEAM=$($PSQL "SELECT * FROM teams WHERE name='$OPPONENT'")
      if [[ -z $SELECT_OPPONENT_TEAM ]]
      then
         ADD_OPPONENT=$($PSQL "INSERT INTO teams(name) VALUES('$OPPONENT')")
         echo $ADD_OPPONENT
      fi
    fi 

  done 
fi

I dont get any error in the terminal and I got the 24 rows but I keep having this message :
" When you run your insert_data.sh script, it should add each unique team to the teams table. There should be 24 rows"

All the others steps before are marked as green, I have already did a refresh and I have also deleted the container in codeally but the error is still there.

Anyone has a solution ?

Thank you

When I ran the script above, I got an error:
Screen Shot 2023-01-23 at 10.03.32 AM

I removed the last fi and the error was gone, and that test passed. If a script throws any errors, the tests won’t be able to run it successfully.

Hello,

Thank you for your response, I have find the problem thank to you, while refactoring I put my code in the “else” of if [[ $1 == "test" ]]