Skip to content

Conversation

gru-agent[bot]
Copy link
Contributor

@gru-agent gru-agent bot commented Jul 10, 2025

Trigger Info

Trigger Type Triggered By Source Pull Request Assignment
PR Created colnii 5192 Detail

Summary

This PR introduces unit tests for the updateTrainingData API handler to ensure its functionality and reliability. Key changes include:

  1. Export Handler: The handler function is now exported from updateTrainingData.ts for testing purposes.

  2. Unit Tests:

    • Retry All Error Data: Tests the scenario where dataId is not provided, ensuring all error data is retried.

    • Update Single Training Data with Image: Validates the update logic when training data includes an image.

    • Update Single Training Data without Image: Ensures proper handling and update when training data does not include an image.

    • Reject When Data Not Found: Confirms the handler rejects the request when the specified data is not found.

  3. Mocking Dependencies:

    • Mocked MongoDatasetTraining methods (findOne, updateOne, updateMany) to simulate database interactions.

    • Mocked authDatasetCollection to simulate authentication and authorization checks.

These tests enhance the robustness of the updateTrainingData API by verifying its behavior under various conditions.

Coverage

The change in coverage value, such as: 0% -> 50%, indicates that the coverage was 0% before writing the tests and 50% after writing them.

https://web.dev/articles/ta-code-coverage

Type Change
lines 0% -> 100% 🔺
functions 0% -> 100% 🔺
statements 0% -> 100% 🔺
branches 0% -> 100% 🔺
source program

Test Statuses

Status Change
passed 0 -> 4 🔺
failed 0 -> 0
skipped 0 -> 0
source program

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

Copy link

Preview sandbox Image:

registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-pr:fatsgpt_sandbox_1526312e87cbfa0bb33239ff9b55ad23f0dd793a

Copy link

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 22.03% 12000 / 54450
🔵 Statements 22.03% 12000 / 54450
🔵 Functions 28.76% 311 / 1081
🔵 Branches 67.38% 847 / 1257
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
projects/app/src/pages/api/core/dataset/training/updateTrainingData.ts 100% 100% 100% 100%
Generated in workflow #1387 for commit 1526312 by the Vitest Coverage Report Action

Copy link

Preview mcp_server Image:

registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-pr:fatsgpt_mcp_server_1526312e87cbfa0bb33239ff9b55ad23f0dd793a

Copy link

Preview fastgpt Image:

registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-pr:fatsgpt_1526312e87cbfa0bb33239ff9b55ad23f0dd793a

@c121914yu c121914yu merged commit 2865419 into main Jul 10, 2025
8 checks passed
@c121914yu c121914yu deleted the gru/projects-app-src-pages-api-core-dataset-training-updateTrainingData-ts-1752133672041 branch July 16, 2025 13:03
xqvvu pushed a commit to xqvvu/FastGPT that referenced this pull request Jul 17, 2025
…o be optional for retrying all error data. (labring#5194)

Co-authored-by: gru-agent[bot] <185149714+gru-agent[bot]@users.noreply.github.com>
dreamer6680 pushed a commit to dreamer6680/FastGPT1 that referenced this pull request Jul 21, 2025
…o be optional for retrying all error data. (labring#5194)

Co-authored-by: gru-agent[bot] <185149714+gru-agent[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant