@@ -11,7 +11,7 @@ import (
1111
1212 "open-cluster-management.io/sdk-go/pkg/cloudevents/generic/options/grpc"
1313 "open-cluster-management.io/sdk-go/pkg/cloudevents/generic/options/mqtt"
14- "open-cluster-management.io/sdk-go/pkg/cloudevents/generic/options/pubsub"
14+ "open-cluster-management.io/sdk-go/pkg/cloudevents/generic/options/v2/ pubsub"
1515 "open-cluster-management.io/sdk-go/pkg/cloudevents/generic/types"
1616 clienttesting "open-cluster-management.io/sdk-go/pkg/testing"
1717)
@@ -108,7 +108,13 @@ func TestBuildCloudEventsSourceOptions(t *testing.T) {
108108 AgentEvents : "projects/test-project/subscriptions/agentevents-source1" ,
109109 AgentBroadcast : "projects/test-project/subscriptions/agentbroadcast-source1" ,
110110 },
111+ KeepaliveSettings : & pubsub.KeepaliveSettings {
112+ Time : 5 * time .Minute ,
113+ Timeout : 20 * time .Second ,
114+ PermitWithoutStream : false ,
115+ },
111116 },
117+ expectedTransportType : "*pubsub.pubsubTransport" ,
112118 },
113119 }
114120
@@ -138,6 +144,7 @@ func TestBuildCloudEventsAgentOptions(t *testing.T) {
138144 Timeout : 60 * time .Second ,
139145 },
140146 },
147+ expectedTransportType : "*mqtt.mqttAgentTransport" ,
141148 },
142149 {
143150 name : "grpc config" ,
@@ -154,6 +161,7 @@ func TestBuildCloudEventsAgentOptions(t *testing.T) {
154161 },
155162 },
156163 },
164+ expectedTransportType : "*grpc.grpcTransport" ,
157165 },
158166 {
159167 name : "pubsub config" ,
@@ -169,7 +177,13 @@ func TestBuildCloudEventsAgentOptions(t *testing.T) {
169177 SourceEvents : "projects/test-project/subscriptions/sourceevents-cluster1" ,
170178 SourceBroadcast : "projects/test-project/subscriptions/sourcebroadcast-cluster1" ,
171179 },
180+ KeepaliveSettings : & pubsub.KeepaliveSettings {
181+ Time : 5 * time .Minute ,
182+ Timeout : 20 * time .Second ,
183+ PermitWithoutStream : false ,
184+ },
172185 },
186+ expectedTransportType : "*pubsub.pubsubTransport" ,
173187 },
174188 }
175189
@@ -200,16 +214,15 @@ func assertSourceOptions(t *testing.T, c buildingCloudEventsOptionTestCase) {
200214 t .Errorf ("unexpected config %v, %v" , config , c .expectedOptions )
201215 }
202216
203- options , err := BuildCloudEventsSourceOptions (config , "agent1 " , sourceId , types.CloudEventsDataType {})
217+ options , err := BuildCloudEventsSourceOptions (config , "client " , sourceId , types.CloudEventsDataType {})
204218 if err != nil {
205219 t .Errorf ("unexpected error %v" , err )
206220 }
207221
208- optionsRaw , _ := json .Marshal (options )
209- expectedRaw , _ := json .Marshal (c .expectedOptions )
222+ tt := reflect .TypeOf (options .CloudEventsTransport )
210223
211- if ! strings . Contains ( string ( optionsRaw ), string ( expectedRaw )) {
212- t .Errorf ("the results %v \n does not contain the original options %v \n " , string ( optionsRaw ), string ( expectedRaw ) )
224+ if tt . String () != c . expectedTransportType {
225+ t .Errorf ("expected %s, but got %s " , c . expectedTransportType , tt )
213226 }
214227}
215228
@@ -224,7 +237,7 @@ func assertAgentOptions(t *testing.T, c buildingCloudEventsOptionTestCase) {
224237 t .Errorf ("unexpected config %v, %v" , config , c .expectedOptions )
225238 }
226239
227- options , err := BuildCloudEventsAgentOptions (config , "cluster1" , "agent1 " , types.CloudEventsDataType {})
240+ options , err := BuildCloudEventsAgentOptions (config , "cluster1" , "client " , types.CloudEventsDataType {})
228241 if err != nil {
229242 t .Errorf ("unexpected error %v" , err )
230243 }
0 commit comments