Merged in feature/clean (pull request #76)
Clean Set Up * fail * starteddb * constraint * cleantest * fixqueries * fixtests * storemimetype * buffer * tests * setup * passingtests * pdfHElloWorld * rm * test * notodos * tests * clean * testpdf
This commit is contained in:
@@ -57,9 +57,14 @@ func TestCreate(t *testing.T) {
|
||||
AddRow(false),
|
||||
)
|
||||
cleanId := database.MustToDBUUID(uuid.New())
|
||||
mimeType := "application/pdf"
|
||||
dbmimetype := repository.NullCleanmimetypes{
|
||||
Valid: true,
|
||||
Cleanmimetypes: repository.Cleanmimetypes(mimeType),
|
||||
}
|
||||
pool.ExpectQuery("name: GetDocumentCleanEntry :one").WithArgs(database.MustToDBUUID(id)).WillReturnRows(
|
||||
pgxmock.NewRows([]string{"id", "documentId", "bucket", "key", "version"}).
|
||||
AddRow(cleanId, database.MustToDBUUID(id), inloc.Bucket, inloc.Key, int32(1)),
|
||||
pgxmock.NewRows([]string{"id", "documentId", "bucket", "key", "version", "mimetype", "fail"}).
|
||||
AddRow(cleanId, database.MustToDBUUID(id), &inloc.Bucket, &inloc.Key, int32(1), dbmimetype, repository.NullCleanfailtype{}),
|
||||
)
|
||||
pool.ExpectExec("name: AddDocumentTextEntry :exec").WithArgs(int32(1), inloc.Bucket, inloc.Key, cleanId).
|
||||
WillReturnResult(pgxmock.NewResult("", 1))
|
||||
|
||||
@@ -2,6 +2,7 @@ package documenttext
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"queryorchestration/internal/database"
|
||||
"queryorchestration/internal/database/repository"
|
||||
"queryorchestration/internal/document"
|
||||
@@ -15,7 +16,6 @@ type ExtractionParams struct {
|
||||
}
|
||||
|
||||
func (s *Service) executeExtraction(params *ExtractionParams) (*document.Location, error) {
|
||||
// TODO - various extraction tasks
|
||||
return ¶ms.Location, nil
|
||||
}
|
||||
|
||||
@@ -25,13 +25,15 @@ func (s *Service) extract(ctx context.Context, id uuid.UUID) error {
|
||||
entry, err := s.cfg.GetDBQueries().GetDocumentCleanEntry(ctx, docId)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if entry.Fail.Valid {
|
||||
return fmt.Errorf("no valid cleaning")
|
||||
}
|
||||
|
||||
outLocation, err := s.executeExtraction(&ExtractionParams{
|
||||
ID: id,
|
||||
Location: document.Location{
|
||||
Bucket: entry.Bucket,
|
||||
Key: entry.Key,
|
||||
Bucket: *entry.Bucket,
|
||||
Key: *entry.Key,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -38,9 +38,14 @@ func TestExtract(t *testing.T) {
|
||||
}
|
||||
|
||||
cleanId := database.MustToDBUUID(uuid.New())
|
||||
mimeType := "application/pdf"
|
||||
dbmimetype := repository.NullCleanmimetypes{
|
||||
Valid: true,
|
||||
Cleanmimetypes: repository.Cleanmimetypes(mimeType),
|
||||
}
|
||||
pool.ExpectQuery("name: GetDocumentCleanEntry :one").WithArgs(database.MustToDBUUID(id)).WillReturnRows(
|
||||
pgxmock.NewRows([]string{"id", "documentId", "bucket", "key", "version"}).
|
||||
AddRow(cleanId, database.MustToDBUUID(id), inloc.Bucket, inloc.Key, int32(1)),
|
||||
pgxmock.NewRows([]string{"id", "documentId", "bucket", "key", "version", "mimetype", "fail"}).
|
||||
AddRow(cleanId, database.MustToDBUUID(id), &inloc.Bucket, &inloc.Key, int32(1), dbmimetype, repository.NullCleanfailtype{}),
|
||||
)
|
||||
pool.ExpectExec("name: AddDocumentTextEntry :exec").WithArgs(int32(1), inloc.Bucket, inloc.Key, cleanId).
|
||||
WillReturnResult(pgxmock.NewResult("", 1))
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
)
|
||||
|
||||
func (s *Service) GetVersion() int32 {
|
||||
// TODO - actual version
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user