/
fake.go
68 lines (54 loc) · 2.29 KB
/
fake.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
Copyright 2019 The Crossplane Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package fake
import (
"context"
"cloud.google.com/go/storage"
gcpstorage "github.com/crossplaneio/stack-gcp/pkg/clients/storage"
)
// MockBucketClient Client interface implementation
type MockBucketClient struct {
MockAttrs func(context.Context) (*storage.BucketAttrs, error)
MockCreate func(context.Context, string, *storage.BucketAttrs) error
MockUpdate func(context.Context, storage.BucketAttrsToUpdate) (*storage.BucketAttrs, error)
MockDelete func(context.Context) error
}
// NewMockBucketClient returns new MockBucketClient with default mock implementations
func NewMockBucketClient() *MockBucketClient {
return &MockBucketClient{
MockAttrs: func(i context.Context) (attrs *storage.BucketAttrs, e error) { return nil, nil },
MockCreate: func(i context.Context, s string, attrs *storage.BucketAttrs) error { return nil },
MockUpdate: func(i context.Context, update storage.BucketAttrsToUpdate) (attrs *storage.BucketAttrs, e error) {
return nil, nil
},
MockDelete: func(i context.Context) error { return nil },
}
}
// Attrs retrieves bucket attributes
func (m *MockBucketClient) Attrs(ctx context.Context) (*storage.BucketAttrs, error) {
return m.MockAttrs(ctx)
}
// Create new bucket resource
func (m *MockBucketClient) Create(ctx context.Context, projectID string, attrs *storage.BucketAttrs) error {
return m.MockCreate(ctx, projectID, attrs)
}
// Update existing bucket resource
func (m *MockBucketClient) Update(ctx context.Context, attrs storage.BucketAttrsToUpdate) (*storage.BucketAttrs, error) {
return m.MockUpdate(ctx, attrs)
}
// Delete existing bucket resource
func (m *MockBucketClient) Delete(ctx context.Context) error {
return m.MockDelete(ctx)
}
// assert interface
var _ gcpstorage.Client = &MockBucketClient{}