From 00f28747b3618ab1f1e33f3c21ac2ba926ec3120 Mon Sep 17 00:00:00 2001 From: Gaurav Singh Date: Sun, 7 Jun 2020 09:52:16 -0400 Subject: [PATCH] TestSchedulingQueue_Close: Remove struct tests and the corresponding for loop Signed-off-by: Gaurav Singh TestSchedulingQueue_Close: Remove for loop Signed-off-by: Gaurav Singh remove the tests slice Signed-off-by: Gaurav Singh Remove struct Signed-off-by: Gaurav Singh Remove t.Run() Signed-off-by: Gaurav Singh Add function name Signed-off-by: Gaurav Singh Remove nested function Signed-off-by: Gaurav Singh Replace expectedErr with wantErr Signed-off-by: Gaurav Singh --- .../internal/queue/scheduling_queue_test.go | 45 +++++++------------ 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/pkg/scheduler/internal/queue/scheduling_queue_test.go b/pkg/scheduler/internal/queue/scheduling_queue_test.go index 55149dc596e..50304307365 100644 --- a/pkg/scheduler/internal/queue/scheduling_queue_test.go +++ b/pkg/scheduler/internal/queue/scheduling_queue_test.go @@ -710,35 +710,22 @@ func TestUnschedulablePodsMap(t *testing.T) { } func TestSchedulingQueue_Close(t *testing.T) { - tests := []struct { - name string - q SchedulingQueue - expectedErr error - }{ - { - name: "PriorityQueue close", - q: NewPriorityQueue(newDefaultQueueSort()), - expectedErr: fmt.Errorf(queueClosed), - }, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - wg := sync.WaitGroup{} - wg.Add(1) - go func() { - defer wg.Done() - pod, err := test.q.Pop() - if err.Error() != test.expectedErr.Error() { - t.Errorf("Expected err %q from Pop() if queue is closed, but got %q", test.expectedErr.Error(), err.Error()) - } - if pod != nil { - t.Errorf("Expected pod nil from Pop() if queue is closed, but got: %v", pod) - } - }() - test.q.Close() - wg.Wait() - }) - } + q := NewPriorityQueue(newDefaultQueueSort()) + wantErr := fmt.Errorf(queueClosed) + wg := sync.WaitGroup{} + wg.Add(1) + go func() { + defer wg.Done() + pod, err := q.Pop() + if err.Error() != wantErr.Error() { + t.Errorf("Expected err %q from Pop() if queue is closed, but got %q", wantErr.Error(), err.Error()) + } + if pod != nil { + t.Errorf("Expected pod nil from Pop() if queue is closed, but got: %v", pod) + } + }() + q.Close() + wg.Wait() } // TestRecentlyTriedPodsGoBack tests that pods which are recently tried and are