/
ecs_pod_definition_manager.go
59 lines (47 loc) · 2.01 KB
/
ecs_pod_definition_manager.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
package mock
import (
"context"
"github.com/evergreen-ci/cocoa"
"github.com/evergreen-ci/utility"
)
// ECSPodDefinitionManager provides a mock implementation of a
// cocoa.ECSPodDefinitionManager backed by another ECS pod definition manager
// implementation.
type ECSPodDefinitionManager struct {
cocoa.ECSPodDefinitionManager
CreatePodDefinitionInput []cocoa.ECSPodDefinitionOptions
CreatePodDefinitionOutput *cocoa.ECSPodDefinitionItem
CreatePodDefinitionError error
DeletePodDefinitionInput *string
DeletePodDefinitionError error
}
// NewECSPodDefinitionManager creates a mock ECS pod definition manager backed
// by the given pod definition manager.
func NewECSPodDefinitionManager(m cocoa.ECSPodDefinitionManager) *ECSPodDefinitionManager {
return &ECSPodDefinitionManager{
ECSPodDefinitionManager: m,
}
}
// CreatePodDefinition saves the input and returns a new mock pod definition
// item. The mock output can be customized. By default, it will return the
// result of creating the pod definition in the backing ECS pod definition
// manager.
func (m *ECSPodDefinitionManager) CreatePodDefinition(ctx context.Context, opts ...cocoa.ECSPodDefinitionOptions) (*cocoa.ECSPodDefinitionItem, error) {
m.CreatePodDefinitionInput = opts
if m.CreatePodDefinitionOutput != nil {
return m.CreatePodDefinitionOutput, m.CreatePodDefinitionError
} else if m.CreatePodDefinitionError != nil {
return nil, m.CreatePodDefinitionError
}
return m.ECSPodDefinitionManager.CreatePodDefinition(ctx, opts...)
}
// DeletePodDefinition saves the input and deletes the mock pod definition. The
// mock output can be customized. By default, it will return the result of
// deleting the pod definition from the backing ECS pod definition manager.
func (m *ECSPodDefinitionManager) DeletePodDefinition(ctx context.Context, id string) error {
m.DeletePodDefinitionInput = utility.ToStringPtr(id)
if m.DeletePodDefinitionError != nil {
return m.DeletePodDefinitionError
}
return m.ECSPodDefinitionManager.DeletePodDefinition(ctx, id)
}