Merged in feature/standardisefilepath (pull request #111)

Feature/standardisefilepath

* baseprocessing

* generalstructure
This commit is contained in:
Michael McGuinness
2025-04-03 12:13:16 +00:00
parent 81e7223560
commit 1d49313a9f
17 changed files with 466 additions and 253 deletions
+9 -2
View File
@@ -5,6 +5,7 @@ import (
"log/slog"
documenttext "queryorchestration/internal/document/text"
"queryorchestration/internal/serviceconfig/objectstore"
"github.com/go-playground/validator/v10"
)
@@ -35,9 +36,15 @@ type Body struct {
}
func (s Runner) Process(ctx context.Context, body Body) bool {
err := s.svc.Text.Process(ctx, &documenttext.ProcessParams{
key, err := objectstore.ParseBucketKey(body.Key)
if err != nil {
slog.Error("unable to parse key", "key", body.Key)
return true
}
err = s.svc.Text.Process(ctx, &documenttext.ProcessParams{
Bucket: body.Bucket,
Key: body.Key,
Key: key,
Hash: body.Hash,
ClientID: body.ClientID,
})
+44 -3
View File
@@ -2,10 +2,12 @@ package doctextprocessrunner
import (
"context"
"errors"
"fmt"
"io"
"strings"
"testing"
"time"
"queryorchestration/internal/database/repository"
"queryorchestration/internal/document"
@@ -55,7 +57,7 @@ func TestDocTextProcessRunner(t *testing.T) {
})
assert.NotNil(t, runner)
t.Run("valid", func(t *testing.T) {
t.Run("pass through", func(t *testing.T) {
triggerId := uuid.New()
docId := uuid.New()
textractId := "heeloo"
@@ -67,10 +69,15 @@ func TestDocTextProcessRunner(t *testing.T) {
ClientID: "hello",
Hash: `"5d41402abc4b2a76b9719d911017c592"`,
}
location := fmt.Sprintf("%s/text/textract/%s", docinfo.ClientID, triggerId)
key := objectstore.BucketKey{
ClientID: docinfo.ClientID,
Location: objectstore.TextTextract,
Filename: triggerId.String(),
CreatedAt: time.Now().UTC(),
}
doc := Body{
Bucket: bucketName,
Key: location,
Key: key.String(),
Hash: docinfo.Hash,
ClientID: docinfo.ClientID,
}
@@ -113,4 +120,38 @@ func TestDocTextProcessRunner(t *testing.T) {
assert.True(t, runner.Process(ctx, doc))
})
t.Run("invalid key", func(t *testing.T) {
key := objectstore.BucketKey{}
doc := Body{
Key: key.String(),
}
assert.True(t, runner.Process(ctx, doc))
})
t.Run("unable to process", func(t *testing.T) {
triggerId := uuid.New()
bucketName := "bucketName"
docinfo := document.DocumentSummary{
ID: uuid.New(),
ClientID: "hello",
Hash: `"5d41402abc4b2a76b9719d911017c592"`,
}
key := objectstore.BucketKey{
ClientID: docinfo.ClientID,
Location: objectstore.TextTextract,
Filename: triggerId.String(),
CreatedAt: time.Now().UTC(),
}
doc := Body{
Bucket: bucketName,
Key: key.String(),
Hash: docinfo.Hash,
ClientID: docinfo.ClientID,
}
pool.ExpectQuery("name: GetDocumentTextTrigger :one").WithArgs(triggerId).
WillReturnError(errors.New("db fail"))
assert.False(t, runner.Process(ctx, doc))
})
}