Skip to content

Commit 1fae4f6

Browse files
pa250194squaremo
authored andcommitted
Tests for GCP Bucket Provider
Signed-off-by: pa250194 <[email protected]>
1 parent 57b54c8 commit 1fae4f6

File tree

4 files changed

+4
-36
lines changed

4 files changed

+4
-36
lines changed

docs/spec/v1alpha1/buckets.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Bucket:
1111
// BucketSpec defines the desired state of an S3 compatible bucket
1212
type BucketSpec struct {
1313
// The S3 compatible storage provider name, default ('generic').
14-
// +kubebuilder:validation:Enum=generic;aws
14+
// +kubebuilder:validation:Enum=generic;aws;gcp
1515
// +optional
1616
Provider string `json:"provider,omitempty"`
1717

pkg/gcp/gcp.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ type Client interface {
5555
}
5656

5757
type BucketHandle interface {
58-
Create(context.Context, string, *gcpStorage.BucketAttrs) error
59-
Delete(context.Context) error
6058
Attrs(context.Context) (*gcpStorage.BucketAttrs, error)
6159
Object(string) *gcpStorage.ObjectHandle
6260
Objects(context.Context, *gcpStorage.Query) *gcpStorage.ObjectIterator
@@ -66,10 +64,11 @@ type ObjectHandle interface {
6664
Attrs(context.Context) (*gcpStorage.ObjectAttrs, error)
6765
NewRangeReader(context.Context, int64, int64) (*gcpStorage.Reader, error)
6866
}
67+
6968
type GCPClient struct {
7069
// client for interacting with the Google Cloud
7170
// Storage APIs.
72-
Client Client
71+
Client
7372
// startRange is the starting read value for
7473
// reading the object from bucket.
7574
StartRange int64
@@ -165,9 +164,6 @@ func ValidateSecret(secret map[string][]byte, name string) error {
165164
if _, exists := secret["clientemail"]; !exists {
166165
return fmt.Errorf("invalid '%s' secret data: required fields 'clientemail'", name)
167166
}
168-
if _, exists := secret["clientemail"]; !exists {
169-
return fmt.Errorf("invalid '%s' secret data: required fields 'clientemail'", name)
170-
}
171167
if _, exists := secret["clientid"]; !exists {
172168
return fmt.Errorf("invalid '%s' secret data: required fields 'clientid'", name)
173169
}

pkg/gcp/gcp_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ var _ = BeforeSuite(func() {
5757
Expect(err).ToNot(HaveOccurred())
5858
}
5959
localPath = filepath.Join(tempDir, objectName)
60-
MockClient.EXPECT().Bucket(bucketName).Return(MockBucketHandle).AnyTimes()
60+
MockClient.EXPECT().Bucket(bucketName).Return(&gcpStorage.BucketHandle{}).AnyTimes()
6161
MockBucketHandle.EXPECT().Object(objectName).Return(&gcpStorage.ObjectHandle{}).AnyTimes()
6262
MockBucketHandle.EXPECT().Attrs(context.Background()).Return(&gcpStorage.BucketAttrs{
6363
Name: bucketName,

pkg/gcp/mocks/mock_gcp_storage.go

Lines changed: 0 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)