Merged in feature/richname (pull request #112)
Standardised rich name for Files * tests
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"io"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"queryorchestration/internal/database/repository"
|
||||
"queryorchestration/internal/document"
|
||||
@@ -55,10 +56,14 @@ func TestCreate(t *testing.T) {
|
||||
ClientID: "yuyu",
|
||||
Hash: "example_hash",
|
||||
}
|
||||
inloc := document.Location{
|
||||
Bucket: "bucket_name",
|
||||
Key: "/i/am/here",
|
||||
bucket := "example_bucket"
|
||||
key := objectstore.BucketKey{
|
||||
ClientID: doc.ClientID,
|
||||
CreatedAt: time.Now().UTC(),
|
||||
EntityID: uuid.New(),
|
||||
Location: objectstore.Import,
|
||||
}
|
||||
keyStr := key.String()
|
||||
dbid := doc.ID
|
||||
|
||||
pool.ExpectQuery("name: HasDocumentCleanEntry :one").WithArgs(dbid).WillReturnRows(
|
||||
@@ -72,7 +77,7 @@ func TestCreate(t *testing.T) {
|
||||
)
|
||||
pool.ExpectQuery("name: GetDocumentEntry :one").WithArgs(dbid).WillReturnRows(
|
||||
pgxmock.NewRows([]string{"documentId", "bucket", "key"}).
|
||||
AddRow(dbid, inloc.Bucket, inloc.Key),
|
||||
AddRow(dbid, bucket, keyStr),
|
||||
)
|
||||
mimeType := "application/pdf"
|
||||
dbmimetype := repository.NullCleanmimetype{
|
||||
@@ -85,7 +90,7 @@ func TestCreate(t *testing.T) {
|
||||
pgxmock.NewRows([]string{"id", "documentId", "bucket", "key", "version", "hash", "mimetype", "fail"}),
|
||||
)
|
||||
cleanid := uuid.New()
|
||||
pool.ExpectQuery("name: AddDocumentClean :one").WithArgs(dbid, &inloc.Bucket, &inloc.Key, &doc.Hash, dbmimetype, repository.NullCleanfailtype{}).
|
||||
pool.ExpectQuery("name: AddDocumentClean :one").WithArgs(dbid, &bucket, &keyStr, &doc.Hash, dbmimetype, repository.NullCleanfailtype{}).
|
||||
WillReturnRows(
|
||||
pgxmock.NewRows([]string{"id"}).
|
||||
AddRow(cleanid),
|
||||
@@ -108,7 +113,7 @@ func TestCreate(t *testing.T) {
|
||||
HeadObject(
|
||||
mock.Anything,
|
||||
mock.MatchedBy(func(in *s3.HeadObjectInput) bool {
|
||||
return *in.Bucket == inloc.Bucket && *in.Key == inloc.Key
|
||||
return *in.Bucket == bucket && *in.Key == key.String()
|
||||
}),
|
||||
mock.Anything,
|
||||
).
|
||||
@@ -121,7 +126,7 @@ func TestCreate(t *testing.T) {
|
||||
GetObject(
|
||||
mock.Anything,
|
||||
mock.MatchedBy(func(in *s3.GetObjectInput) bool {
|
||||
return *in.Bucket == inloc.Bucket && *in.Key == inloc.Key
|
||||
return *in.Bucket == bucket && *in.Key == key.String()
|
||||
}),
|
||||
mock.Anything,
|
||||
).
|
||||
|
||||
Reference in New Issue
Block a user