From d8fec75658c32364d92fc88823465fcd86ee5fc7 Mon Sep 17 00:00:00 2001 From: Andy Goldstein Date: Thu, 27 Oct 2016 12:07:23 -0400 Subject: [PATCH] Fixes for golint tip golint as of https://github.com/golang/lint/blob/3390df4df2787994aea98de825b964ac7944b817/lint.go#L1440-L1442 requires that any function that has a context.Context argument have said argument in the first position. This commit fixes the one function we had where it wasn't. --- pkg/storage/etcd3/store_test.go | 18 +++++++++--------- pkg/storage/etcd3/watcher_test.go | 8 ++++---- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/pkg/storage/etcd3/store_test.go b/pkg/storage/etcd3/store_test.go index b9a394724c2..b5e101490f8 100644 --- a/pkg/storage/etcd3/store_test.go +++ b/pkg/storage/etcd3/store_test.go @@ -97,7 +97,7 @@ func TestCreateWithKeyExist(t *testing.T) { ctx, store, cluster := testSetup(t) defer cluster.Terminate(t) obj := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}} - key, _ := testPropogateStore(t, store, ctx, obj) + key, _ := testPropogateStore(ctx, t, store, obj) out := &api.Pod{} err := store.Create(ctx, key, obj, out, 0) if err == nil || !storage.IsNodeExist(err) { @@ -108,7 +108,7 @@ func TestCreateWithKeyExist(t *testing.T) { func TestGet(t *testing.T) { ctx, store, cluster := testSetup(t) defer cluster.Terminate(t) - key, storedObj := testPropogateStore(t, store, ctx, &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}) + key, storedObj := testPropogateStore(ctx, t, store, &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}) tests := []struct { key string @@ -152,7 +152,7 @@ func TestGet(t *testing.T) { func TestUnconditionalDelete(t *testing.T) { ctx, store, cluster := testSetup(t) defer cluster.Terminate(t) - key, storedObj := testPropogateStore(t, store, ctx, &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}) + key, storedObj := testPropogateStore(ctx, t, store, &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}) tests := []struct { key string @@ -189,7 +189,7 @@ func TestUnconditionalDelete(t *testing.T) { func TestConditionalDelete(t *testing.T) { ctx, store, cluster := testSetup(t) defer cluster.Terminate(t) - key, storedObj := testPropogateStore(t, store, ctx, &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo", UID: "A"}}) + key, storedObj := testPropogateStore(ctx, t, store, &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo", UID: "A"}}) tests := []struct { precondition *storage.Preconditions @@ -217,14 +217,14 @@ func TestConditionalDelete(t *testing.T) { if !reflect.DeepEqual(storedObj, out) { t.Errorf("#%d: pod want=%#v, get=%#v", i, storedObj, out) } - key, storedObj = testPropogateStore(t, store, ctx, &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo", UID: "A"}}) + key, storedObj = testPropogateStore(ctx, t, store, &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo", UID: "A"}}) } } func TestGetToList(t *testing.T) { ctx, store, cluster := testSetup(t) defer cluster.Terminate(t) - key, storedObj := testPropogateStore(t, store, ctx, &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}) + key, storedObj := testPropogateStore(ctx, t, store, &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}) tests := []struct { key string @@ -273,7 +273,7 @@ func TestGetToList(t *testing.T) { func TestGuaranteedUpdate(t *testing.T) { ctx, store, cluster := testSetup(t) defer cluster.Terminate(t) - key, storeObj := testPropogateStore(t, store, ctx, &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo", UID: "A"}}) + key, storeObj := testPropogateStore(ctx, t, store, &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo", UID: "A"}}) tests := []struct { key string @@ -404,7 +404,7 @@ func TestGuaranteedUpdateWithTTL(t *testing.T) { func TestGuaranteedUpdateWithConflict(t *testing.T) { ctx, store, cluster := testSetup(t) defer cluster.Terminate(t) - key, _ := testPropogateStore(t, store, ctx, &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}) + key, _ := testPropogateStore(ctx, t, store, &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}) errChan := make(chan error, 1) var firstToFinish sync.WaitGroup @@ -545,7 +545,7 @@ func testSetup(t *testing.T) (context.Context, *store, *integration.ClusterV3) { // testPropogateStore helps propogates store with objects, automates key generation, and returns // keys and stored objects. -func testPropogateStore(t *testing.T, store *store, ctx context.Context, obj *api.Pod) (string, *api.Pod) { +func testPropogateStore(ctx context.Context, t *testing.T, store *store, obj *api.Pod) (string, *api.Pod) { // Setup store with a key and grab the output for returning. key := "/testkey" setOutput := &api.Pod{} diff --git a/pkg/storage/etcd3/watcher_test.go b/pkg/storage/etcd3/watcher_test.go index f0d71db36dd..43281b1d799 100644 --- a/pkg/storage/etcd3/watcher_test.go +++ b/pkg/storage/etcd3/watcher_test.go @@ -128,7 +128,7 @@ func testWatch(t *testing.T, recursive bool) { func TestDeleteTriggerWatch(t *testing.T) { ctx, store, cluster := testSetup(t) defer cluster.Terminate(t) - key, storedObj := testPropogateStore(t, store, ctx, &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}) + key, storedObj := testPropogateStore(ctx, t, store, &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}) w, err := store.Watch(ctx, key, storedObj.ResourceVersion, storage.Everything) if err != nil { t.Fatalf("Watch failed: %v", err) @@ -145,7 +145,7 @@ func TestDeleteTriggerWatch(t *testing.T) { func TestWatchFromZero(t *testing.T) { ctx, store, cluster := testSetup(t) defer cluster.Terminate(t) - key, storedObj := testPropogateStore(t, store, ctx, &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}) + key, storedObj := testPropogateStore(ctx, t, store, &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}) w, err := store.Watch(ctx, key, "0", storage.Everything) if err != nil { @@ -159,7 +159,7 @@ func TestWatchFromZero(t *testing.T) { func TestWatchFromNoneZero(t *testing.T) { ctx, store, cluster := testSetup(t) defer cluster.Terminate(t) - key, storedObj := testPropogateStore(t, store, ctx, &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}) + key, storedObj := testPropogateStore(ctx, t, store, &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}) w, err := store.Watch(ctx, key, storedObj.ResourceVersion, storage.Everything) if err != nil { @@ -238,7 +238,7 @@ func TestWatchErrResultNotBlockAfterCancel(t *testing.T) { func TestWatchDeleteEventObjectHaveLatestRV(t *testing.T) { ctx, store, cluster := testSetup(t) defer cluster.Terminate(t) - key, storedObj := testPropogateStore(t, store, ctx, &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}) + key, storedObj := testPropogateStore(ctx, t, store, &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}) w, err := store.Watch(ctx, key, storedObj.ResourceVersion, storage.Everything) if err != nil {