Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I can't get the tests running #115

Closed
robido opened this issue Feb 22, 2020 · 6 comments
Closed

I can't get the tests running #115

robido opened this issue Feb 22, 2020 · 6 comments

Comments

@robido
Copy link

robido commented Feb 22, 2020

I am new with Docker so maybe its a noob issue, I have no clue on how to run the tests. Here is what I tried, with corresponding outputs:

docker-compose exec backend-tests /tests-start.sh
‘bash\r’: No such file or directory

docker-compose exec backend-tests \tests-start.sh
OCI runtime exec failed: exec failed: container_linux.go:346: starting container process caused "exec: "\\tests-start.sh": executable file not found in $PATH": unknown

docker-compose exec backend-tests tests-start.sh
OCI runtime exec failed: exec failed: container_linux.go:346: starting container process caused "exec: "tests-start.sh": executable file not found in $PATH": unknown

docker-compose exec backend bash
root@0dca8fc07bda:/app# DOMAIN=backend sh ./scripts/test.sh
sh: 0: Can't open ./scripts/test.sh

root@0dca8fc07bda:/app# sh scripts/test.sh
sh: 0: Can't open scripts/test.sh

root@0dca8fc07bda:/app# ls
Pipfile alembic alembic.ini app prestart.sh scripts tests-start.sh worker-start.sh

root@0dca8fc07bda:/app# sh tests-start.sh
tests-start.sh: 2: set: Illegal option -

@slushnys
Copy link

that line should be ran from your local computer of your root directory.

Question offtopic:
I'm questioning the way this is tested, each time you want to tests, you must spawn new docker-compose? Where's productivity in that?

@robido
Copy link
Author

robido commented Feb 23, 2020

Thanks @slushnys can you elaborate more what you mean by root directory? Do you mean within bash within the container.

@slushnys
Copy link

You have to execute DOMAIN=backend sh ./scripts/test.sh in your main folder which will spawn another backend container where it will run a script to execute pytest. After that you can enter the backend-tests container and run pytest whenever you want to 👍🏻

@robido
Copy link
Author

robido commented Feb 25, 2020

The command DOMAIN=backend sh ./scripts/test.sh does not work for me, I assume there is some difference between Linux and Windows for those commands. That is the error I get:
'DOMAIN' is not recognized as an internal or external command,
operable program or batch file.

I finally was able to run the tests. To help others with the same issue, here is what worked:

  1. There is an issue in Windows and cookiecutter regarding line endings being CR + LF, so I used notepad++ to batch convert all the CR + LF to LF. Make sure to exclude binary files such as .png images and icons or they will be corrupted.
  2. Keep the project files in a separate drive outside the Windows C, as per Docker docs.
  3. I had to reset docker to factory and restart the PC, then rebuild the images (docker-compose up -d). Docker: must be in Linux container mode (not Windows)
  4. After that, the tests worked with this command:
    docker-compose exec backend-tests /tests-start.sh
  5. There are some other issues, where the tests pass the first time, but not the second time. Applying PR Update CRUD utils for users handling password hashing #106 solved it.

I saw a few of the issues are related to that CR+LF problem, I think it would be good to mention in in the README.md.

Thanks Tiangolo for the great FastAPI framework and this fullstack example.

@tiangolo
Copy link
Owner

Thanks for the discussion here everyone!

About the CR LF problem, indeed, it's an issue with Cookiecutter in Windows: cookiecutter/cookiecutter#1159

But it should be fixed now on this side with: #149 🎉

Now after generating a new project line endings are fixed for shell files 🚀

@github-actions
Copy link

Assuming the original issue was solved, it will be automatically closed now. But feel free to add more comments or create new issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants