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
+8 -73
View File
@@ -2,7 +2,6 @@ package test
import (
"context"
"fmt"
"strings"
"testing"
@@ -63,90 +62,26 @@ func TestPutObject(t *testing.T) {
mockS3 := objectstoremock.NewMockS3Client(t)
cfg.StoreClient = mockS3
clientId := "byebye"
bucketName := "bucket"
file := strings.NewReader("hello")
filename := "hello"
expectedLocation := fmt.Sprintf("%s/%s", clientId, filename)
key := objectstore.BucketKey{
ClientID: "byebye",
Filename: "hello",
}
mockS3.EXPECT().
PutObject(
mock.Anything,
mock.MatchedBy(func(in *s3.PutObjectInput) bool {
return *in.Bucket == bucketName && *in.Key == expectedLocation
return *in.Bucket == bucketName && *in.Key == key.String()
}),
mock.Anything,
).
Return(&s3.PutObjectOutput{}, nil)
PutObject(t, ctx, cfg, PutObjectParams{
ClientId: clientId,
Bucket: bucketName,
Filepath: filename,
File: file,
})
}
func TestPutImportObject(t *testing.T) {
ctx := context.Background()
cfg := &StoreConfig{}
SetCfgProvider(t, cfg)
mockS3 := objectstoremock.NewMockS3Client(t)
cfg.StoreClient = mockS3
clientId := "byebye"
bucketName := "bucket"
file := strings.NewReader("hello")
filename := "hello"
expectedLocation := fmt.Sprintf("%s/import/%s", clientId, filename)
mockS3.EXPECT().
PutObject(
mock.Anything,
mock.MatchedBy(func(in *s3.PutObjectInput) bool {
return *in.Bucket == bucketName && *in.Key == expectedLocation
}),
mock.Anything,
).
Return(&s3.PutObjectOutput{}, nil)
PutImportObject(t, ctx, cfg, PutObjectParams{
ClientId: clientId,
Bucket: bucketName,
Filepath: filename,
File: file,
})
}
func TestPutTextractObject(t *testing.T) {
ctx := context.Background()
cfg := &StoreConfig{}
SetCfgProvider(t, cfg)
mockS3 := objectstoremock.NewMockS3Client(t)
cfg.StoreClient = mockS3
clientId := "byebye"
bucketName := "bucket"
file := strings.NewReader("hello")
filename := "hello"
expectedLocation := fmt.Sprintf("%s/text/textract/%s", clientId, filename)
mockS3.EXPECT().
PutObject(
mock.Anything,
mock.MatchedBy(func(in *s3.PutObjectInput) bool {
return *in.Bucket == bucketName && *in.Key == expectedLocation
}),
mock.Anything,
).
Return(&s3.PutObjectOutput{}, nil)
PutTextractObject(t, ctx, cfg, PutObjectParams{
ClientId: clientId,
Bucket: bucketName,
Filepath: filename,
File: file,
Bucket: bucketName,
File: file,
Key: key,
})
}