You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2018/09/25 13:35:54 UTC

[camel-k] branch cancel created (now 7ba335b)

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a change to branch cancel
in repository https://gitbox.apache.org/repos/asf/camel-k.git.


      at 7ba335b  Defer cancel function call returned by WithDeadline in tests

This branch includes the following new commits:

     new 7ba335b  Defer cancel function call returned by WithDeadline in tests

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[camel-k] 01/01: Defer cancel function call returned by WithDeadline in tests

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch cancel
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 7ba335bbd696fbd21c47700c6e50075219891eba
Author: Andrea Cosentino <an...@gmail.com>
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)