dubbo.apache.org/dubbo-go/v3@v3.1.1/registry/etcdv3/listener_test.go (about)

     1  /*
     2   * Licensed to the Apache Software Foundation (ASF) under one or more
     3   * contributor license agreements.  See the NOTICE file distributed with
     4   * this work for additional information regarding copyright ownership.
     5   * The ASF licenses this file to You under the Apache License, Version 2.0
     6   * (the "License"); you may not use this file except in compliance with
     7   * the License.  You may obtain a copy of the License at
     8   *
     9   *     http://www.apache.org/licenses/LICENSE-2.0
    10   *
    11   * Unless required by applicable law or agreed to in writing, software
    12   * distributed under the License is distributed on an "AS IS" BASIS,
    13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14   * See the License for the specific language governing permissions and
    15   * limitations under the License.
    16   */
    17  
    18  package etcdv3
    19  
    20  import (
    21  	"dubbo.apache.org/dubbo-go/v3/common"
    22  	"dubbo.apache.org/dubbo-go/v3/config_center"
    23  )
    24  
    25  type MockDataListener struct{}
    26  
    27  func (*MockDataListener) Process(configType *config_center.ConfigChangeEvent) {}
    28  
    29  type dataListenerFields struct {
    30  	interestedURL []*common.URL
    31  	listener      config_center.ConfigurationListener
    32  }
    33  
    34  func newDataListener(listenerFields dataListenerFields) *dataListener {
    35  	return &dataListener{
    36  		interestedURL: listenerFields.interestedURL,
    37  		listener:      listenerFields.listener,
    38  	}
    39  }
    40  
    41  /*
    42  func Test_dataListener_DataChange(t *testing.T) {
    43  	tests := []struct {
    44  		name   string
    45  		fields dataListenerFields
    46  		args   args
    47  		want   bool
    48  	}{
    49  		{
    50  			name: "test",
    51  			fields: dataListenerFields{
    52  				interestedURL: nil,
    53  				listener:      &MockDataListener{},
    54  			},
    55  			args: args{
    56  				eventType: remoting.Event{
    57  					Path: "com.ikurento.user.UserProvider/providers/jsonrpc%3A%2F%2F127.0.0.1%3A20001%2Fcom.ikurento.user.UserProvider%3Fanyhost%3Dtrue%26app.version%3D0.0.1%26application%3DBDTService%26category%3Dproviders%26cluster%3Dfailover%26dubbo%3Ddubbo-provider-golang-2.6.0%26environment%3Ddev%26group%3D%26interface%3Dcom.ikurento.user.UserProvider%26ip%3D10.32.20.124%26loadbalance%3Drandom%26methods.GetUser.loadbalance%3Drandom%26methods.GetUser.retries%3D1%26methods.GetUser.weight%3D0%26module%3Ddubbogo%2Buser-info%2Bserver%26name%3DBDTService%26organization%3Dikurento.com%26owner%3DZX%26pid%3D74500%26retries%3D0%26service.filter%3Decho%26side%3Dprovider%26timestamp%3D1560155407%26version%3D%26warmup%3D100",
    58  				},
    59  			},
    60  			want: false,
    61  		},
    62  	}
    63  	for _, tt := range tests {
    64  		t.Run(tt.name, func(t *testing.T) {
    65  			l := newDataListener(tt.fields)
    66  			if got := l.DataChange(tt.args.eventType); got != tt.want {
    67  				t.Errorf("DataChange() = %v, want %v", got, tt.want)
    68  			}
    69  		})
    70  	}
    71  }
    72  
    73  */