From 8f7fae585ce682c6d1a6736d2a2a6176e72871c3 Mon Sep 17 00:00:00 2001 From: max furman Date: Mon, 7 Nov 2022 13:09:07 -0800 Subject: [PATCH] Add mockgen commands for cloudcas_test --- cas/cloudcas/cloudcas_test.go | 3 ++ cas/cloudcas/mock_client_test.go | 35 +++++++++++----------- cas/cloudcas/mock_operation_server_test.go | 23 +++++++------- 3 files changed, 31 insertions(+), 30 deletions(-) diff --git a/cas/cloudcas/cloudcas_test.go b/cas/cloudcas/cloudcas_test.go index f52bfe0c..d4e92a32 100644 --- a/cas/cloudcas/cloudcas_test.go +++ b/cas/cloudcas/cloudcas_test.go @@ -1,3 +1,6 @@ +//go:generate mockgen -package cloudcas -mock_names=CertificateAuthorityClient=MockCertificateAuthorityClient -destination mock_client_test.go github.com/smallstep/certificates/cas/cloudcas CertificateAuthorityClient +//go:generate mockgen -package cloudcas -mock_names=OperationsServer=MockOperationsServer -destination mock_operation_server_test.go cloud.google.com/go/longrunning/autogen/longrunningpb OperationsServer + package cloudcas import ( diff --git a/cas/cloudcas/mock_client_test.go b/cas/cloudcas/mock_client_test.go index 90d1a2f9..4ade89a5 100644 --- a/cas/cloudcas/mock_client_test.go +++ b/cas/cloudcas/mock_client_test.go @@ -5,13 +5,12 @@ package cloudcas import ( - context "context" - reflect "reflect" - privateca "cloud.google.com/go/security/privateca/apiv1" + privatecapb "cloud.google.com/go/security/privateca/apiv1/privatecapb" + context "context" gomock "github.com/golang/mock/gomock" gax "github.com/googleapis/gax-go/v2" - privateca0 "google.golang.org/genproto/googleapis/cloud/security/privateca/v1" + reflect "reflect" ) // MockCertificateAuthorityClient is a mock of CertificateAuthorityClient interface @@ -38,7 +37,7 @@ func (m *MockCertificateAuthorityClient) EXPECT() *MockCertificateAuthorityClien } // ActivateCertificateAuthority mocks base method -func (m *MockCertificateAuthorityClient) ActivateCertificateAuthority(arg0 context.Context, arg1 *privateca0.ActivateCertificateAuthorityRequest, arg2 ...gax.CallOption) (*privateca.ActivateCertificateAuthorityOperation, error) { +func (m *MockCertificateAuthorityClient) ActivateCertificateAuthority(arg0 context.Context, arg1 *privatecapb.ActivateCertificateAuthorityRequest, arg2 ...gax.CallOption) (*privateca.ActivateCertificateAuthorityOperation, error) { m.ctrl.T.Helper() varargs := []interface{}{arg0, arg1} for _, a := range arg2 { @@ -58,7 +57,7 @@ func (mr *MockCertificateAuthorityClientMockRecorder) ActivateCertificateAuthori } // CreateCaPool mocks base method -func (m *MockCertificateAuthorityClient) CreateCaPool(arg0 context.Context, arg1 *privateca0.CreateCaPoolRequest, arg2 ...gax.CallOption) (*privateca.CreateCaPoolOperation, error) { +func (m *MockCertificateAuthorityClient) CreateCaPool(arg0 context.Context, arg1 *privatecapb.CreateCaPoolRequest, arg2 ...gax.CallOption) (*privateca.CreateCaPoolOperation, error) { m.ctrl.T.Helper() varargs := []interface{}{arg0, arg1} for _, a := range arg2 { @@ -78,14 +77,14 @@ func (mr *MockCertificateAuthorityClientMockRecorder) CreateCaPool(arg0, arg1 in } // CreateCertificate mocks base method -func (m *MockCertificateAuthorityClient) CreateCertificate(arg0 context.Context, arg1 *privateca0.CreateCertificateRequest, arg2 ...gax.CallOption) (*privateca0.Certificate, error) { +func (m *MockCertificateAuthorityClient) CreateCertificate(arg0 context.Context, arg1 *privatecapb.CreateCertificateRequest, arg2 ...gax.CallOption) (*privatecapb.Certificate, error) { m.ctrl.T.Helper() varargs := []interface{}{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } ret := m.ctrl.Call(m, "CreateCertificate", varargs...) - ret0, _ := ret[0].(*privateca0.Certificate) + ret0, _ := ret[0].(*privatecapb.Certificate) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -98,7 +97,7 @@ func (mr *MockCertificateAuthorityClientMockRecorder) CreateCertificate(arg0, ar } // CreateCertificateAuthority mocks base method -func (m *MockCertificateAuthorityClient) CreateCertificateAuthority(arg0 context.Context, arg1 *privateca0.CreateCertificateAuthorityRequest, arg2 ...gax.CallOption) (*privateca.CreateCertificateAuthorityOperation, error) { +func (m *MockCertificateAuthorityClient) CreateCertificateAuthority(arg0 context.Context, arg1 *privatecapb.CreateCertificateAuthorityRequest, arg2 ...gax.CallOption) (*privateca.CreateCertificateAuthorityOperation, error) { m.ctrl.T.Helper() varargs := []interface{}{arg0, arg1} for _, a := range arg2 { @@ -118,7 +117,7 @@ func (mr *MockCertificateAuthorityClientMockRecorder) CreateCertificateAuthority } // EnableCertificateAuthority mocks base method -func (m *MockCertificateAuthorityClient) EnableCertificateAuthority(arg0 context.Context, arg1 *privateca0.EnableCertificateAuthorityRequest, arg2 ...gax.CallOption) (*privateca.EnableCertificateAuthorityOperation, error) { +func (m *MockCertificateAuthorityClient) EnableCertificateAuthority(arg0 context.Context, arg1 *privatecapb.EnableCertificateAuthorityRequest, arg2 ...gax.CallOption) (*privateca.EnableCertificateAuthorityOperation, error) { m.ctrl.T.Helper() varargs := []interface{}{arg0, arg1} for _, a := range arg2 { @@ -138,14 +137,14 @@ func (mr *MockCertificateAuthorityClientMockRecorder) EnableCertificateAuthority } // FetchCertificateAuthorityCsr mocks base method -func (m *MockCertificateAuthorityClient) FetchCertificateAuthorityCsr(arg0 context.Context, arg1 *privateca0.FetchCertificateAuthorityCsrRequest, arg2 ...gax.CallOption) (*privateca0.FetchCertificateAuthorityCsrResponse, error) { +func (m *MockCertificateAuthorityClient) FetchCertificateAuthorityCsr(arg0 context.Context, arg1 *privatecapb.FetchCertificateAuthorityCsrRequest, arg2 ...gax.CallOption) (*privatecapb.FetchCertificateAuthorityCsrResponse, error) { m.ctrl.T.Helper() varargs := []interface{}{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } ret := m.ctrl.Call(m, "FetchCertificateAuthorityCsr", varargs...) - ret0, _ := ret[0].(*privateca0.FetchCertificateAuthorityCsrResponse) + ret0, _ := ret[0].(*privatecapb.FetchCertificateAuthorityCsrResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -158,14 +157,14 @@ func (mr *MockCertificateAuthorityClientMockRecorder) FetchCertificateAuthorityC } // GetCaPool mocks base method -func (m *MockCertificateAuthorityClient) GetCaPool(arg0 context.Context, arg1 *privateca0.GetCaPoolRequest, arg2 ...gax.CallOption) (*privateca0.CaPool, error) { +func (m *MockCertificateAuthorityClient) GetCaPool(arg0 context.Context, arg1 *privatecapb.GetCaPoolRequest, arg2 ...gax.CallOption) (*privatecapb.CaPool, error) { m.ctrl.T.Helper() varargs := []interface{}{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } ret := m.ctrl.Call(m, "GetCaPool", varargs...) - ret0, _ := ret[0].(*privateca0.CaPool) + ret0, _ := ret[0].(*privatecapb.CaPool) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -178,14 +177,14 @@ func (mr *MockCertificateAuthorityClientMockRecorder) GetCaPool(arg0, arg1 inter } // GetCertificateAuthority mocks base method -func (m *MockCertificateAuthorityClient) GetCertificateAuthority(arg0 context.Context, arg1 *privateca0.GetCertificateAuthorityRequest, arg2 ...gax.CallOption) (*privateca0.CertificateAuthority, error) { +func (m *MockCertificateAuthorityClient) GetCertificateAuthority(arg0 context.Context, arg1 *privatecapb.GetCertificateAuthorityRequest, arg2 ...gax.CallOption) (*privatecapb.CertificateAuthority, error) { m.ctrl.T.Helper() varargs := []interface{}{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } ret := m.ctrl.Call(m, "GetCertificateAuthority", varargs...) - ret0, _ := ret[0].(*privateca0.CertificateAuthority) + ret0, _ := ret[0].(*privatecapb.CertificateAuthority) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -198,14 +197,14 @@ func (mr *MockCertificateAuthorityClientMockRecorder) GetCertificateAuthority(ar } // RevokeCertificate mocks base method -func (m *MockCertificateAuthorityClient) RevokeCertificate(arg0 context.Context, arg1 *privateca0.RevokeCertificateRequest, arg2 ...gax.CallOption) (*privateca0.Certificate, error) { +func (m *MockCertificateAuthorityClient) RevokeCertificate(arg0 context.Context, arg1 *privatecapb.RevokeCertificateRequest, arg2 ...gax.CallOption) (*privatecapb.Certificate, error) { m.ctrl.T.Helper() varargs := []interface{}{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } ret := m.ctrl.Call(m, "RevokeCertificate", varargs...) - ret0, _ := ret[0].(*privateca0.Certificate) + ret0, _ := ret[0].(*privatecapb.Certificate) ret1, _ := ret[1].(error) return ret0, ret1 } diff --git a/cas/cloudcas/mock_operation_server_test.go b/cas/cloudcas/mock_operation_server_test.go index 43dfa713..da0d39ab 100644 --- a/cas/cloudcas/mock_operation_server_test.go +++ b/cas/cloudcas/mock_operation_server_test.go @@ -1,16 +1,15 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: google.golang.org/genproto/googleapis/longrunning (interfaces: OperationsServer) +// Source: cloud.google.com/go/longrunning/autogen/longrunningpb (interfaces: OperationsServer) // Package cloudcas is a generated GoMock package. package cloudcas import ( + longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb" context "context" - reflect "reflect" - gomock "github.com/golang/mock/gomock" - longrunning "google.golang.org/genproto/googleapis/longrunning" emptypb "google.golang.org/protobuf/types/known/emptypb" + reflect "reflect" ) // MockOperationsServer is a mock of OperationsServer interface @@ -37,7 +36,7 @@ func (m *MockOperationsServer) EXPECT() *MockOperationsServerMockRecorder { } // CancelOperation mocks base method -func (m *MockOperationsServer) CancelOperation(arg0 context.Context, arg1 *longrunning.CancelOperationRequest) (*emptypb.Empty, error) { +func (m *MockOperationsServer) CancelOperation(arg0 context.Context, arg1 *longrunningpb.CancelOperationRequest) (*emptypb.Empty, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CancelOperation", arg0, arg1) ret0, _ := ret[0].(*emptypb.Empty) @@ -52,7 +51,7 @@ func (mr *MockOperationsServerMockRecorder) CancelOperation(arg0, arg1 interface } // DeleteOperation mocks base method -func (m *MockOperationsServer) DeleteOperation(arg0 context.Context, arg1 *longrunning.DeleteOperationRequest) (*emptypb.Empty, error) { +func (m *MockOperationsServer) DeleteOperation(arg0 context.Context, arg1 *longrunningpb.DeleteOperationRequest) (*emptypb.Empty, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteOperation", arg0, arg1) ret0, _ := ret[0].(*emptypb.Empty) @@ -67,10 +66,10 @@ func (mr *MockOperationsServerMockRecorder) DeleteOperation(arg0, arg1 interface } // GetOperation mocks base method -func (m *MockOperationsServer) GetOperation(arg0 context.Context, arg1 *longrunning.GetOperationRequest) (*longrunning.Operation, error) { +func (m *MockOperationsServer) GetOperation(arg0 context.Context, arg1 *longrunningpb.GetOperationRequest) (*longrunningpb.Operation, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetOperation", arg0, arg1) - ret0, _ := ret[0].(*longrunning.Operation) + ret0, _ := ret[0].(*longrunningpb.Operation) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -82,10 +81,10 @@ func (mr *MockOperationsServerMockRecorder) GetOperation(arg0, arg1 interface{}) } // ListOperations mocks base method -func (m *MockOperationsServer) ListOperations(arg0 context.Context, arg1 *longrunning.ListOperationsRequest) (*longrunning.ListOperationsResponse, error) { +func (m *MockOperationsServer) ListOperations(arg0 context.Context, arg1 *longrunningpb.ListOperationsRequest) (*longrunningpb.ListOperationsResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ListOperations", arg0, arg1) - ret0, _ := ret[0].(*longrunning.ListOperationsResponse) + ret0, _ := ret[0].(*longrunningpb.ListOperationsResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -97,10 +96,10 @@ func (mr *MockOperationsServerMockRecorder) ListOperations(arg0, arg1 interface{ } // WaitOperation mocks base method -func (m *MockOperationsServer) WaitOperation(arg0 context.Context, arg1 *longrunning.WaitOperationRequest) (*longrunning.Operation, error) { +func (m *MockOperationsServer) WaitOperation(arg0 context.Context, arg1 *longrunningpb.WaitOperationRequest) (*longrunningpb.Operation, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "WaitOperation", arg0, arg1) - ret0, _ := ret[0].(*longrunning.Operation) + ret0, _ := ret[0].(*longrunningpb.Operation) ret1, _ := ret[1].(error) return ret0, ret1 }