a9d81a1094
remove parallel to stabilize ci/cd
65 lines
1.2 KiB
Go
65 lines
1.2 KiB
Go
package test
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"queryorchestration/internal/serviceconfig"
|
|
"queryorchestration/internal/serviceconfig/aws"
|
|
|
|
objectstore "queryorchestration/internal/serviceconfig/objectstore"
|
|
objectstoremock "queryorchestration/mocks/objectstore"
|
|
|
|
"github.com/aws/aws-sdk-go-v2/service/s3"
|
|
"github.com/stretchr/testify/mock"
|
|
)
|
|
|
|
type StoreConfig struct {
|
|
aws.AWSConfig
|
|
serviceconfig.BaseConfig
|
|
objectstore.ObjectStoreConfig
|
|
}
|
|
|
|
func TestCreateBucket(t *testing.T) {
|
|
if testing.Short() {
|
|
t.SkipNow()
|
|
}
|
|
ctx := t.Context()
|
|
|
|
cfg := &StoreConfig{}
|
|
|
|
acfg := CreateAWSContainer(t, cfg)
|
|
SetStoreClient(t, ctx, cfg, acfg.ExternalEndpoint)
|
|
|
|
CreateBucket(t, cfg)
|
|
}
|
|
|
|
func TestPutObject(t *testing.T) {
|
|
ctx := t.Context()
|
|
|
|
cfg := &StoreConfig{}
|
|
|
|
mockS3 := objectstoremock.NewMockS3Client(t)
|
|
cfg.StoreClient = mockS3
|
|
|
|
file := strings.NewReader("hello")
|
|
key := objectstore.BucketKey{
|
|
ClientID: "byebye",
|
|
}
|
|
|
|
mockS3.EXPECT().
|
|
PutObject(
|
|
mock.Anything,
|
|
mock.MatchedBy(func(in *s3.PutObjectInput) bool {
|
|
return *in.Bucket == GetAlias(t, "bucket") && *in.Key == key.String()
|
|
}),
|
|
mock.Anything,
|
|
).
|
|
Return(&s3.PutObjectOutput{}, nil)
|
|
|
|
PutObject(t, ctx, cfg, PutObjectParams{
|
|
File: file,
|
|
Key: key,
|
|
})
|
|
}
|