gofmt -s fixes

This commit is contained in:
Hector Sanjuan 2020-04-14 23:44:18 +02:00
parent f8c0f942ea
commit 717ed85823
9 changed files with 74 additions and 74 deletions

View File

@ -194,7 +194,7 @@ func TestFromMultipart_Errors(t *testing.T) {
} }
tcs := []*testcase{ tcs := []*testcase{
&testcase{ {
name: "bad chunker", name: "bad chunker",
params: &api.AddParams{ params: &api.AddParams{
Layout: "", Layout: "",
@ -210,7 +210,7 @@ func TestFromMultipart_Errors(t *testing.T) {
}, },
}, },
}, },
&testcase{ {
name: "shard size too small", name: "shard size too small",
params: &api.AddParams{ params: &api.AddParams{
Layout: "", Layout: "",
@ -226,7 +226,7 @@ func TestFromMultipart_Errors(t *testing.T) {
}, },
}, },
}, },
&testcase{ {
name: "replication too high", name: "replication too high",
params: &api.AddParams{ params: &api.AddParams{
Layout: "", Layout: "",

View File

@ -546,11 +546,11 @@ func TestProxyRepoGC(t *testing.T) {
} }
testcases := []testcase{ testcases := []testcase{
testcase{ {
name: "With streaming errors", name: "With streaming errors",
streamErrors: true, streamErrors: true,
}, },
testcase{ {
name: "Without streaming errors", name: "Without streaming errors",
streamErrors: false, streamErrors: false,
}, },
@ -622,19 +622,19 @@ func TestProxyAdd(t *testing.T) {
} }
testcases := []testcase{ testcases := []testcase{
testcase{ {
query: "", query: "",
expectedCid: test.ShardingDirBalancedRootCID, expectedCid: test.ShardingDirBalancedRootCID,
}, },
testcase{ {
query: "progress=true", query: "progress=true",
expectedCid: test.ShardingDirBalancedRootCID, expectedCid: test.ShardingDirBalancedRootCID,
}, },
testcase{ {
query: "wrap-with-directory=true", query: "wrap-with-directory=true",
expectedCid: test.ShardingDirBalancedRootCIDWrapped, expectedCid: test.ShardingDirBalancedRootCIDWrapped,
}, },
testcase{ {
query: "trickle=true", query: "trickle=true",
expectedCid: test.ShardingDirTrickleRootCID, expectedCid: test.ShardingDirTrickleRootCID,
}, },
@ -809,8 +809,8 @@ func TestAttackHeaderSize(t *testing.T) {
expectedStatus int expectedStatus int
} }
testcases := []testcase{ testcases := []testcase{
testcase{testHeaderSize / 2, http.StatusNotFound}, {testHeaderSize / 2, http.StatusNotFound},
testcase{testHeaderSize * 2, http.StatusRequestHeaderFieldsTooLarge}, {testHeaderSize * 2, http.StatusRequestHeaderFieldsTooLarge},
} }
req, err := http.NewRequest("POST", fmt.Sprintf("%s/foo", proxyURL(proxy)), nil) req, err := http.NewRequest("POST", fmt.Sprintf("%s/foo", proxyURL(proxy)), nil)

View File

@ -159,19 +159,19 @@ func TestHostPort(t *testing.T) {
} }
testcases := []testcase{ testcases := []testcase{
testcase{ {
host: "3.3.1.1", host: "3.3.1.1",
port: "9094", port: "9094",
expectedHostname: "3.3.1.1:9094", expectedHostname: "3.3.1.1:9094",
expectedProxyAddr: "/ip4/3.3.1.1/tcp/9095", expectedProxyAddr: "/ip4/3.3.1.1/tcp/9095",
}, },
testcase{ {
host: "ipfs.io", host: "ipfs.io",
port: "9094", port: "9094",
expectedHostname: "ipfs.io:9094", expectedHostname: "ipfs.io:9094",
expectedProxyAddr: "/dns4/ipfs.io/tcp/9095", expectedProxyAddr: "/dns4/ipfs.io/tcp/9095",
}, },
testcase{ {
host: "2001:db8::1", host: "2001:db8::1",
port: "9094", port: "9094",
expectedHostname: "[2001:db8::1]:9094", expectedHostname: "[2001:db8::1]:9094",

View File

@ -1144,7 +1144,7 @@ func TestCORS(t *testing.T) {
reqHeaders.Set("Access-Control-Request-Headers", "Content-Type") reqHeaders.Set("Access-Control-Request-Headers", "Content-Type")
for _, tc := range []testcase{ for _, tc := range []testcase{
testcase{"GET", "/pins"}, {"GET", "/pins"},
// testcase{}, // testcase{},
} { } {
reqHeaders.Set("Access-Control-Request-Method", tc.method) reqHeaders.Set("Access-Control-Request-Method", tc.method)
@ -1275,116 +1275,116 @@ func TestBasicAuth(t *testing.T) {
defer rest.Shutdown(ctx) defer rest.Shutdown(ctx)
for _, tc := range []httpTestcase{ for _, tc := range []httpTestcase{
httpTestcase{}, {},
httpTestcase{ {
method: "", method: "",
path: "", path: "",
checker: assertHTTPStatusIsUnauthoriazed, checker: assertHTTPStatusIsUnauthoriazed,
}, },
httpTestcase{ {
method: "GET", method: "GET",
path: "", path: "",
checker: assertHTTPStatusIsUnauthoriazed, checker: assertHTTPStatusIsUnauthoriazed,
}, },
httpTestcase{ {
method: "GET", method: "GET",
path: "/", path: "/",
checker: assertHTTPStatusIsUnauthoriazed, checker: assertHTTPStatusIsUnauthoriazed,
}, },
httpTestcase{ {
method: "GET", method: "GET",
path: "/foo", path: "/foo",
checker: assertHTTPStatusIsUnauthoriazed, checker: assertHTTPStatusIsUnauthoriazed,
}, },
httpTestcase{ {
method: "POST", method: "POST",
path: "/foo", path: "/foo",
checker: assertHTTPStatusIsUnauthoriazed, checker: assertHTTPStatusIsUnauthoriazed,
}, },
httpTestcase{ {
method: "DELETE", method: "DELETE",
path: "/foo", path: "/foo",
checker: assertHTTPStatusIsUnauthoriazed, checker: assertHTTPStatusIsUnauthoriazed,
}, },
httpTestcase{ {
method: "HEAD", method: "HEAD",
path: "/foo", path: "/foo",
checker: assertHTTPStatusIsUnauthoriazed, checker: assertHTTPStatusIsUnauthoriazed,
}, },
httpTestcase{ {
method: "OPTIONS", method: "OPTIONS",
path: "/foo", path: "/foo",
checker: assertHTTPStatusIsUnauthoriazed, checker: assertHTTPStatusIsUnauthoriazed,
}, },
httpTestcase{ {
method: "PUT", method: "PUT",
path: "/foo", path: "/foo",
checker: assertHTTPStatusIsUnauthoriazed, checker: assertHTTPStatusIsUnauthoriazed,
}, },
httpTestcase{ {
method: "TRACE", method: "TRACE",
path: "/foo", path: "/foo",
checker: assertHTTPStatusIsUnauthoriazed, checker: assertHTTPStatusIsUnauthoriazed,
}, },
httpTestcase{ {
method: "CONNECT", method: "CONNECT",
path: "/foo", path: "/foo",
checker: assertHTTPStatusIsUnauthoriazed, checker: assertHTTPStatusIsUnauthoriazed,
}, },
httpTestcase{ {
method: "BAR", method: "BAR",
path: "/foo", path: "/foo",
checker: assertHTTPStatusIsUnauthoriazed, checker: assertHTTPStatusIsUnauthoriazed,
}, },
httpTestcase{ {
method: "GET", method: "GET",
path: "/foo", path: "/foo",
shaper: makeBasicAuthRequestShaper(invalidUserName, invalidUserPassword), shaper: makeBasicAuthRequestShaper(invalidUserName, invalidUserPassword),
checker: assertHTTPStatusIsUnauthoriazed, checker: assertHTTPStatusIsUnauthoriazed,
}, },
httpTestcase{ {
method: "GET", method: "GET",
path: "/foo", path: "/foo",
shaper: makeBasicAuthRequestShaper(validUserName, invalidUserPassword), shaper: makeBasicAuthRequestShaper(validUserName, invalidUserPassword),
checker: assertHTTPStatusIsUnauthoriazed, checker: assertHTTPStatusIsUnauthoriazed,
}, },
httpTestcase{ {
method: "GET", method: "GET",
path: "/foo", path: "/foo",
shaper: makeBasicAuthRequestShaper(invalidUserName, validUserPassword), shaper: makeBasicAuthRequestShaper(invalidUserName, validUserPassword),
checker: assertHTTPStatusIsUnauthoriazed, checker: assertHTTPStatusIsUnauthoriazed,
}, },
httpTestcase{ {
method: "GET", method: "GET",
path: "/foo", path: "/foo",
shaper: makeBasicAuthRequestShaper(adminUserName, validUserPassword), shaper: makeBasicAuthRequestShaper(adminUserName, validUserPassword),
checker: assertHTTPStatusIsUnauthoriazed, checker: assertHTTPStatusIsUnauthoriazed,
}, },
httpTestcase{ {
method: "GET", method: "GET",
path: "/foo", path: "/foo",
shaper: makeBasicAuthRequestShaper(validUserName, validUserPassword), shaper: makeBasicAuthRequestShaper(validUserName, validUserPassword),
checker: makeHTTPStatusNegatedAssert(assertHTTPStatusIsUnauthoriazed), checker: makeHTTPStatusNegatedAssert(assertHTTPStatusIsUnauthoriazed),
}, },
httpTestcase{ {
method: "POST", method: "POST",
path: "/foo", path: "/foo",
shaper: makeBasicAuthRequestShaper(validUserName, validUserPassword), shaper: makeBasicAuthRequestShaper(validUserName, validUserPassword),
checker: makeHTTPStatusNegatedAssert(assertHTTPStatusIsUnauthoriazed), checker: makeHTTPStatusNegatedAssert(assertHTTPStatusIsUnauthoriazed),
}, },
httpTestcase{ {
method: "DELETE", method: "DELETE",
path: "/foo", path: "/foo",
shaper: makeBasicAuthRequestShaper(validUserName, validUserPassword), shaper: makeBasicAuthRequestShaper(validUserName, validUserPassword),
checker: makeHTTPStatusNegatedAssert(assertHTTPStatusIsUnauthoriazed), checker: makeHTTPStatusNegatedAssert(assertHTTPStatusIsUnauthoriazed),
}, },
httpTestcase{ {
method: "BAR", method: "BAR",
path: "/foo", path: "/foo",
shaper: makeBasicAuthRequestShaper(validUserName, validUserPassword), shaper: makeBasicAuthRequestShaper(validUserName, validUserPassword),
checker: makeHTTPStatusNegatedAssert(assertHTTPStatusIsUnauthoriazed), checker: makeHTTPStatusNegatedAssert(assertHTTPStatusIsUnauthoriazed),
}, },
httpTestcase{ {
method: "GET", method: "GET",
path: "/id", path: "/id",
shaper: makeBasicAuthRequestShaper(validUserName, validUserPassword), shaper: makeBasicAuthRequestShaper(validUserName, validUserPassword),
@ -1405,13 +1405,13 @@ func TestLimitMaxHeaderSize(t *testing.T) {
defer rest.Shutdown(ctx) defer rest.Shutdown(ctx)
for _, tc := range []httpTestcase{ for _, tc := range []httpTestcase{
httpTestcase{ {
method: "GET", method: "GET",
path: "/foo", path: "/foo",
shaper: makeLongHeaderShaper(maxHeaderBytes * 2), shaper: makeLongHeaderShaper(maxHeaderBytes * 2),
checker: assertHTTPStatusIsTooLarge, checker: assertHTTPStatusIsTooLarge,
}, },
httpTestcase{ {
method: "GET", method: "GET",
path: "/foo", path: "/foo",
shaper: makeLongHeaderShaper(maxHeaderBytes / 2), shaper: makeLongHeaderShaper(maxHeaderBytes / 2),

View File

@ -159,7 +159,7 @@ func TestDupTags(t *testing.T) {
func TestPinOptionsQuery(t *testing.T) { func TestPinOptionsQuery(t *testing.T) {
testcases := []*PinOptions{ testcases := []*PinOptions{
&PinOptions{ {
ReplicationFactorMax: 3, ReplicationFactorMax: 3,
ReplicationFactorMin: 2, ReplicationFactorMin: 2,
Name: "abc", Name: "abc",
@ -174,7 +174,7 @@ func TestPinOptionsQuery(t *testing.T) {
"hello2": "bye2", "hello2": "bye2",
}, },
}, },
&PinOptions{ {
ReplicationFactorMax: -1, ReplicationFactorMax: -1,
ReplicationFactorMin: 0, ReplicationFactorMin: 0,
Name: "", Name: "",
@ -182,7 +182,7 @@ func TestPinOptionsQuery(t *testing.T) {
UserAllocations: []peer.ID{}, UserAllocations: []peer.ID{},
Metadata: nil, Metadata: nil,
}, },
&PinOptions{ {
ReplicationFactorMax: -1, ReplicationFactorMax: -1,
ReplicationFactorMin: 0, ReplicationFactorMin: 0,
Name: "", Name: "",

View File

@ -83,29 +83,29 @@ func TestSimpleIpfsGraphs(t *testing.T) {
cg := api.ConnectGraph{ cg := api.ConnectGraph{
ClusterID: pid1, ClusterID: pid1,
ClusterLinks: map[string][]peer.ID{ ClusterLinks: map[string][]peer.ID{
peer.Encode(pid1): []peer.ID{ peer.Encode(pid1): {
pid2, pid2,
pid3, pid3,
}, },
peer.Encode(pid2): []peer.ID{ peer.Encode(pid2): {
pid1, pid1,
pid3, pid3,
}, },
peer.Encode(pid3): []peer.ID{ peer.Encode(pid3): {
pid1, pid1,
pid2, pid2,
}, },
}, },
IPFSLinks: map[string][]peer.ID{ IPFSLinks: map[string][]peer.ID{
peer.Encode(pid4): []peer.ID{ peer.Encode(pid4): {
pid5, pid5,
pid6, pid6,
}, },
peer.Encode(pid5): []peer.ID{ peer.Encode(pid5): {
pid4, pid4,
pid6, pid6,
}, },
peer.Encode(pid6): []peer.ID{ peer.Encode(pid6): {
pid4, pid4,
pid5, pid5,
}, },
@ -181,35 +181,35 @@ func TestIpfsAllGraphs(t *testing.T) {
cg := api.ConnectGraph{ cg := api.ConnectGraph{
ClusterID: pid1, ClusterID: pid1,
ClusterLinks: map[string][]peer.ID{ ClusterLinks: map[string][]peer.ID{
peer.Encode(pid1): []peer.ID{ peer.Encode(pid1): {
pid2, pid2,
pid3, pid3,
}, },
peer.Encode(pid2): []peer.ID{ peer.Encode(pid2): {
pid1, pid1,
pid3, pid3,
}, },
peer.Encode(pid3): []peer.ID{ peer.Encode(pid3): {
pid1, pid1,
pid2, pid2,
}, },
}, },
IPFSLinks: map[string][]peer.ID{ IPFSLinks: map[string][]peer.ID{
peer.Encode(pid4): []peer.ID{ peer.Encode(pid4): {
pid5, pid5,
pid6, pid6,
pid7, pid7,
pid8, pid8,
pid9, pid9,
}, },
peer.Encode(pid5): []peer.ID{ peer.Encode(pid5): {
pid4, pid4,
pid6, pid6,
pid7, pid7,
pid8, pid8,
pid9, pid9,
}, },
peer.Encode(pid6): []peer.ID{ peer.Encode(pid6): {
pid4, pid4,
pid5, pid5,
pid7, pid7,

View File

@ -203,9 +203,9 @@ func TestOperationTracker_OpContext(t *testing.T) {
func TestOperationTracker_filterOps(t *testing.T) { func TestOperationTracker_filterOps(t *testing.T) {
ctx := context.Background() ctx := context.Background()
testOpsMap := map[string]*Operation{ testOpsMap := map[string]*Operation{
test.Cid1.String(): &Operation{pin: api.PinCid(test.Cid1), opType: OperationPin, phase: PhaseQueued}, test.Cid1.String(): {pin: api.PinCid(test.Cid1), opType: OperationPin, phase: PhaseQueued},
test.Cid2.String(): &Operation{pin: api.PinCid(test.Cid2), opType: OperationPin, phase: PhaseInProgress}, test.Cid2.String(): {pin: api.PinCid(test.Cid2), opType: OperationPin, phase: PhaseInProgress},
test.Cid3.String(): &Operation{pin: api.PinCid(test.Cid3), opType: OperationUnpin, phase: PhaseInProgress}, test.Cid3.String(): {pin: api.PinCid(test.Cid3), opType: OperationUnpin, phase: PhaseInProgress},
} }
opt := &OperationTracker{ctx: ctx, operations: testOpsMap} opt := &OperationTracker{ctx: ctx, operations: testOpsMap}

View File

@ -201,14 +201,14 @@ func (mock *mockCluster) ConnectGraph(ctx context.Context, in struct{}, out *api
*out = api.ConnectGraph{ *out = api.ConnectGraph{
ClusterID: PeerID1, ClusterID: PeerID1,
IPFSLinks: map[string][]peer.ID{ IPFSLinks: map[string][]peer.ID{
peer.Encode(PeerID4): []peer.ID{PeerID5, PeerID6}, peer.Encode(PeerID4): {PeerID5, PeerID6},
peer.Encode(PeerID5): []peer.ID{PeerID4, PeerID6}, peer.Encode(PeerID5): {PeerID4, PeerID6},
peer.Encode(PeerID6): []peer.ID{PeerID4, PeerID5}, peer.Encode(PeerID6): {PeerID4, PeerID5},
}, },
ClusterLinks: map[string][]peer.ID{ ClusterLinks: map[string][]peer.ID{
peer.Encode(PeerID1): []peer.ID{PeerID2, PeerID3}, peer.Encode(PeerID1): {PeerID2, PeerID3},
peer.Encode(PeerID2): []peer.ID{PeerID1, PeerID3}, peer.Encode(PeerID2): {PeerID1, PeerID3},
peer.Encode(PeerID3): []peer.ID{PeerID1, PeerID2}, peer.Encode(PeerID3): {PeerID1, PeerID2},
}, },
ClustertoIPFS: map[string]peer.ID{ ClustertoIPFS: map[string]peer.ID{
peer.Encode(PeerID1): PeerID4, peer.Encode(PeerID1): PeerID4,

View File

@ -204,23 +204,23 @@ func (sth *ShardingTestHelper) makeTree(t *testing.T) os.FileInfo {
p0 := shardingTestTree p0 := shardingTestTree
paths := [][]string{ paths := [][]string{
[]string{p0, "A", "alpha"}, {p0, "A", "alpha"},
[]string{p0, "A", "beta"}, {p0, "A", "beta"},
[]string{p0, "A", "delta", "empty"}, {p0, "A", "delta", "empty"},
[]string{p0, "A", "gamma"}, {p0, "A", "gamma"},
[]string{p0, "B"}, {p0, "B"},
} }
for _, p := range paths { for _, p := range paths {
makeDir(t, sth.path(p...)) makeDir(t, sth.path(p...))
} }
files := [][]string{ files := [][]string{
[]string{p0, "A", "alpha", "small_file_0"}, {p0, "A", "alpha", "small_file_0"},
[]string{p0, "A", "beta", "small_file_1"}, {p0, "A", "beta", "small_file_1"},
[]string{p0, "A", "small_file_2"}, {p0, "A", "small_file_2"},
[]string{p0, "A", "gamma", "small_file_3"}, {p0, "A", "gamma", "small_file_3"},
[]string{p0, "B", "medium_file"}, {p0, "B", "medium_file"},
[]string{p0, "B", "big_file"}, {p0, "B", "big_file"},
} }
fileSizes := []int{5, 5, 5, 5, 300, 3000} fileSizes := []int{5, 5, 5, 5, 300, 3000}