github.com/oam-dev/kubevela@v1.9.11/test/mock/nacos/config_client.go (about)

     1  /*
     2  Copyright 2022 The KubeVela Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8  	http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package nacos
    18  
    19  import (
    20  	"reflect"
    21  
    22  	"github.com/golang/mock/gomock"
    23  	"github.com/nacos-group/nacos-sdk-go/v2/model"
    24  	"github.com/nacos-group/nacos-sdk-go/v2/vo"
    25  )
    26  
    27  // MockIConfigClient is a mock of IConfigClient interface
    28  type MockIConfigClient struct {
    29  	ctrl     *gomock.Controller
    30  	recorder *MockIConfigClientMockRecorder
    31  }
    32  
    33  // MockIConfigClientMockRecorder is the mock recorder for MockIConfigClient
    34  type MockIConfigClientMockRecorder struct {
    35  	mock *MockIConfigClient
    36  }
    37  
    38  // NewMockIConfigClient creates a new mock instance
    39  func NewMockIConfigClient(ctrl *gomock.Controller) *MockIConfigClient {
    40  	mock := &MockIConfigClient{ctrl: ctrl}
    41  	mock.recorder = &MockIConfigClientMockRecorder{mock}
    42  	return mock
    43  }
    44  
    45  // EXPECT returns an object that allows the caller to indicate expected use
    46  func (m *MockIConfigClient) EXPECT() *MockIConfigClientMockRecorder {
    47  	return m.recorder
    48  }
    49  
    50  // GetConfig mock getting the config
    51  func (m *MockIConfigClient) GetConfig(param vo.ConfigParam) (string, error) {
    52  	m.ctrl.T.Helper()
    53  	ret := m.ctrl.Call(m, "GetConfig", param)
    54  	ret0, _ := ret[0].(string)
    55  	ret1, _ := ret[1].(error)
    56  	return ret0, ret1
    57  }
    58  
    59  // GetConfig indicates an expected call of GetConfig
    60  func (mr *MockIConfigClientMockRecorder) GetConfig(param interface{}) *gomock.Call {
    61  	mr.mock.ctrl.T.Helper()
    62  	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetConfig", reflect.TypeOf((*MockIConfigClient)(nil).GetConfig), param)
    63  }
    64  
    65  // PublishConfig use to publish config to nacos server
    66  // dataId  require
    67  // group   require
    68  // content require
    69  // tenant ==>nacos.namespace optional
    70  func (m *MockIConfigClient) PublishConfig(param vo.ConfigParam) (bool, error) {
    71  	m.ctrl.T.Helper()
    72  	ret := m.ctrl.Call(m, "PublishConfig", param)
    73  	ret0, _ := ret[0].(bool)
    74  	ret1, _ := ret[1].(error)
    75  	return ret0, ret1
    76  }
    77  
    78  // PublishConfig indicates an expected call of PublishConfig
    79  func (mr *MockIConfigClientMockRecorder) PublishConfig(param interface{}) *gomock.Call {
    80  	mr.mock.ctrl.T.Helper()
    81  	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PublishConfig", reflect.TypeOf((*MockIConfigClient)(nil).PublishConfig), param)
    82  }
    83  
    84  // DeleteConfig use to delete config
    85  // dataId  require
    86  // group   require
    87  // tenant ==>nacos.namespace optional
    88  func (m *MockIConfigClient) DeleteConfig(param vo.ConfigParam) (bool, error) {
    89  	m.ctrl.T.Helper()
    90  	ret := m.ctrl.Call(m, "DeleteConfig", param)
    91  	ret0, _ := ret[0].(bool)
    92  	ret1, _ := ret[1].(error)
    93  	return ret0, ret1
    94  }
    95  
    96  // DeleteConfig indicates an expected call of DeleteConfig
    97  func (mr *MockIConfigClientMockRecorder) DeleteConfig(param interface{}) *gomock.Call {
    98  	mr.mock.ctrl.T.Helper()
    99  	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteConfig", reflect.TypeOf((*MockIConfigClient)(nil).DeleteConfig), param)
   100  }
   101  
   102  // ListenConfig use to listen config change,it will callback OnChange() when config change
   103  // dataId  require
   104  // group   require
   105  // onchange require
   106  // tenant ==>nacos.namespace optional
   107  func (m *MockIConfigClient) ListenConfig(params vo.ConfigParam) (err error) {
   108  	m.ctrl.T.Helper()
   109  	ret := m.ctrl.Call(m, "ListenConfig", params)
   110  	ret0, _ := ret[0].(error)
   111  	return ret0
   112  }
   113  
   114  // ListenConfig indicates an expected call of ListenConfig
   115  func (mr *MockIConfigClientMockRecorder) ListenConfig(params interface{}) *gomock.Call {
   116  	mr.mock.ctrl.T.Helper()
   117  	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListenConfig", reflect.TypeOf((*MockIConfigClient)(nil).ListenConfig), params)
   118  }
   119  
   120  // CancelListenConfig use to cancel listen config change
   121  // dataId  require
   122  // group   require
   123  // tenant ==>nacos.namespace optional
   124  func (m *MockIConfigClient) CancelListenConfig(params vo.ConfigParam) (err error) {
   125  	m.ctrl.T.Helper()
   126  	ret := m.ctrl.Call(m, "CancelListenConfig", params)
   127  	ret0, _ := ret[0].(error)
   128  	return ret0
   129  }
   130  
   131  // CancelListenConfig indicates an expected call of CancelListenConfig
   132  func (mr *MockIConfigClientMockRecorder) CancelListenConfig(params interface{}) *gomock.Call {
   133  	mr.mock.ctrl.T.Helper()
   134  	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CancelListenConfig", reflect.TypeOf((*MockIConfigClient)(nil).CancelListenConfig), params)
   135  }
   136  
   137  // SearchConfig use to search nacos config
   138  // search  require search=accurate--精确搜索  search=blur--模糊搜索
   139  // group   option
   140  // dataId  option
   141  // tenant ==>nacos.namespace optional
   142  // pageNo  option,default is 1
   143  // pageSize option,default is 10
   144  func (m *MockIConfigClient) SearchConfig(param vo.SearchConfigParam) (*model.ConfigPage, error) {
   145  	m.ctrl.T.Helper()
   146  	ret := m.ctrl.Call(m, "SearchConfig", param)
   147  	ret0, _ := ret[0].(*model.ConfigPage)
   148  	ret1, _ := ret[0].(error)
   149  	return ret0, ret1
   150  }
   151  
   152  // SearchConfig indicates an expected call of SearchConfig
   153  func (mr *MockIConfigClientMockRecorder) SearchConfig(params interface{}) *gomock.Call {
   154  	mr.mock.ctrl.T.Helper()
   155  	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SearchConfig", reflect.TypeOf((*MockIConfigClient)(nil).SearchConfig), params)
   156  }
   157  
   158  // CloseClient Close the GRPC client
   159  func (m *MockIConfigClient) CloseClient() {
   160  	m.ctrl.T.Helper()
   161  	m.ctrl.Call(m, "SearchConfig")
   162  }
   163  
   164  // CloseClient indicates an expected call of CloseClient
   165  func (mr *MockIConfigClientMockRecorder) CloseClient(params interface{}) *gomock.Call {
   166  	mr.mock.ctrl.T.Helper()
   167  	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CloseClient", reflect.TypeOf((*MockIConfigClient)(nil).CloseClient), params)
   168  }