gofmt -s fixes
This commit is contained in:
parent
f8c0f942ea
commit
717ed85823
|
@ -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: "",
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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: "",
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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}
|
||||
|
|
Loading…
Reference in New Issue
Block a user