Tell us what’s happening:
Describe your issue in detail here.
Even through I tried and manual dry run for all test cases are successful, all test cases are not getting passed.
Your code so far
#!/bin/bash
echo -e "\n **************** WELCOME TO SALON ****************** \n"
PSQL="psql -X --username=freecodecamp --dbname=salon --tuples-only -c"
CREATE_APPOINTMENT()
{
Cust_id=$($PSQL "select customer_id from customers where name='$2'")
Make_appointment=$($PSQL "insert into appointments(service_id,customer_id,time) values($1,$Cust_id,'$3')")
if [[ -z $Make_appointment ]]
then
echo -e "\nInsert not successful."
else
echo -e "\nI have put you down for a$4 at $3, $2."
fi
}
GET_INPUT()
{
read SERVICE_ID_SELECTED
READED_SERVICE=$($PSQL "select name from services where service_id='$SERVICE_ID_SELECTED'")
echo $READED_SERVICE
if [[ -z $READED_SERVICE ]]
then
echo "I could not find that service. What would you like today?"
MENU
else
echo -e "\nWhat's your phone number?"
read CUSTOMER_PHONE
Phone_exists=$($PSQL "select phone from customers where phone='$CUSTOMER_PHONE'")
if [[ -z $Phone_exists ]]
then
echo -e "\nI don't have a record for that phone number, what's your name?"
read CUSTOMER_NAME
ADD_CUST=$($PSQL "insert into customers(phone,name) values('$CUSTOMER_PHONE','$CUSTOMER_NAME')")
echo -e "\nWhat time would you like your $READED_SERVICE, $CUSTOMER_NAME?"
read SERVICE_TIME
CREATE_APPOINTMENT $SERVICE_ID_SELECTED $CUSTOMER_NAME $SERVICE_TIME "$READED_SERVICE"
else
CUSTOMER_NAME=$($PSQL "select name from customers where phone='$CUSTOMER_PHONE'")
echo -e "\nWhat time would you like your $READED_SERVICE, $CUSTOMER_NAME?"
read SERVICE_TIME
CREATE_APPOINTMENT $SERVICE_ID_SELECTED $CUSTOMER_NAME $SERVICE_TIME "$READED_SERVICE"
fi
fi
}
MENU()
{
COUNT=$($PSQL "select count(*) from services")
i=1
while [[ $i -le $COUNT ]]
do
SERVICE=$($PSQL "select name from services where service_id=$i")
echo "$i) $SERVICE"
i=$(( i+1 ))
done
GET_INPUT
}
MENU
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.63 Safari/537.36 Edg/102.0.1245.33
The tests are not very lenient in this case - and the instructions could probably use some clarification. We didn’t teach about the time type so the tests are using strings instead of a real time. Change your time column to a varchar type, that should get the bottom four tests to pass. To get the last two to pass, remove the extra space in your list of services. e.g. change 1)<space><space>Hair Cut & Style to 1)<space>Hair Cut & Style for all the services in your list.
I will make an issue to try and make improvements.
Thanks @moT01 , I was able to pass all the test cases by changing the time column to varchar and removing the leading spaces from the output name of each service.