From 717ed858231492b32d3f02b3df9a31a72ac4644c Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Tue, 14 Apr 2020 23:44:18 +0200 Subject: [PATCH] gofmt -s fixes --- adder/sharding/dag_service_test.go | 6 +-- api/ipfsproxy/ipfsproxy_test.go | 16 +++--- api/rest/client/client_test.go | 6 +-- api/rest/restapi_test.go | 50 +++++++++---------- api/types_test.go | 6 +-- cmd/ipfs-cluster-ctl/graph_test.go | 24 ++++----- pintracker/optracker/operationtracker_test.go | 6 +-- test/rpc_api_mock.go | 12 ++--- test/sharding.go | 22 ++++---- 9 files changed, 74 insertions(+), 74 deletions(-) diff --git a/adder/sharding/dag_service_test.go b/adder/sharding/dag_service_test.go index 94f618eb..b60d3461 100644 --- a/adder/sharding/dag_service_test.go +++ b/adder/sharding/dag_service_test.go @@ -194,7 +194,7 @@ func TestFromMultipart_Errors(t *testing.T) { } tcs := []*testcase{ - &testcase{ + { name: "bad chunker", params: &api.AddParams{ Layout: "", @@ -210,7 +210,7 @@ func TestFromMultipart_Errors(t *testing.T) { }, }, }, - &testcase{ + { name: "shard size too small", params: &api.AddParams{ Layout: "", @@ -226,7 +226,7 @@ func TestFromMultipart_Errors(t *testing.T) { }, }, }, - &testcase{ + { name: "replication too high", params: &api.AddParams{ Layout: "", diff --git a/api/ipfsproxy/ipfsproxy_test.go b/api/ipfsproxy/ipfsproxy_test.go index a67874e0..ca5ebc1f 100644 --- a/api/ipfsproxy/ipfsproxy_test.go +++ b/api/ipfsproxy/ipfsproxy_test.go @@ -546,11 +546,11 @@ func TestProxyRepoGC(t *testing.T) { } testcases := []testcase{ - testcase{ + { name: "With streaming errors", streamErrors: true, }, - testcase{ + { name: "Without streaming errors", streamErrors: false, }, @@ -622,19 +622,19 @@ func TestProxyAdd(t *testing.T) { } testcases := []testcase{ - testcase{ + { query: "", expectedCid: test.ShardingDirBalancedRootCID, }, - testcase{ + { query: "progress=true", expectedCid: test.ShardingDirBalancedRootCID, }, - testcase{ + { query: "wrap-with-directory=true", expectedCid: test.ShardingDirBalancedRootCIDWrapped, }, - testcase{ + { query: "trickle=true", expectedCid: test.ShardingDirTrickleRootCID, }, @@ -809,8 +809,8 @@ func TestAttackHeaderSize(t *testing.T) { expectedStatus int } testcases := []testcase{ - testcase{testHeaderSize / 2, http.StatusNotFound}, - testcase{testHeaderSize * 2, http.StatusRequestHeaderFieldsTooLarge}, + {testHeaderSize / 2, http.StatusNotFound}, + {testHeaderSize * 2, http.StatusRequestHeaderFieldsTooLarge}, } req, err := http.NewRequest("POST", fmt.Sprintf("%s/foo", proxyURL(proxy)), nil) diff --git a/api/rest/client/client_test.go b/api/rest/client/client_test.go index 64c25dd5..fa32a402 100644 --- a/api/rest/client/client_test.go +++ b/api/rest/client/client_test.go @@ -159,19 +159,19 @@ func TestHostPort(t *testing.T) { } testcases := []testcase{ - testcase{ + { host: "3.3.1.1", port: "9094", expectedHostname: "3.3.1.1:9094", expectedProxyAddr: "/ip4/3.3.1.1/tcp/9095", }, - testcase{ + { host: "ipfs.io", port: "9094", expectedHostname: "ipfs.io:9094", expectedProxyAddr: "/dns4/ipfs.io/tcp/9095", }, - testcase{ + { host: "2001:db8::1", port: "9094", expectedHostname: "[2001:db8::1]:9094", diff --git a/api/rest/restapi_test.go b/api/rest/restapi_test.go index c9a6e302..cdefb330 100644 --- a/api/rest/restapi_test.go +++ b/api/rest/restapi_test.go @@ -1144,7 +1144,7 @@ func TestCORS(t *testing.T) { reqHeaders.Set("Access-Control-Request-Headers", "Content-Type") for _, tc := range []testcase{ - testcase{"GET", "/pins"}, + {"GET", "/pins"}, // testcase{}, } { reqHeaders.Set("Access-Control-Request-Method", tc.method) @@ -1275,116 +1275,116 @@ func TestBasicAuth(t *testing.T) { defer rest.Shutdown(ctx) for _, tc := range []httpTestcase{ - httpTestcase{}, - httpTestcase{ + {}, + { method: "", path: "", checker: assertHTTPStatusIsUnauthoriazed, }, - httpTestcase{ + { method: "GET", path: "", checker: assertHTTPStatusIsUnauthoriazed, }, - httpTestcase{ + { method: "GET", path: "/", checker: assertHTTPStatusIsUnauthoriazed, }, - httpTestcase{ + { method: "GET", path: "/foo", checker: assertHTTPStatusIsUnauthoriazed, }, - httpTestcase{ + { method: "POST", path: "/foo", checker: assertHTTPStatusIsUnauthoriazed, }, - httpTestcase{ + { method: "DELETE", path: "/foo", checker: assertHTTPStatusIsUnauthoriazed, }, - httpTestcase{ + { method: "HEAD", path: "/foo", checker: assertHTTPStatusIsUnauthoriazed, }, - httpTestcase{ + { method: "OPTIONS", path: "/foo", checker: assertHTTPStatusIsUnauthoriazed, }, - httpTestcase{ + { method: "PUT", path: "/foo", checker: assertHTTPStatusIsUnauthoriazed, }, - httpTestcase{ + { method: "TRACE", path: "/foo", checker: assertHTTPStatusIsUnauthoriazed, }, - httpTestcase{ + { method: "CONNECT", path: "/foo", checker: assertHTTPStatusIsUnauthoriazed, }, - httpTestcase{ + { method: "BAR", path: "/foo", checker: assertHTTPStatusIsUnauthoriazed, }, - httpTestcase{ + { method: "GET", path: "/foo", shaper: makeBasicAuthRequestShaper(invalidUserName, invalidUserPassword), checker: assertHTTPStatusIsUnauthoriazed, }, - httpTestcase{ + { method: "GET", path: "/foo", shaper: makeBasicAuthRequestShaper(validUserName, invalidUserPassword), checker: assertHTTPStatusIsUnauthoriazed, }, - httpTestcase{ + { method: "GET", path: "/foo", shaper: makeBasicAuthRequestShaper(invalidUserName, validUserPassword), checker: assertHTTPStatusIsUnauthoriazed, }, - httpTestcase{ + { method: "GET", path: "/foo", shaper: makeBasicAuthRequestShaper(adminUserName, validUserPassword), checker: assertHTTPStatusIsUnauthoriazed, }, - httpTestcase{ + { method: "GET", path: "/foo", shaper: makeBasicAuthRequestShaper(validUserName, validUserPassword), checker: makeHTTPStatusNegatedAssert(assertHTTPStatusIsUnauthoriazed), }, - httpTestcase{ + { method: "POST", path: "/foo", shaper: makeBasicAuthRequestShaper(validUserName, validUserPassword), checker: makeHTTPStatusNegatedAssert(assertHTTPStatusIsUnauthoriazed), }, - httpTestcase{ + { method: "DELETE", path: "/foo", shaper: makeBasicAuthRequestShaper(validUserName, validUserPassword), checker: makeHTTPStatusNegatedAssert(assertHTTPStatusIsUnauthoriazed), }, - httpTestcase{ + { method: "BAR", path: "/foo", shaper: makeBasicAuthRequestShaper(validUserName, validUserPassword), checker: makeHTTPStatusNegatedAssert(assertHTTPStatusIsUnauthoriazed), }, - httpTestcase{ + { method: "GET", path: "/id", shaper: makeBasicAuthRequestShaper(validUserName, validUserPassword), @@ -1405,13 +1405,13 @@ func TestLimitMaxHeaderSize(t *testing.T) { defer rest.Shutdown(ctx) for _, tc := range []httpTestcase{ - httpTestcase{ + { method: "GET", path: "/foo", shaper: makeLongHeaderShaper(maxHeaderBytes * 2), checker: assertHTTPStatusIsTooLarge, }, - httpTestcase{ + { method: "GET", path: "/foo", shaper: makeLongHeaderShaper(maxHeaderBytes / 2), diff --git a/api/types_test.go b/api/types_test.go index d541d11a..6047dfe1 100644 --- a/api/types_test.go +++ b/api/types_test.go @@ -159,7 +159,7 @@ func TestDupTags(t *testing.T) { func TestPinOptionsQuery(t *testing.T) { testcases := []*PinOptions{ - &PinOptions{ + { ReplicationFactorMax: 3, ReplicationFactorMin: 2, Name: "abc", @@ -174,7 +174,7 @@ func TestPinOptionsQuery(t *testing.T) { "hello2": "bye2", }, }, - &PinOptions{ + { ReplicationFactorMax: -1, ReplicationFactorMin: 0, Name: "", @@ -182,7 +182,7 @@ func TestPinOptionsQuery(t *testing.T) { UserAllocations: []peer.ID{}, Metadata: nil, }, - &PinOptions{ + { ReplicationFactorMax: -1, ReplicationFactorMin: 0, Name: "", diff --git a/cmd/ipfs-cluster-ctl/graph_test.go b/cmd/ipfs-cluster-ctl/graph_test.go index 2978efa3..4a08c34a 100644 --- a/cmd/ipfs-cluster-ctl/graph_test.go +++ b/cmd/ipfs-cluster-ctl/graph_test.go @@ -83,29 +83,29 @@ func TestSimpleIpfsGraphs(t *testing.T) { cg := api.ConnectGraph{ ClusterID: pid1, ClusterLinks: map[string][]peer.ID{ - peer.Encode(pid1): []peer.ID{ + peer.Encode(pid1): { pid2, pid3, }, - peer.Encode(pid2): []peer.ID{ + peer.Encode(pid2): { pid1, pid3, }, - peer.Encode(pid3): []peer.ID{ + peer.Encode(pid3): { pid1, pid2, }, }, IPFSLinks: map[string][]peer.ID{ - peer.Encode(pid4): []peer.ID{ + peer.Encode(pid4): { pid5, pid6, }, - peer.Encode(pid5): []peer.ID{ + peer.Encode(pid5): { pid4, pid6, }, - peer.Encode(pid6): []peer.ID{ + peer.Encode(pid6): { pid4, pid5, }, @@ -181,35 +181,35 @@ func TestIpfsAllGraphs(t *testing.T) { cg := api.ConnectGraph{ ClusterID: pid1, ClusterLinks: map[string][]peer.ID{ - peer.Encode(pid1): []peer.ID{ + peer.Encode(pid1): { pid2, pid3, }, - peer.Encode(pid2): []peer.ID{ + peer.Encode(pid2): { pid1, pid3, }, - peer.Encode(pid3): []peer.ID{ + peer.Encode(pid3): { pid1, pid2, }, }, IPFSLinks: map[string][]peer.ID{ - peer.Encode(pid4): []peer.ID{ + peer.Encode(pid4): { pid5, pid6, pid7, pid8, pid9, }, - peer.Encode(pid5): []peer.ID{ + peer.Encode(pid5): { pid4, pid6, pid7, pid8, pid9, }, - peer.Encode(pid6): []peer.ID{ + peer.Encode(pid6): { pid4, pid5, pid7, diff --git a/pintracker/optracker/operationtracker_test.go b/pintracker/optracker/operationtracker_test.go index bb87651f..c4e06cf4 100644 --- a/pintracker/optracker/operationtracker_test.go +++ b/pintracker/optracker/operationtracker_test.go @@ -203,9 +203,9 @@ func TestOperationTracker_OpContext(t *testing.T) { func TestOperationTracker_filterOps(t *testing.T) { ctx := context.Background() testOpsMap := map[string]*Operation{ - test.Cid1.String(): &Operation{pin: api.PinCid(test.Cid1), opType: OperationPin, phase: PhaseQueued}, - test.Cid2.String(): &Operation{pin: api.PinCid(test.Cid2), opType: OperationPin, phase: PhaseInProgress}, - test.Cid3.String(): &Operation{pin: api.PinCid(test.Cid3), opType: OperationUnpin, phase: PhaseInProgress}, + test.Cid1.String(): {pin: api.PinCid(test.Cid1), opType: OperationPin, phase: PhaseQueued}, + test.Cid2.String(): {pin: api.PinCid(test.Cid2), opType: OperationPin, phase: PhaseInProgress}, + test.Cid3.String(): {pin: api.PinCid(test.Cid3), opType: OperationUnpin, phase: PhaseInProgress}, } opt := &OperationTracker{ctx: ctx, operations: testOpsMap} diff --git a/test/rpc_api_mock.go b/test/rpc_api_mock.go index 51581e5e..5d5099ec 100644 --- a/test/rpc_api_mock.go +++ b/test/rpc_api_mock.go @@ -201,14 +201,14 @@ func (mock *mockCluster) ConnectGraph(ctx context.Context, in struct{}, out *api *out = api.ConnectGraph{ ClusterID: PeerID1, IPFSLinks: map[string][]peer.ID{ - peer.Encode(PeerID4): []peer.ID{PeerID5, PeerID6}, - peer.Encode(PeerID5): []peer.ID{PeerID4, PeerID6}, - peer.Encode(PeerID6): []peer.ID{PeerID4, PeerID5}, + peer.Encode(PeerID4): {PeerID5, PeerID6}, + peer.Encode(PeerID5): {PeerID4, PeerID6}, + peer.Encode(PeerID6): {PeerID4, PeerID5}, }, ClusterLinks: map[string][]peer.ID{ - peer.Encode(PeerID1): []peer.ID{PeerID2, PeerID3}, - peer.Encode(PeerID2): []peer.ID{PeerID1, PeerID3}, - peer.Encode(PeerID3): []peer.ID{PeerID1, PeerID2}, + peer.Encode(PeerID1): {PeerID2, PeerID3}, + peer.Encode(PeerID2): {PeerID1, PeerID3}, + peer.Encode(PeerID3): {PeerID1, PeerID2}, }, ClustertoIPFS: map[string]peer.ID{ peer.Encode(PeerID1): PeerID4, diff --git a/test/sharding.go b/test/sharding.go index 0d324615..c243e15d 100644 --- a/test/sharding.go +++ b/test/sharding.go @@ -204,23 +204,23 @@ func (sth *ShardingTestHelper) makeTree(t *testing.T) os.FileInfo { p0 := shardingTestTree paths := [][]string{ - []string{p0, "A", "alpha"}, - []string{p0, "A", "beta"}, - []string{p0, "A", "delta", "empty"}, - []string{p0, "A", "gamma"}, - []string{p0, "B"}, + {p0, "A", "alpha"}, + {p0, "A", "beta"}, + {p0, "A", "delta", "empty"}, + {p0, "A", "gamma"}, + {p0, "B"}, } for _, p := range paths { makeDir(t, sth.path(p...)) } files := [][]string{ - []string{p0, "A", "alpha", "small_file_0"}, - []string{p0, "A", "beta", "small_file_1"}, - []string{p0, "A", "small_file_2"}, - []string{p0, "A", "gamma", "small_file_3"}, - []string{p0, "B", "medium_file"}, - []string{p0, "B", "big_file"}, + {p0, "A", "alpha", "small_file_0"}, + {p0, "A", "beta", "small_file_1"}, + {p0, "A", "small_file_2"}, + {p0, "A", "gamma", "small_file_3"}, + {p0, "B", "medium_file"}, + {p0, "B", "big_file"}, } fileSizes := []int{5, 5, 5, 5, 300, 3000}