@@ -590,6 +590,8 @@ func TestIsReplicaSetReferenced(t *testing.T) {
590590}
591591
592592func TestIsReplicaSetReferencedByIstioDestinationRule (t * testing.T ) {
593+ const testDestRuleName = "test-destrule"
594+
593595 newRSWithPodTemplateHash := func (hash string ) * appsv1.ReplicaSet {
594596 return & appsv1.ReplicaSet {
595597 ObjectMeta : metav1.ObjectMeta {
@@ -686,47 +688,47 @@ spec:
686688 },
687689 {
688690 name : "destination rule references hash - should return true" ,
689- rollout : newRolloutWithIstioDestinationRule ("test-destrule" ),
690- destinationRule : newDestinationRuleYAML ("test-destrule" , "abc123" , "def456" ),
691+ rollout : newRolloutWithIstioDestinationRule (testDestRuleName ),
692+ destinationRule : newDestinationRuleYAML (testDestRuleName , "abc123" , "def456" ),
691693 rsHash : "abc123" ,
692694 expectedResult : true ,
693695 },
694696 {
695697 name : "destination rule does not reference hash - should return false" ,
696- rollout : newRolloutWithIstioDestinationRule ("test-destrule" ),
697- destinationRule : newDestinationRuleYAML ("test-destrule" , "abc123" , "def456" ),
698+ rollout : newRolloutWithIstioDestinationRule (testDestRuleName ),
699+ destinationRule : newDestinationRuleYAML (testDestRuleName , "abc123" , "def456" ),
698700 rsHash : "xyz789" ,
699701 expectedResult : false ,
700702 },
701703 {
702704 name : "destination rule not found - should return false" ,
703705 rollout : newRolloutWithIstioDestinationRule ("non-existent-destrule" ),
704- destinationRule : newDestinationRuleYAML ("test-destrule" , "abc123" , "def456" ),
706+ destinationRule : newDestinationRuleYAML (testDestRuleName , "abc123" , "def456" ),
705707 rsHash : "abc123" ,
706708 expectedResult : false ,
707709 },
708710 {
709711 name : "no istio controller - should return false" ,
710- rollout : newRolloutWithIstioDestinationRule ("test-destrule" ),
712+ rollout : newRolloutWithIstioDestinationRule (testDestRuleName ),
711713 noIstioController : true ,
712714 rsHash : "abc123" ,
713715 expectedResult : false ,
714716 },
715717 {
716718 name : "canary subset references hash - should return true" ,
717- rollout : newRolloutWithIstioDestinationRule ("test-destrule" ),
718- destinationRule : newDestinationRuleYAML ("test-destrule" , "stable-hash" , "canary-hash" ),
719+ rollout : newRolloutWithIstioDestinationRule (testDestRuleName ),
720+ destinationRule : newDestinationRuleYAML (testDestRuleName , "stable-hash" , "canary-hash" ),
719721 rsHash : "canary-hash" ,
720722 expectedResult : true ,
721723 },
722724 {
723725 name : "destination rule with no subsets - should return false" ,
724- rollout : newRolloutWithIstioDestinationRule ("test-destrule" ),
726+ rollout : newRolloutWithIstioDestinationRule (testDestRuleName ),
725727 destinationRule : `
726728apiVersion: networking.istio.io/v1alpha3
727729kind: DestinationRule
728730metadata:
729- name: test-destrule
731+ name: ` + testDestRuleName + `
730732 namespace: default
731733spec:
732734 host: test-service
@@ -736,12 +738,12 @@ spec:
736738 },
737739 {
738740 name : "destination rule with subset missing labels - should return false" ,
739- rollout : newRolloutWithIstioDestinationRule ("test-destrule" ),
741+ rollout : newRolloutWithIstioDestinationRule (testDestRuleName ),
740742 destinationRule : `
741743apiVersion: networking.istio.io/v1alpha3
742744kind: DestinationRule
743745metadata:
744- name: test-destrule
746+ name: ` + testDestRuleName + `
745747 namespace: default
746748spec:
747749 host: test-service
0 commit comments