blitz-orm icon indicating copy to clipboard operation
blitz-orm copied to clipboard

Sweep: Add more query tests

Open lveillard opened this issue 2 years ago • 1 comments

Todo:

  • Try to identify missing tests in the queries and add at least 10 new tests that cover typical DB queries that are not present in the current tests.

  • If you miss some data in the database for some particular tests (data is here (test/mocks/data.tql ) you can suggest new lines of data as well

Context files:

  • test/mocks/data.tql //the current data in the test DB that can be queries
  • tests/mocks/testSchema.ts // this is the current schema that holds the definitions and relations of the different items

Files to change:

  • test/unit/queries/query.test.ts
Checklist
  • [X] Modify tests/unit/queries/query.test.ts ✓ https://github.com/Blitzapps/blitz-orm/commit/73cd014acbf549aa535ab3d986e2701e148894c5
  • [X] Check tests/unit/queries/query.test.ts
  • [X] Modify package.json ! No changes made
  • [X] Modify .eslintrc ! No changes made
  • [X] Check tests/unit/queries/query.test.ts
  • [X] Modify tests/mocks/data.tql ✓ https://github.com/Blitzapps/blitz-orm/commit/d29d060299cd4d1296a1b79c9f6f4d09f827a8d3
  • [X] Check tests/mocks/data.tql

Flowchart

lveillard avatar Nov 01 '23 18:11 lveillard

Here's the PR! https://github.com/Blitzapps/blitz-orm/pull/27.

Sweep Basic Tier: I'm using GPT-4. You have 5 GPT-4 tickets left for the month and 3 for the day.

For more GPT-4 tickets, visit our payment portal. For a one week free trial, try Sweep Pro (unlimited GPT-4 tickets).

Actions (click)

  • [ ] ↻ Restart Sweep
Install Sweep Configs: Pull Request

Step 1: 🔎 Searching

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I looked at (click to expand). If some file is missing from here, you can mention the path in the ticket description.

https://github.com/Blitzapps/blitz-orm/blob/2abe78629d722cdc991ab1afa44263af7d008dd6/tests/mocks/testSchema.ts#L352-L496

https://github.com/Blitzapps/blitz-orm/blob/2abe78629d722cdc991ab1afa44263af7d008dd6/readme.md#L1-L79

https://github.com/Blitzapps/blitz-orm/blob/2abe78629d722cdc991ab1afa44263af7d008dd6/tests/mocks/testSchema.ts#L15-L201


Step 2: ⌨️ Coding

  • [X] Modify tests/unit/queries/query.test.ts ✓ https://github.com/Blitzapps/blitz-orm/commit/73cd014acbf549aa535ab3d986e2701e148894c5
Modify tests/unit/queries/query.test.ts with contents:
• Analyze the existing tests in the `query.test.ts` file and identify the types of queries that are not currently being tested.
• Add new tests for these queries. Each test should create a query, execute it, and then assert that the result is as expected.
• If a test requires data that is not currently in the database, suggest new lines of data to be added to the `data.tql` file.
  • [X] Check tests/unit/queries/query.test.ts
Sandbox logs for
trunk init 1/3 ✓
⡿ Downloading Trunk 1.17.1...
⡿ Downloading Trunk 1.17.1...
⢿ Downloading Trunk 1.17.1...
⣻ Downloading Trunk 1.17.1...
⣽ Downloading Trunk 1.17.1...
⣾ Downloading Trunk 1.17.1...
⣷ Downloading Trunk 1.17.1...
✔ Downloading Trunk 1.17.1... done
⡿ Verifying Trunk sha256...
✔ Verifying Trunk sha256... done
⡿ Unpacking Trunk...
✔ Unpacking Trunk... done


✔ 10 linters were enabled (.trunk/trunk.yaml)
  checkov 3.0.15 (3 json, 2 yaml files)
  eslint 8.52.0 (2 javascript, 51 typescript files)
  git-diff-check (70 files)
  markdownlint 0.37.0 (2 markdown files) (created .markdownlint.yaml)
  prettier 3.0.3 (2 javascript, 3 json, 2 markdown, 1 prettier_supported_configs, 51 typescript, 2 yaml files)
  shellcheck 0.9.0 (1 shell file) (created .shellcheckrc)
  shfmt 3.6.0 (1 shell file)
  trivy 0.46.1 (2 yaml files)
  trufflehog 3.62.1 (70 files)
  yamllint 1.32.0 (2 yaml files) (created .yamllint.yaml)
Next Steps
 1. Read documentation
    Our documentation can be found at https://docs.trunk.io
 2. Get help and give feedback
    Join the Trunk community at https://slack.trunk.io
trunk fmt tests/unit/queries/query.test.ts || exit 0 2/3 ✓
 ✔ Formatted tests/unit/queries/query.test.ts
Re-checking autofixed files...


Checked 1 file
✔ No issues
trunk check --fix --print-failures tests/unit/queries/query.test.ts 3/3 ❌ (`1`)
  FAILURES  
 eslint  tests/unit/queries/query.test.ts  .trunk/out/fMjpQ.yaml
 eslint  tests/unit/queries/query.test.ts  .trunk/out/pCrmN.yaml
  NOTICES  
 [suggestion] Eslint could not resolve dependencies; try running `npm install`, `yarn install`, or your equivalent      
 thereof                                                                                                                
 Some tools failed to run. You can open the details yaml files for more information.                                    
Checked 1 file
✖ No issues, 2 failures
# .trunk/out/fMjpQ.yaml
trunk_cli_version: 1.17.1
title: eslint exited with exit_code=2
report:
  - eslint exited with exit_code=2
  - suggestion: Eslint could not resolve dependencies; try running `npm install`, `yarn install`, or your equivalent thereof
  - linter:
      command: |
        /root/.cache/trunk/tools/eslint/8.52.0-a618ad632f0aeb358b6d43b1e01c686f/node_modules/.bin/eslint --output-file /tmp/trunk-0/SJv9E3/6jNXiP8FYn5f --format json tests/unit/queries/query.test.ts
      stdin_path: (none)
      run_from: /tmp/trunk-0/mZYuu6/srRoG7
      timeout: 10m
      rerun: (cd /tmp/trunk-0/mZYuu6/srRoG7; env -i PATH=/root/.cache/trunk/tools/eslint/8.52.0-a618ad632f0aeb358b6d43b1e01c686f/node_modules/.bin:/root/.cache/trunk/tools/node/18.12.1-00ae74f39ac4de3ff3c7e3686016ebf3/bin:/root/.cache/trunk/tools/node/18.12.1-00ae74f39ac4de3ff3c7e3686016ebf3:/root/.nvm/versions/node/v18.17.0/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin NODE_PATH=/root/.cache/trunk/tools/eslint/8.52.0-a618ad632f0aeb358b6d43b1e01c686f/node_modules HOME=/root /root/.cache/trunk/tools/eslint/8.52.0-a618ad632f0aeb358b6d43b1e01c686f/node_modules/.bin/eslint --output-file /tmp/trunk-0/SJv9E3/6jNXiP8FYn5f --format json tests/unit/queries/query.test.ts)
      affects_cache:
        - .eslintignore
        - package.json
        - tsconfig.json
      direct_configs:
        - .eslintrc
      exit_status: exited
      exit_code: 2
      stdout: (none)
      stderr: |
        Oops! Something went wrong! :(
        ESLint: 8.52.0
        ESLint couldn't find the config "@blitznocode/eslint-config" to extend from. Please check that the name of the config is correct.
        The config "@blitznocode/eslint-config" was referenced from the config file in "/tmp/trunk-0/mZYuu6/srRoG7/.eslintrc".
        If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.
    parser: |
      (none)
# .trunk/out/pCrmN.yaml
trunk_cli_version: 1.17.1
title: eslint exited with exit_code=2
report:
  - eslint exited with exit_code=2
  - suggestion: Eslint could not resolve dependencies; try running `npm install`, `yarn install`, or your equivalent thereof
  - linter:
      command: |
        /root/.cache/trunk/tools/eslint/8.52.0-a618ad632f0aeb358b6d43b1e01c686f/node_modules/.bin/eslint --output-file /tmp/trunk-0/cg0vKx/qbquk1xNlQZA --format json tests/unit/queries/query.test.ts
      stdin_path: (none)
      run_from: /tmp/trunk-0/CuArlP/HNCUME
      timeout: 10m
      rerun: (cd /tmp/trunk-0/CuArlP/HNCUME; env -i PATH=/root/.cache/trunk/tools/eslint/8.52.0-a618ad632f0aeb358b6d43b1e01c686f/node_modules/.bin:/root/.cache/trunk/tools/node/18.12.1-00ae74f39ac4de3ff3c7e3686016ebf3/bin:/root/.cache/trunk/tools/node/18.12.1-00ae74f39ac4de3ff3c7e3686016ebf3:/root/.nvm/versions/node/v18.17.0/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin NODE_PATH=/root/.cache/trunk/tools/eslint/8.52.0-a618ad632f0aeb358b6d43b1e01c686f/node_modules HOME=/root /root/.cache/trunk/tools/eslint/8.52.0-a618ad632f0aeb358b6d43b1e01c686f/node_modules/.bin/eslint --output-file /tmp/trunk-0/cg0vKx/qbquk1xNlQZA --format json tests/unit/queries/query.test.ts)
      affects_cache:
        - .eslintignore
        - package.json
        - tsconfig.json
      direct_configs:
        - .eslintrc
      exit_status: exited
      exit_code: 2
      stdout: (none)
      stderr: |
        Oops! Something went wrong! :(
        ESLint: 8.52.0
        ESLint couldn't find the config "@blitznocode/eslint-config" to extend from. Please check that the name of the config is correct.
        The config "@blitznocode/eslint-config" was referenced from the config file in "/tmp/trunk-0/CuArlP/HNCUME/.eslintrc".
        If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.
    parser: |
      (none)
  • [X] Modify package.json ! No changes made
Modify package.json with contents: Ensure that the "@blitznocode/eslint-config" package is included in the "devDependencies" section of the package.json file. If it's not present, add it with the appropriate version. After modifying the package.json, run "npm install" or "yarn install" to install the package.
  • [X] Check package.json
Run package.json through the sandbox.
  • [X] Modify .eslintrc ! No changes made
Modify .eslintrc with contents: Check the .eslintrc file to ensure that it's correctly configured to extend from "@blitznocode/eslint-config". The "extends" field in the .eslintrc file should include "@blitznocode/eslint-config". If it's not present, add it.
  • [X] Check .eslintrc
Run .eslintrc through the sandbox.
  • [X] Check tests/unit/queries/query.test.ts
Sandbox logs for
trunk init 1/3 ✓
⡿ Downloading Trunk 1.17.1...
⡿ Downloading Trunk 1.17.1...
⢿ Downloading Trunk 1.17.1...
⣻ Downloading Trunk 1.17.1...
⣽ Downloading Trunk 1.17.1...
⣾ Downloading Trunk 1.17.1...
⣷ Downloading Trunk 1.17.1...
✔ Downloading Trunk 1.17.1... done
⡿ Verifying Trunk sha256...
✔ Verifying Trunk sha256... done
⡿ Unpacking Trunk...
✔ Unpacking Trunk... done


✔ 10 linters were enabled (.trunk/trunk.yaml)
  checkov 3.0.15 (3 json, 2 yaml files)
  eslint 8.52.0 (2 javascript, 51 typescript files)
  git-diff-check (70 files)
  markdownlint 0.37.0 (2 markdown files) (created .markdownlint.yaml)
  prettier 3.0.3 (2 javascript, 3 json, 2 markdown, 1 prettier_supported_configs, 51 typescript, 2 yaml files)
  shellcheck 0.9.0 (1 shell file) (created .shellcheckrc)
  shfmt 3.6.0 (1 shell file)
  trivy 0.46.1 (2 yaml files)
  trufflehog 3.62.1 (70 files)
  yamllint 1.32.0 (2 yaml files) (created .yamllint.yaml)
Next Steps
 1. Read documentation
    Our documentation can be found at https://docs.trunk.io
 2. Get help and give feedback
    Join the Trunk community at https://slack.trunk.io
trunk fmt tests/unit/queries/query.test.ts || exit 0 2/3 ✓
 ✔ Formatted tests/unit/queries/query.test.ts
Re-checking autofixed files...


Checked 1 file
✔ No issues
trunk check --fix --print-failures tests/unit/queries/query.test.ts 3/3 ❌ (`1`)
  FAILURES  
 eslint  tests/unit/queries/query.test.ts  .trunk/out/fMjpQ.yaml
 eslint  tests/unit/queries/query.test.ts  .trunk/out/pCrmN.yaml
  NOTICES  
 [suggestion] Eslint could not resolve dependencies; try running `npm install`, `yarn install`, or your equivalent      
 thereof                                                                                                                
 Some tools failed to run. You can open the details yaml files for more information.                                    
Checked 1 file
✖ No issues, 2 failures
# .trunk/out/fMjpQ.yaml
trunk_cli_version: 1.17.1
title: eslint exited with exit_code=2
report:
  - eslint exited with exit_code=2
  - suggestion: Eslint could not resolve dependencies; try running `npm install`, `yarn install`, or your equivalent thereof
  - linter:
      command: |
        /root/.cache/trunk/tools/eslint/8.52.0-a618ad632f0aeb358b6d43b1e01c686f/node_modules/.bin/eslint --output-file /tmp/trunk-0/SJv9E3/6jNXiP8FYn5f --format json tests/unit/queries/query.test.ts
      stdin_path: (none)
      run_from: /tmp/trunk-0/mZYuu6/srRoG7
      timeout: 10m
      rerun: (cd /tmp/trunk-0/mZYuu6/srRoG7; env -i PATH=/root/.cache/trunk/tools/eslint/8.52.0-a618ad632f0aeb358b6d43b1e01c686f/node_modules/.bin:/root/.cache/trunk/tools/node/18.12.1-00ae74f39ac4de3ff3c7e3686016ebf3/bin:/root/.cache/trunk/tools/node/18.12.1-00ae74f39ac4de3ff3c7e3686016ebf3:/root/.nvm/versions/node/v18.17.0/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin NODE_PATH=/root/.cache/trunk/tools/eslint/8.52.0-a618ad632f0aeb358b6d43b1e01c686f/node_modules HOME=/root /root/.cache/trunk/tools/eslint/8.52.0-a618ad632f0aeb358b6d43b1e01c686f/node_modules/.bin/eslint --output-file /tmp/trunk-0/SJv9E3/6jNXiP8FYn5f --format json tests/unit/queries/query.test.ts)
      affects_cache:
        - .eslintignore
        - package.json
        - tsconfig.json
      direct_configs:
        - .eslintrc
      exit_status: exited
      exit_code: 2
      stdout: (none)
      stderr: |
        Oops! Something went wrong! :(
        ESLint: 8.52.0
        ESLint couldn't find the config "@blitznocode/eslint-config" to extend from. Please check that the name of the config is correct.
        The config "@blitznocode/eslint-config" was referenced from the config file in "/tmp/trunk-0/mZYuu6/srRoG7/.eslintrc".
        If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.
    parser: |
      (none)
# .trunk/out/pCrmN.yaml
trunk_cli_version: 1.17.1
title: eslint exited with exit_code=2
report:
  - eslint exited with exit_code=2
  - suggestion: Eslint could not resolve dependencies; try running `npm install`, `yarn install`, or your equivalent thereof
  - linter:
      command: |
        /root/.cache/trunk/tools/eslint/8.52.0-a618ad632f0aeb358b6d43b1e01c686f/node_modules/.bin/eslint --output-file /tmp/trunk-0/cg0vKx/qbquk1xNlQZA --format json tests/unit/queries/query.test.ts
      stdin_path: (none)
      run_from: /tmp/trunk-0/CuArlP/HNCUME
      timeout: 10m
      rerun: (cd /tmp/trunk-0/CuArlP/HNCUME; env -i PATH=/root/.cache/trunk/tools/eslint/8.52.0-a618ad632f0aeb358b6d43b1e01c686f/node_modules/.bin:/root/.cache/trunk/tools/node/18.12.1-00ae74f39ac4de3ff3c7e3686016ebf3/bin:/root/.cache/trunk/tools/node/18.12.1-00ae74f39ac4de3ff3c7e3686016ebf3:/root/.nvm/versions/node/v18.17.0/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin NODE_PATH=/root/.cache/trunk/tools/eslint/8.52.0-a618ad632f0aeb358b6d43b1e01c686f/node_modules HOME=/root /root/.cache/trunk/tools/eslint/8.52.0-a618ad632f0aeb358b6d43b1e01c686f/node_modules/.bin/eslint --output-file /tmp/trunk-0/cg0vKx/qbquk1xNlQZA --format json tests/unit/queries/query.test.ts)
      affects_cache:
        - .eslintignore
        - package.json
        - tsconfig.json
      direct_configs:
        - .eslintrc
      exit_status: exited
      exit_code: 2
      stdout: (none)
      stderr: |
        Oops! Something went wrong! :(
        ESLint: 8.52.0
        ESLint couldn't find the config "@blitznocode/eslint-config" to extend from. Please check that the name of the config is correct.
        The config "@blitznocode/eslint-config" was referenced from the config file in "/tmp/trunk-0/CuArlP/HNCUME/.eslintrc".
        If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.
    parser: |
      (none)
  • [X] Modify tests/mocks/data.tql ✓ https://github.com/Blitzapps/blitz-orm/commit/d29d060299cd4d1296a1b79c9f6f4d09f827a8d3
Modify tests/mocks/data.tql with contents:
• Based on the new tests added in the `query.test.ts` file, identify if there is a need for additional data in the database.
• If additional data is needed, add new lines of data to the `data.tql` file. The new data should be relevant to the new tests and should help in testing the queries effectively.
  • [X] Check tests/mocks/data.tql
Sandbox logs for
trunk fmt tests/mocks/data.tql || exit 0 1/2 ✓
Found no applicable linters for the requested path
trunk check --fix --print-failures tests/mocks/data.tql 2/2 ✓
Checked 1 file
✔ No issues

Step 3: 🔁 Code Review

I have finished reviewing the code for completeness. I did not find errors for sweep/add-query-tests.


🎉 Latest improvements to Sweep:

  • Sweep can now passively improve your repository! Check out Rules to learn more.

💡 To recreate the pull request edit the issue title or description. To tweak the pull request, leave a comment on the pull request. Join Our Discord