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

Figure out how to setup database/posts for test suite #445

Closed
3 tasks
epadams opened this issue Mar 27, 2024 · 6 comments · Fixed by #450
Closed
3 tasks

Figure out how to setup database/posts for test suite #445

epadams opened this issue Mar 27, 2024 · 6 comments · Fixed by #450
Assignees
Labels
discuss Discuss something med-priority

Comments

@epadams
Copy link
Contributor

epadams commented Mar 27, 2024

When reviewing #441, I realized we need a good way to make sure that all the components we are testing are properly setup. For example, testing the filters currently requires the Casual tag to be created. We should either go ahead and test Create.jsx so that posts are created and we can assume the tags are created as well, or look into setting up a mock data script to apply to the database. We also need to setup users, x number of posts so that pagination can be tested, and more.

Reproducible items needed:

  • Created user, probably email verified
  • User that has created several posts (Lorem ipsum/empty text is good enough), and enough posts that we can test pagination
  • Multiple tags associated with post(s)
@jbytes1027
Copy link
Contributor

This is a big problem and needs to get done asap for testing. There are two parts to this.

  1. Will need a separated API and DB running for testing.
  2. Need a way to reset the API.

If a separate API is setup in the cloud, there's no guarantee that two people don't interrupt each other's testing. Also it will probably be slower to run tests.

If done locally, we could use a docker image to startup the DB and API together. Front end will need a way to the add data they want to on startup. The easiest way without learning LINQ or telling me or Evan to add something to the database is probably a raw SQL file. The database container could be initialized by running the SQL file on startup. @evan-scales What do you think?

@epadams
Copy link
Contributor Author

epadams commented Mar 27, 2024

If done locally, we could use a docker image to startup the DB and API together. Front end will need a way to the add data they want to on startup. The easiest way without learning LINQ or telling me or Evan to add something to the database is probably a raw SQL file. The database container could be initialized by running the SQL file on startup.

I think this is probably the best way to do it. I don't necessarily think we need to add the API into the container (I'm not super experienced with Docker, not sure how difficult this would be) as long as we have the same reproducible database.

I'm not sure how feasible it would be at this point to try and add a workflow for this, @evan-scales would have a better idea if it is or not.

@jbytes1027
Copy link
Contributor

I could setup the docker containers. All that would need to be done on y'all end is edit an SQL file as needed and run one command to test everything.

@epadams
Copy link
Contributor Author

epadams commented Mar 27, 2024

Ok, I'll look into making a SQL file. Is there any way to run the file as soon as the container is initialized? Probably don't want it running on every startup unless we reset the container on each test.

@jbytes1027
Copy link
Contributor

An sql file is just a list of sql commands for PostgreSQL. Now that I think about it, most of the set up could probably be done in selenium as tests that run before everything else.

@jbytes1027 jbytes1027 self-assigned this Mar 27, 2024
@evan-scales
Copy link
Collaborator

evan-scales commented Mar 28, 2024

I'm not sure how feasible it would be at this point to try and add a workflow

It's doable, but probably not worth it for us. At my work to run the full behavioral tests we have a pipeline that creates a private environment on the cloud, then its able to do all of its tests. We can create a new api/db on azure dedicated to running behavioral tests. But they need to be updated/redeployed on each workflow run. But then we can't have 2 workflows running at the same time. So just a lot of hassle

I think the best way to do this is go with @jbytes1027 approach. Plus would be nice to containerize the api. My experience with applying sample data is by creating a powershell script to run in the docker file. The script connects to the db and runs any sql files it needs to.

Or the easiest option, make fake 'set up' tests that run before everything else. These ensure games/tags and whatever else are actually created

@jbytes1027 jbytes1027 linked a pull request Mar 29, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss Discuss something med-priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants