Skip to content

Commit

Permalink
Use t.Cleanup() based on PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jvoravong committed Nov 1, 2024
1 parent 7c8e2fc commit 606176b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions receiver/k8sclusterreceiver/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ func TestE2E(t *testing.T) {
testObjs, err := k8stest.CreateObjects(k8sClient, testObjectsDir)
require.NoErrorf(t, err, "failed to create objects")

defer func() {
t.Cleanup(func() {
require.NoErrorf(t, k8stest.DeleteObjects(k8sClient, testObjs), "failed to delete objects")
}()
})

metricsConsumer := new(consumertest.MetricsSink)
shutdownSink := startUpSink(t, metricsConsumer)
Expand All @@ -60,11 +60,11 @@ func TestE2E(t *testing.T) {
testID := uuid.NewString()[:8]
collectorObjs := k8stest.CreateCollectorObjects(t, k8sClient, testID, "")

defer func() {
t.Cleanup(func() {
for _, obj := range append(collectorObjs) {
require.NoErrorf(t, k8stest.DeleteObject(k8sClient, obj), "failed to delete object %s", obj.GetName())
}
}()
})

wantEntries := 10 // Minimal number of metrics to wait for.
waitForData(t, wantEntries, metricsConsumer)
Expand Down

0 comments on commit 606176b

Please sign in to comment.