This is an automated email from the ASF dual-hosted git repository.
lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git
The following commit(s) were added to refs/heads/master by this push:
new 9d8da53 Defer cancel function call returned by WithDeadline in tests
9d8da53 is described below
commit 9d8da53fcaa3170bf0a8c9bc8a71ecc6e77be043
Author: Andrea Cosentino <[email protected]>
AuthorDate: Tue Sep 25 15:27:27 2018 +0200
Defer cancel function call returned by WithDeadline in tests
---
pkg/util/sync/file_test.go | 8 +++++---
test/log_scrape_integration_test.go | 15 +++++++++------
2 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/pkg/util/sync/file_test.go b/pkg/util/sync/file_test.go
index 266b55c..efd0bd8 100644
--- a/pkg/util/sync/file_test.go
+++ b/pkg/util/sync/file_test.go
@@ -19,7 +19,6 @@ package sync
import (
"context"
- "github.com/stretchr/testify/assert"
"io/ioutil"
"math/rand"
"os"
@@ -27,6 +26,8 @@ import (
"strconv"
"testing"
"time"
+
+ "github.com/stretchr/testify/assert"
)
func TestFile(t *testing.T) {
@@ -36,7 +37,8 @@ func TestFile(t *testing.T) {
assert.Nil(t, err)
defer os.Remove(fileName)
- ctx, _ := context.WithDeadline(context.Background(),
time.Now().Add(100*time.Second))
+ ctx, cancel := context.WithDeadline(context.Background(),
time.Now().Add(100*time.Second))
+ defer cancel()
changes, err := File(ctx, fileName)
assert.Nil(t, err)
@@ -55,7 +57,7 @@ watch:
return
case <-changes:
numChanges++
- if (numChanges == expectedNumChanges) {
+ if numChanges == expectedNumChanges {
break watch
}
}
diff --git a/test/log_scrape_integration_test.go
b/test/log_scrape_integration_test.go
index 2052cc5..e790e99 100644
--- a/test/log_scrape_integration_test.go
+++ b/test/log_scrape_integration_test.go
@@ -22,13 +22,14 @@ limitations under the License.
package test
import (
- "testing"
- "github.com/apache/camel-k/pkg/util/log"
"context"
- "time"
- "github.com/stretchr/testify/assert"
"strings"
+ "testing"
+ "time"
+
+ "github.com/apache/camel-k/pkg/util/log"
"github.com/operator-framework/operator-sdk/pkg/sdk"
+ "github.com/stretchr/testify/assert"
)
func TestPodLogScrape(t *testing.T) {
@@ -37,7 +38,8 @@ func TestPodLogScrape(t *testing.T) {
defer sdk.Delete(pod)
assert.Nil(t, err)
- ctx, _ := context.WithDeadline(context.Background(),
time.Now().Add(30*time.Second))
+ ctx, cancel := context.WithDeadline(context.Background(),
time.Now().Add(30*time.Second))
+ defer cancel()
scraper := log.NewPodScraper(pod.Namespace, pod.Name)
in := scraper.Start(ctx)
@@ -71,7 +73,8 @@ func TestSelectorLogScrape(t *testing.T) {
defer sdk.Delete(deployment)
assert.Nil(t, err)
- ctx, _ := context.WithDeadline(context.Background(),
time.Now().Add(30*time.Second))
+ ctx, cancel := context.WithDeadline(context.Background(),
time.Now().Add(30*time.Second))
+ defer cancel()
scraper := log.NewSelectorScraper(deployment.Namespace, "scrape=me")
in := scraper.Start(ctx)