File tree 2 files changed +16
-3
lines changed
internal/mode/static/state/graph
2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -135,7 +135,7 @@ func (g *Graph) IsNGFPolicyRelevant(
135
135
}
136
136
137
137
if policy == nil {
138
- return false
138
+ panic ( "policy cannot be nil" )
139
139
}
140
140
141
141
ref := policy .GetTargetRef ()
Original file line number Diff line number Diff line change @@ -1022,9 +1022,9 @@ func TestIsNGFPolicyRelevant(t *testing.T) {
1022
1022
expRelevant : true ,
1023
1023
},
1024
1024
{
1025
- name : "irrelevant; policy does not exist in graph and is nil (delete event)" ,
1025
+ name : "irrelevant; policy does not exist in graph and is empty (delete event)" ,
1026
1026
graph : getGraph (),
1027
- policy : nil ,
1027
+ policy : & policiesfakes. FakePolicy {} ,
1028
1028
nsname : types.NamespacedName {Namespace : "diff" , Name : "diff" },
1029
1029
expRelevant : false ,
1030
1030
},
@@ -1108,3 +1108,16 @@ func TestIsNGFPolicyRelevant(t *testing.T) {
1108
1108
})
1109
1109
}
1110
1110
}
1111
+
1112
+ func TestIsNGFPolicyRelevantPanics (t * testing.T ) {
1113
+ g := NewWithT (t )
1114
+ graph := & Graph {}
1115
+ nsname := types.NamespacedName {Namespace : "test" , Name : "pol" }
1116
+ gvk := schema.GroupVersionKind {Kind : "MyKind" }
1117
+
1118
+ isRelevant := func () {
1119
+ _ = graph .IsNGFPolicyRelevant (nil , gvk , nsname )
1120
+ }
1121
+
1122
+ g .Expect (isRelevant ).To (Panic ())
1123
+ }
You can’t perform that action at this time.
0 commit comments