mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-28 19:58:11 +08:00
Add Go service/handler tests for API contract parity (#16905)
This commit is contained in:
@@ -68,7 +68,7 @@ func (s *DocumentService) DownloadDocument(datasetID, docID string) (*DownloadDo
|
||||
}
|
||||
doc, err := s.documentDAO.GetByID(docID)
|
||||
if err != nil || doc.KbID != datasetID {
|
||||
return nil, fmt.Errorf("The dataset not own the document %s.", docID)
|
||||
return nil, fmt.Errorf("Document not found!")
|
||||
}
|
||||
bucket, name, err := s.GetDocumentStorageAddress(doc)
|
||||
if err != nil {
|
||||
|
||||
@@ -232,8 +232,13 @@ func (s *DocumentService) validateDatasetDocumentUpdate(datasetID, documentID, u
|
||||
if present["token_count"] && req.TokenCount != nil && *req.TokenCount != 0 && *req.TokenCount != doc.TokenNum {
|
||||
return common.CodeDataError, errors.New("Can't change `token_count`.")
|
||||
}
|
||||
if present["progress"] && req.Progress != nil && *req.Progress != 0 && math.Abs(*req.Progress-doc.Progress) > 1e-9 {
|
||||
return common.CodeDataError, errors.New("Can't change `progress`.")
|
||||
if present["progress"] && req.Progress != nil {
|
||||
if *req.Progress > 1 {
|
||||
return common.CodeDataError, fmt.Errorf("Field: <progress> - Message: <Input should be less than or equal to 1> - Value: <%v>", *req.Progress)
|
||||
}
|
||||
if *req.Progress != 0 && math.Abs(*req.Progress-doc.Progress) > 1e-9 {
|
||||
return common.CodeDataError, errors.New("Can't change `progress`.")
|
||||
}
|
||||
}
|
||||
|
||||
if present["enabled"] {
|
||||
|
||||
@@ -288,7 +288,7 @@ func (s *DocumentService) validateDocsInDataset(docIDs []string, datasetID strin
|
||||
}
|
||||
}
|
||||
if len(invalid) > 0 {
|
||||
return nil, fmt.Errorf("these documents do not belong to dataset %s: %v", datasetID, invalid)
|
||||
return nil, fmt.Errorf("These documents do not belong to dataset %s: %v", datasetID, invalid)
|
||||
}
|
||||
return docs, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user