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

✅ test: add unit test for src/server/routers/lambda/aiModel.ts #6085

Conversation

gru-agent[bot]
Copy link
Contributor

@gru-agent gru-agent bot commented Feb 13, 2025

Trigger Info

Trigger Type Triggered By Source Pull Request Assignment
Auto Rebase arvinxx 6080 Detail

Summary

This PR introduces unit tests for the aiModelRouter module, ensuring comprehensive coverage of its functionalities. The following key features are tested:

  • Batch Operations:

    • batchToggleAiModels: Verifies toggling the enabled state of multiple AI models.

    • batchUpdateAiModels: Ensures batch updates of AI models are handled correctly.

  • Model Management:

    • clearModelsByProvider: Tests clearing models associated with a specific provider.

    • clearRemoteModels: Validates clearing remote models for a given provider.

    • createAiModel: Confirms the creation of a new AI model and returns the created model's ID.

    • getAiModelById: Ensures retrieval of an AI model by its ID.

    • removeAiModel: Verifies the deletion of an AI model by ID and provider.

  • Model State and Order:

    • toggleModelEnabled: Tests toggling the enabled state of a specific model.

    • updateAiModel: Validates updating a model's attributes.

    • updateAiModelOrder: Ensures the correct reordering of models based on a provided sort map.

Mocks are used for dependencies such as AiModelModel, UserModel, AiInfraRepos, KeyVaultsGateKeeper, and getServerGlobalConfig to isolate the tests and focus on the router's logic. Each test case ensures the corresponding method is called with the expected arguments.

Tip

You can @gru-agent and leave your feedback. TestGru will make adjustments based on your input

Tip

You can @gru-agent rebase to rebase the PR.

Tip

You can @gru-agent redo to reset or rebase before redoing the PR.

Tip

To modify the test code yourself, click here Edit Test Code

@gru-agent gru-agent bot requested a review from arvinxx February 13, 2025 05:47
@gru-agent gru-agent bot mentioned this pull request Feb 13, 2025
8 tasks
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Feb 13, 2025
Copy link

vercel bot commented Feb 13, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
lobe-chat-database ⬜️ Ignored (Inspect) Visit Preview Feb 13, 2025 6:37am
lobe-chat-preview ⬜️ Ignored (Inspect) Visit Preview Feb 13, 2025 6:37am

@lobehubbot
Copy link
Member

👍 @gru-agent[bot]

Thank you for raising your pull request and contributing to our Community
Please make sure you have followed our contributing guidelines. We will review it as soon as possible.
If you encounter any problems, please feel free to connect with us.
非常感谢您提出拉取请求并为我们的社区做出贡献,请确保您已经遵循了我们的贡献指南,我们会尽快审查它。
如果您遇到任何问题,请随时与我们联系。

Copy link

codecov bot commented Feb 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.44%. Comparing base (257fda1) to head (da23dff).
Report is 27 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6085      +/-   ##
==========================================
+ Coverage   92.43%   92.44%   +0.01%     
==========================================
  Files         661      662       +1     
  Lines       60005    60138     +133     
  Branches     3022     2833     -189     
==========================================
+ Hits        55463    55595     +132     
- Misses       4542     4543       +1     
Flag Coverage Δ
app 92.44% <ø> (+0.01%) ⬆️
server 97.90% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor Author

gru-agent bot commented Feb 13, 2025

TestGru Assignment

Summary

Link CommitId Status Reason
Detail da23dff 🚫 Skipped No files need to be tested {"src/server/routers/lambda/aiModel.test.ts":"target file(src/server/routers/lambda/aiModel.test.ts) not in work scope \n include: src/utils,src/server,src/database,src/services,src/store \n exclude: node_modules,/*.test.ts,/.test.tsx,**/.spec.ts,/*.spec.tsx,/.d.ts,**/.test.js,**/*.spec.js"}

Tip

You can @gru-agent and leave your feedback. TestGru will make adjustments based on your input

@arvinxx arvinxx closed this Feb 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants