From 454d21d87f8395d2a0affafb8597e3fcf1334905 Mon Sep 17 00:00:00 2001 From: Adrian Utrilla Date: Wed, 22 Feb 2017 12:26:02 +0100 Subject: [PATCH] Update mocks --- CONTRIBUTING.md | 4 ++ Makefile | 6 +- kms/mocks/KMSAPI.go | 154 ++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 157 insertions(+), 7 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 35d69efd4..adedd9c1a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,6 +20,10 @@ Mozilla welcomes contributions from everyone. Here are a few guidelines and inst * Unless it's particularly hard, changes that fix a bug should have a regression test to make sure that the bug is not introduced again. * New features and changes to existing features should be documented, and, if possible, tested. +# Regenerating mocks + +If you encounter an error like `kms/mocks/KMSAPI.go:1607: cannot use (*KMSAPI)(nil) (type *KMSAPI) as type kmsiface.KMSAPI in assignment: *KMSAPI does not implement kmsiface.KMSAPI (missing ListResourceTags method)`, you need to regenerate mocks, probably because the interface was changed by a vendoring update. There is a make command to do this for you. Simply run `make mock`, and the new mocks will be automatically generated. + # Communication If you need any help contributing to sops, several contributors are on the `#go` channel on [Mozilla's IRC server](https://wiki.mozilla.org/IRC). diff --git a/Makefile b/Makefile index 37fe8aac4..280461796 100644 --- a/Makefile +++ b/Makefile @@ -91,4 +91,8 @@ endif download-index: bash make_download_page.sh -.PHONY: all test generate clean vendor functional-tests +mock: + go get github.com/vektra/mockery/.../ + mockery -dir vendor/github.com/aws/aws-sdk-go/service/kms/kmsiface/ -name KMSAPI -output kms/mocks + +.PHONY: all test generate clean vendor functional-tests mock diff --git a/kms/mocks/KMSAPI.go b/kms/mocks/KMSAPI.go index 8b40d67ab..c4dd55a5d 100644 --- a/kms/mocks/KMSAPI.go +++ b/kms/mocks/KMSAPI.go @@ -1,11 +1,9 @@ package mocks -import ( - "github.com/aws/aws-sdk-go/aws/request" - "github.com/aws/aws-sdk-go/service/kms" - "github.com/aws/aws-sdk-go/service/kms/kmsiface" - "github.com/stretchr/testify/mock" -) +import kms "github.com/aws/aws-sdk-go/service/kms" +import kmsiface "github.com/aws/aws-sdk-go/service/kms/kmsiface" +import mock "github.com/stretchr/testify/mock" +import request "github.com/aws/aws-sdk-go/aws/request" // KMSAPI is an autogenerated mock type for the KMSAPI type type KMSAPI struct { @@ -1220,6 +1218,54 @@ func (_m *KMSAPI) ListKeysRequest(_a0 *kms.ListKeysInput) (*request.Request, *km return r0, r1 } +// ListResourceTags provides a mock function with given fields: _a0 +func (_m *KMSAPI) ListResourceTags(_a0 *kms.ListResourceTagsInput) (*kms.ListResourceTagsOutput, error) { + ret := _m.Called(_a0) + + var r0 *kms.ListResourceTagsOutput + if rf, ok := ret.Get(0).(func(*kms.ListResourceTagsInput) *kms.ListResourceTagsOutput); ok { + r0 = rf(_a0) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*kms.ListResourceTagsOutput) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(*kms.ListResourceTagsInput) error); ok { + r1 = rf(_a0) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ListResourceTagsRequest provides a mock function with given fields: _a0 +func (_m *KMSAPI) ListResourceTagsRequest(_a0 *kms.ListResourceTagsInput) (*request.Request, *kms.ListResourceTagsOutput) { + ret := _m.Called(_a0) + + var r0 *request.Request + if rf, ok := ret.Get(0).(func(*kms.ListResourceTagsInput) *request.Request); ok { + r0 = rf(_a0) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*request.Request) + } + } + + var r1 *kms.ListResourceTagsOutput + if rf, ok := ret.Get(1).(func(*kms.ListResourceTagsInput) *kms.ListResourceTagsOutput); ok { + r1 = rf(_a0) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*kms.ListResourceTagsOutput) + } + } + + return r0, r1 +} + // ListRetirableGrants provides a mock function with given fields: _a0 func (_m *KMSAPI) ListRetirableGrants(_a0 *kms.ListRetirableGrantsInput) (*kms.ListGrantsResponse, error) { ret := _m.Called(_a0) @@ -1508,6 +1554,102 @@ func (_m *KMSAPI) ScheduleKeyDeletionRequest(_a0 *kms.ScheduleKeyDeletionInput) return r0, r1 } +// TagResource provides a mock function with given fields: _a0 +func (_m *KMSAPI) TagResource(_a0 *kms.TagResourceInput) (*kms.TagResourceOutput, error) { + ret := _m.Called(_a0) + + var r0 *kms.TagResourceOutput + if rf, ok := ret.Get(0).(func(*kms.TagResourceInput) *kms.TagResourceOutput); ok { + r0 = rf(_a0) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*kms.TagResourceOutput) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(*kms.TagResourceInput) error); ok { + r1 = rf(_a0) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// TagResourceRequest provides a mock function with given fields: _a0 +func (_m *KMSAPI) TagResourceRequest(_a0 *kms.TagResourceInput) (*request.Request, *kms.TagResourceOutput) { + ret := _m.Called(_a0) + + var r0 *request.Request + if rf, ok := ret.Get(0).(func(*kms.TagResourceInput) *request.Request); ok { + r0 = rf(_a0) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*request.Request) + } + } + + var r1 *kms.TagResourceOutput + if rf, ok := ret.Get(1).(func(*kms.TagResourceInput) *kms.TagResourceOutput); ok { + r1 = rf(_a0) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*kms.TagResourceOutput) + } + } + + return r0, r1 +} + +// UntagResource provides a mock function with given fields: _a0 +func (_m *KMSAPI) UntagResource(_a0 *kms.UntagResourceInput) (*kms.UntagResourceOutput, error) { + ret := _m.Called(_a0) + + var r0 *kms.UntagResourceOutput + if rf, ok := ret.Get(0).(func(*kms.UntagResourceInput) *kms.UntagResourceOutput); ok { + r0 = rf(_a0) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*kms.UntagResourceOutput) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(*kms.UntagResourceInput) error); ok { + r1 = rf(_a0) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// UntagResourceRequest provides a mock function with given fields: _a0 +func (_m *KMSAPI) UntagResourceRequest(_a0 *kms.UntagResourceInput) (*request.Request, *kms.UntagResourceOutput) { + ret := _m.Called(_a0) + + var r0 *request.Request + if rf, ok := ret.Get(0).(func(*kms.UntagResourceInput) *request.Request); ok { + r0 = rf(_a0) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*request.Request) + } + } + + var r1 *kms.UntagResourceOutput + if rf, ok := ret.Get(1).(func(*kms.UntagResourceInput) *kms.UntagResourceOutput); ok { + r1 = rf(_a0) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*kms.UntagResourceOutput) + } + } + + return r0, r1 +} + // UpdateAlias provides a mock function with given fields: _a0 func (_m *KMSAPI) UpdateAlias(_a0 *kms.UpdateAliasInput) (*kms.UpdateAliasOutput, error) { ret := _m.Called(_a0)