Skip to content

Commit

Permalink
Add missing mock functions
Browse files Browse the repository at this point in the history
  • Loading branch information
hakman committed Oct 22, 2023
1 parent a66061d commit 5e92d89
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cloudmock/aws/mockec2/launch_templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ limitations under the License.
package mockec2

import (
"context"
"fmt"
"strings"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/service/ec2"
"k8s.io/klog/v2"
)
Expand All @@ -43,6 +45,11 @@ func (m *MockEC2) DescribeLaunchTemplatesPages(request *ec2.DescribeLaunchTempla
return nil
}

// DescribeLaunchTemplatesPagesWithContext mocks the describing the launch templates
func (m *MockEC2) DescribeLaunchTemplatesPagesWithContext(ctx context.Context, request *ec2.DescribeLaunchTemplatesInput, callback func(*ec2.DescribeLaunchTemplatesOutput, bool) bool, option ...request.Option) error {
return m.DescribeLaunchTemplatesPages(request, callback)
}

// DescribeLaunchTemplates mocks the describing the launch templates
func (m *MockEC2) DescribeLaunchTemplates(request *ec2.DescribeLaunchTemplatesInput) (*ec2.DescribeLaunchTemplatesOutput, error) {
m.mutex.Lock()
Expand Down Expand Up @@ -116,6 +123,11 @@ func (m *MockEC2) DescribeLaunchTemplateVersions(request *ec2.DescribeLaunchTemp
return o, nil
}

// DescribeLaunchTemplateVersionsWithContext mocks the retrieval of launch template versions - we don't use this at the moment so we can just return the template
func (m *MockEC2) DescribeLaunchTemplateVersionsWithContext(ctx context.Context, request *ec2.DescribeLaunchTemplateVersionsInput, option ...request.Option) (*ec2.DescribeLaunchTemplateVersionsOutput, error) {
return m.DescribeLaunchTemplateVersions(request)
}

// CreateLaunchTemplate mocks the ec2 create launch template
func (m *MockEC2) CreateLaunchTemplate(request *ec2.CreateLaunchTemplateInput) (*ec2.CreateLaunchTemplateOutput, error) {
m.mutex.Lock()
Expand Down
5 changes: 5 additions & 0 deletions pkg/instancegroups/rollingupdate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/service/autoscaling"
"github.com/aws/aws-sdk-go/service/autoscaling/autoscalingiface"
"github.com/aws/aws-sdk-go/service/ec2"
Expand Down Expand Up @@ -949,6 +950,10 @@ func (m *disabledSurgeTest) DetachInstances(input *autoscaling.DetachInstancesIn
return &autoscaling.DetachInstancesOutput{}, nil
}

func (m *disabledSurgeTest) DetachInstancesWithContext(ctx context.Context, input *autoscaling.DetachInstancesInput, option ...request.Option) (*autoscaling.DetachInstancesOutput, error) {
return m.DetachInstances(input)
}

func TestRollingUpdateDisabledSurge(t *testing.T) {
c, cloud := getTestSetup()

Expand Down

0 comments on commit 5e92d89

Please sign in to comment.