Skip to content

Commit 0af61e9

Browse files
committed
fix ut
Signed-off-by: lec-bit <[email protected]>
1 parent 1cddf8c commit 0af61e9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pkg/controller/ads/ads_controller_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ import (
2525
"github.com/agiledragon/gomonkey/v2"
2626
config_cluster_v3 "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3"
2727
discoveryv3 "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3"
28+
service_discovery_v3 "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3"
2829
resource_v3 "github.com/envoyproxy/go-control-plane/pkg/resource/v3"
2930
"google.golang.org/grpc"
3031
"google.golang.org/protobuf/types/known/anypb"
32+
"istio.io/istio/pkg/channels"
3133

3234
"kmesh.net/kmesh/pkg/controller/xdstest"
3335
)
@@ -43,7 +45,7 @@ func TestAdsStreamAdsStreamCreateAndSend(t *testing.T) {
4345
defer client.Cleanup()
4446

4547
adsStream := Controller{
46-
con: &connection{Stream: client.AdsClient},
48+
con: &connection{Stream: client.AdsClient, stopCh: make(chan struct{})},
4749
Processor: nil,
4850
}
4951

@@ -116,7 +118,7 @@ func TestHandleAdsStream(t *testing.T) {
116118
defer fakeClient.Cleanup()
117119

118120
adsStream := NewController()
119-
adsStream.con = &connection{Stream: fakeClient.AdsClient}
121+
adsStream.con = &connection{Stream: fakeClient.AdsClient, requestsChan: channels.NewUnbounded[*service_discovery_v3.DiscoveryRequest](), stopCh: make(chan struct{})}
120122

121123
patches1 := gomonkey.NewPatches()
122124
patches2 := gomonkey.NewPatches()
@@ -140,7 +142,7 @@ func TestHandleAdsStream(t *testing.T) {
140142
wantErr: true,
141143
},
142144
{
143-
name: "test3: handle success, should return nil",
145+
name: "test2: handle success, should return nil",
144146
beforeFunc: func() {
145147
patches1.ApplyMethod(reflect.TypeOf(adsStream.con.Stream), "Recv",
146148
func(_ discoveryv3.AggregatedDiscoveryService_StreamAggregatedResourcesClient) (*discoveryv3.DiscoveryResponse, error) {

0 commit comments

Comments
 (0)