@@ -274,7 +274,6 @@ func TestProcessBlacklisting(t *testing.T) {
274274}
275275
276276func TestProcessInclusions (t * testing.T ) {
277- type Tags = map [string ]struct {}
278277 for _ , tc := range []struct {
279278 name string
280279 processes []* ProcessCommon
@@ -284,10 +283,7 @@ func TestProcessInclusions(t *testing.T) {
284283 amountTopIOWriteUsage int
285284 amountTopMemoryUsage int
286285 memoryUsageThreshold int
287- expectedPidsTags []struct {
288- Pid int
289- Tags Tags
290- }
286+ expectedPids []int
291287 totalCPUpercentage float32
292288 totalMemory uint64
293289 }{
@@ -349,15 +345,7 @@ func TestProcessInclusions(t *testing.T) {
349345 amountTopIOWriteUsage : 1 ,
350346 amountTopMemoryUsage : 1 ,
351347 memoryUsageThreshold : 35 ,
352- expectedPidsTags : []struct {
353- Pid int
354- Tags Tags
355- }{
356- {2 , map [string ]struct {}{TopMemory : {}}},
357- {4 , map [string ]struct {}{TopCPU : {}}},
358- {6 , map [string ]struct {}{TopIORead : {}}},
359- {8 , map [string ]struct {}{TopIOWrite : {}}},
360- },
348+ expectedPids : []int {2 , 4 , 6 , 8 },
361349 totalCPUpercentage : 25 ,
362350 totalMemory : 40 ,
363351 },
@@ -419,10 +407,7 @@ func TestProcessInclusions(t *testing.T) {
419407 amountTopIOWriteUsage : 1 ,
420408 amountTopMemoryUsage : 1 ,
421409 memoryUsageThreshold : 35 ,
422- expectedPidsTags : []struct {
423- Pid int
424- Tags Tags
425- }{{1 , map [string ]struct {}{TopMemory : {}, TopCPU : {}, TopIORead : {}, TopIOWrite : {}}}},
410+ expectedPids : []int {1 },
426411 totalCPUpercentage : 25 ,
427412 totalMemory : 40 ,
428413 },
@@ -484,13 +469,7 @@ func TestProcessInclusions(t *testing.T) {
484469 amountTopIOWriteUsage : 1 ,
485470 amountTopMemoryUsage : 1 ,
486471 memoryUsageThreshold : 35 ,
487- expectedPidsTags : []struct {
488- Pid int
489- Tags Tags
490- }{
491- {6 , map [string ]struct {}{TopIORead : {}}},
492- {8 , map [string ]struct {}{TopIOWrite : {}}},
493- },
472+ expectedPids : []int {6 , 8 },
494473 totalCPUpercentage : 10 ,
495474 totalMemory : 10 ,
496475 },
@@ -509,12 +488,8 @@ func TestProcessInclusions(t *testing.T) {
509488 assert .True (t , len (processInclusions ) <= maxTopProcesses , fmt .Sprintf ("Way too many top processes reported: %d > %d" , len (processInclusions ), maxTopProcesses ))
510489
511490 for _ , proc := range processInclusions {
512- sort .Strings (proc .Tags )
513- pidTags := struct {
514- Pid int
515- Tags Tags
516- }{int (proc .Pid ), deriveSet (proc .Tags )}
517- assert .Contains (t , tc .expectedPidsTags , pidTags , fmt .Sprintf ("Expected pids/tags: %v, found pid/tag: %v" , tc .expectedPidsTags , pidTags ))
491+ pids := int (proc .Pid )
492+ assert .Contains (t , tc .expectedPids , pids , fmt .Sprintf ("Expected pids/tags: %v, found pid/tag: %v" , tc .expectedPids , pids ))
518493 }
519494 })
520495 }
0 commit comments