@@ -40,6 +40,12 @@ func TestServiceRouter_Create(t *testing.T) {
4040 kubeClient : mocks .kubeClient ,
4141 flaggerClient : mocks .flaggerClient ,
4242 logger : mocks .logger ,
43+ matchLabels : map [string ]string {
44+ "name" : "podinfo" ,
45+ "test-label-1" : "test-label-value-1" ,
46+ },
47+ labelSelector : "name" ,
48+ labelValue : "podinfo" ,
4349 }
4450 appProtocol := "http"
4551
@@ -52,13 +58,20 @@ func TestServiceRouter_Create(t *testing.T) {
5258 canarySvc , err := mocks .kubeClient .CoreV1 ().Services ("default" ).Get (context .TODO (), "podinfo-canary" , metav1.GetOptions {})
5359 require .NoError (t , err )
5460
61+ assert .Equal (t , 2 , len (canarySvc .Spec .Selector ))
62+ assert .Equal (t , "podinfo" , canarySvc .Spec .Selector ["name" ])
63+ assert .Equal (t , "test-label-value-1" , canarySvc .Spec .Selector ["test-label-1" ])
5564 assert .Equal (t , & appProtocol , canarySvc .Spec .Ports [0 ].AppProtocol )
5665 assert .Equal (t , "http" , canarySvc .Spec .Ports [0 ].Name )
5766 assert .Equal (t , int32 (9898 ), canarySvc .Spec .Ports [0 ].Port )
5867 assert .Equal (t , "None" , canarySvc .Spec .ClusterIP )
5968
6069 primarySvc , err := mocks .kubeClient .CoreV1 ().Services ("default" ).Get (context .TODO (), "podinfo-primary" , metav1.GetOptions {})
6170 require .NoError (t , err )
71+
72+ assert .Equal (t , 2 , len (primarySvc .Spec .Selector ))
73+ assert .Equal (t , "podinfo-primary" , primarySvc .Spec .Selector ["name" ])
74+ assert .Equal (t , "test-label-value-1" , primarySvc .Spec .Selector ["test-label-1" ])
6275 assert .Equal (t , "http" , primarySvc .Spec .Ports [0 ].Name )
6376 assert .Equal (t , int32 (9898 ), primarySvc .Spec .Ports [0 ].Port )
6477 assert .Equal (t , "None" , primarySvc .Spec .ClusterIP )
0 commit comments