edit: @moT01 and colleagues, please help. I dont know what is the error. All expected output is produce d correctly with my code, still the “Run” wont let me pass.
Sorry for your troubles @NazaLearn, that looks like it should pass that test. I’m not sure what the problem is. If you share a dump of your database, I can take a look - use the command in the instructions to create it.
I’m not sure if those files in your repo are up to date - but when I rebuilt database using your dump, some of the database related tests passed - including the one you outlined. After I added your insert_data.sh script, then those tests failed. The script is giving an error, which is causing all the tests to fail. Here’s what I see when I run it:
If you comment out the two lines in your script that use that COPY command, the database related tests will pass again. Is that script working when you run it? I would just complete the script so it works, and then the tests won’t error out and should pass again.
I can also look into fixing up the tests so that they don’t all fail when a script errors out like that.
Sorry if it took so long answering your question. I needed to drop the table and recreate it again to make sure I know what I am having. Yes, I receive the same error message as you. However, this error message seems does not have effect with the insertion process. When I run the insert_data.sh, I receive the error message but I can confirm that the data is populated accordingly. Could you please check the record in your table? If I am right, the record should now doubled, tripled or quadrupled depends on how many you run the insert_data.sh.
K, I played with it a little more. You are right, the data is being inserted. What’s happening is that bash is trying to execute the result of those queries. If I put the result of the psql commands into variables:
and echo them:
You can see the result of running the psql commands. Bash is trying to execute COPY, that’s where that error comes from. Adding those variables like I did will stop bash from trying to run COPY.
After that, the tests still don’t pass. You are entering data into the wrong columns - if you fix that, I think they will pass.
The command the test runs is ./insert_data.sh test - which will use that other PSQL variable which connects to the test database. The test database has the columns and tables expected - e.g. winner_id and opponent_id, etc. So if I run the test command, I see the error of your script trying to insert data into columns that don’t exist over there:
I think that might be enough info to help you get passed these errors and bugs. Let me know if you are still stuck. Again, I will try to improve the messages and tests here - but for now, you are going to have to use the existing tests.
I just have another question. I deleted the database “worldcup” and not even begin yet with creating tables. When pressing the button “Run”, at least I should pass the first requirement, right? the problem here, is I still cannot get pass the first requirement. When trying to create a new database, postgress is telling that the database is already exists. Do you know what cause this issue?
Thank you for your help.
[I created database world cup and the table games. However, the run does not seem to recognize my table. Did I do something wrong?=“NazaLearn, post:1, topic:544435, full:true”]
Hello @NazaLearn,
I had the same problem I solve it by saving the insert result in a variable and the echo it, following a suggestion from @moT01 that explain something similar.
It is posible that test need the result to check against the test. I not sure, just guessing.
I see this is a few months old post but I hope this can help you or others with a similar problem.