Skip to content

I can't get the tests running #115

Closed

Description

@robido

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 -

Activity

  1. slushnys commented on Feb 22, 2020

    @slushnys

    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?

  2. robido commented on Feb 23, 2020

    @robido
    Author

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

  3. slushnys commented on Feb 23, 2020

    @slushnys

    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 👍🏻

  4. robido commented on Feb 25, 2020

    @robido
    Author

    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.

  5. tiangolo commented on Apr 18, 2020

    @tiangolo
    Member

    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 🚀

  6. github-actions commented on Apr 29, 2020

    @github-actions
    Contributor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions