Merged in feature/standardisefilepath (pull request #111)
Feature/standardisefilepath * baseprocessing * generalstructure
This commit is contained in:
@@ -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,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user