Files
query-orchestration/internal/document/clean/content_test.go
T
Michael McGuinness bbd86fb4ea Merged in feature/CollectorBuildVersion (pull request #100)
Collector Build Version

* lint

* fixtests
2025-03-11 18:15:49 +00:00

57 lines
1.1 KiB
Go

package documentclean
import (
"context"
"io"
"strings"
"testing"
"queryorchestration/internal/document"
objectstoremock "queryorchestration/mocks/objectstore"
"github.com/aws/aws-sdk-go-v2/service/s3"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)
func TestGetContent(t *testing.T) {
t.Run("Working", func(t *testing.T) {
ctx := context.Background()
cfg := &DocCleanConfig{}
mockS3 := objectstoremock.NewMockS3Client(t)
cfg.StoreClient = mockS3
svc := Service{
cfg: cfg,
}
inloc := document.Location{
Bucket: "bucket_name",
Key: "/i/am/here",
}
params := &CleanParams{
Hash: "hash",
Location: inloc,
}
mimeType := MimeTypePDF
body := io.NopCloser(strings.NewReader(pdfHelloWorld))
mockS3.EXPECT().
GetObject(
mock.Anything,
mock.MatchedBy(func(in *s3.GetObjectInput) bool {
return *in.Bucket == inloc.Bucket && *in.Key == inloc.Key
}),
mock.Anything,
).
Return(&s3.GetObjectOutput{
Body: body,
}, nil)
content, err := svc.getContent(ctx, params, mimeType)
assert.NoError(t, err)
assert.NotNil(t, content)
})
}