@@ -162,3 +162,73 @@ func Test_GetStatusAndSubStatus_NewResourceAssociatedControls(t *testing.T) {
162162 assert .Equal (t , controlIdToExpectedSubStatus [control .ControlID ], string (control .GetSubStatus ()))
163163 }
164164}
165+
166+ func TestControlMissingAllConfigurations (t * testing.T ) {
167+ tests := []struct {
168+ name string
169+ control * ResourceAssociatedControl
170+ want bool
171+ }{
172+ {
173+ name : "TestControlNoConfigurations" ,
174+ control : & ResourceAssociatedControl {
175+ ResourceAssociatedRules : []ResourceAssociatedRule {
176+ {
177+ ControlConfigurations : map [string ][]string {},
178+ },
179+ },
180+ },
181+ want : true ,
182+ }, {
183+ name : "TestControlOneEmptyConfiguration" ,
184+ control : & ResourceAssociatedControl {
185+ ResourceAssociatedRules : []ResourceAssociatedRule {
186+ {
187+ ControlConfigurations : map [string ][]string {
188+ "EmptyConfiguration" : {},
189+ },
190+ },
191+ },
192+ },
193+ want : true ,
194+ },
195+ {
196+ name : "TestControlOneNonEmptyConfiguration" ,
197+ control : & ResourceAssociatedControl {
198+ ResourceAssociatedRules : []ResourceAssociatedRule {
199+ {
200+ ControlConfigurations : map [string ][]string {
201+ "NonEmptyConfiguration" : {
202+ "key" , "value" ,
203+ },
204+ },
205+ },
206+ },
207+ },
208+ want : false ,
209+ },
210+ {
211+ name : "TestControlMultipleConfigurations" ,
212+ control : & ResourceAssociatedControl {
213+ ResourceAssociatedRules : []ResourceAssociatedRule {
214+ {
215+ ControlConfigurations : map [string ][]string {
216+ "EmptyConfiguration" : {},
217+ "NonEmptyConfiguration" : {
218+ "key" , "value" ,
219+ },
220+ },
221+ },
222+ },
223+ },
224+ want : false ,
225+ },
226+ }
227+ for _ , tt := range tests {
228+ t .Run (tt .name , func (t * testing.T ) {
229+ if got := controlMissingAllConfigurations (tt .control ); got != tt .want {
230+ t .Errorf ("Control.missingAllConfigurations() = %v, want %v" , got , tt .want )
231+ }
232+ })
233+ }
234+ }
0 commit comments