mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
*: test gofmt with -s and fix reported issues
This commit is contained in:
@@ -333,8 +333,8 @@ func TestHTTPClusterClientDo(t *testing.T) {
|
||||
endpoints: []url.URL{fakeURL, fakeURL},
|
||||
clientFactory: newStaticHTTPClientFactory(
|
||||
[]staticHTTPResponse{
|
||||
staticHTTPResponse{resp: http.Response{StatusCode: http.StatusTeapot}},
|
||||
staticHTTPResponse{err: fakeErr},
|
||||
{resp: http.Response{StatusCode: http.StatusTeapot}},
|
||||
{err: fakeErr},
|
||||
},
|
||||
),
|
||||
rand: rand.New(rand.NewSource(0)),
|
||||
@@ -348,8 +348,8 @@ func TestHTTPClusterClientDo(t *testing.T) {
|
||||
endpoints: []url.URL{fakeURL, fakeURL},
|
||||
clientFactory: newStaticHTTPClientFactory(
|
||||
[]staticHTTPResponse{
|
||||
staticHTTPResponse{err: fakeErr},
|
||||
staticHTTPResponse{resp: http.Response{StatusCode: http.StatusTeapot}},
|
||||
{err: fakeErr},
|
||||
{resp: http.Response{StatusCode: http.StatusTeapot}},
|
||||
},
|
||||
),
|
||||
rand: rand.New(rand.NewSource(0)),
|
||||
@@ -364,8 +364,8 @@ func TestHTTPClusterClientDo(t *testing.T) {
|
||||
endpoints: []url.URL{fakeURL, fakeURL},
|
||||
clientFactory: newStaticHTTPClientFactory(
|
||||
[]staticHTTPResponse{
|
||||
staticHTTPResponse{err: context.Canceled},
|
||||
staticHTTPResponse{resp: http.Response{StatusCode: http.StatusTeapot}},
|
||||
{err: context.Canceled},
|
||||
{resp: http.Response{StatusCode: http.StatusTeapot}},
|
||||
},
|
||||
),
|
||||
rand: rand.New(rand.NewSource(0)),
|
||||
@@ -389,8 +389,8 @@ func TestHTTPClusterClientDo(t *testing.T) {
|
||||
endpoints: []url.URL{fakeURL, fakeURL},
|
||||
clientFactory: newStaticHTTPClientFactory(
|
||||
[]staticHTTPResponse{
|
||||
staticHTTPResponse{err: fakeErr},
|
||||
staticHTTPResponse{err: fakeErr},
|
||||
{err: fakeErr},
|
||||
{err: fakeErr},
|
||||
},
|
||||
),
|
||||
rand: rand.New(rand.NewSource(0)),
|
||||
@@ -404,8 +404,8 @@ func TestHTTPClusterClientDo(t *testing.T) {
|
||||
endpoints: []url.URL{fakeURL, fakeURL},
|
||||
clientFactory: newStaticHTTPClientFactory(
|
||||
[]staticHTTPResponse{
|
||||
staticHTTPResponse{resp: http.Response{StatusCode: http.StatusBadGateway}},
|
||||
staticHTTPResponse{resp: http.Response{StatusCode: http.StatusTeapot}},
|
||||
{resp: http.Response{StatusCode: http.StatusBadGateway}},
|
||||
{resp: http.Response{StatusCode: http.StatusTeapot}},
|
||||
},
|
||||
),
|
||||
rand: rand.New(rand.NewSource(0)),
|
||||
@@ -513,7 +513,7 @@ func TestRedirectFollowingHTTPClient(t *testing.T) {
|
||||
checkRedirect: func(int) error { return ErrTooManyRedirects },
|
||||
client: &multiStaticHTTPClient{
|
||||
responses: []staticHTTPResponse{
|
||||
staticHTTPResponse{
|
||||
{
|
||||
err: errors.New("fail!"),
|
||||
},
|
||||
},
|
||||
@@ -526,7 +526,7 @@ func TestRedirectFollowingHTTPClient(t *testing.T) {
|
||||
checkRedirect: func(int) error { return ErrTooManyRedirects },
|
||||
client: &multiStaticHTTPClient{
|
||||
responses: []staticHTTPResponse{
|
||||
staticHTTPResponse{
|
||||
{
|
||||
resp: http.Response{
|
||||
StatusCode: http.StatusTeapot,
|
||||
},
|
||||
@@ -546,13 +546,13 @@ func TestRedirectFollowingHTTPClient(t *testing.T) {
|
||||
},
|
||||
client: &multiStaticHTTPClient{
|
||||
responses: []staticHTTPResponse{
|
||||
staticHTTPResponse{
|
||||
{
|
||||
resp: http.Response{
|
||||
StatusCode: http.StatusTemporaryRedirect,
|
||||
Header: http.Header{"Location": []string{"http://example.com"}},
|
||||
},
|
||||
},
|
||||
staticHTTPResponse{
|
||||
{
|
||||
resp: http.Response{
|
||||
StatusCode: http.StatusTeapot,
|
||||
},
|
||||
@@ -572,19 +572,19 @@ func TestRedirectFollowingHTTPClient(t *testing.T) {
|
||||
},
|
||||
client: &multiStaticHTTPClient{
|
||||
responses: []staticHTTPResponse{
|
||||
staticHTTPResponse{
|
||||
{
|
||||
resp: http.Response{
|
||||
StatusCode: http.StatusTemporaryRedirect,
|
||||
Header: http.Header{"Location": []string{"http://example.com"}},
|
||||
},
|
||||
},
|
||||
staticHTTPResponse{
|
||||
{
|
||||
resp: http.Response{
|
||||
StatusCode: http.StatusTemporaryRedirect,
|
||||
Header: http.Header{"Location": []string{"http://example.com"}},
|
||||
},
|
||||
},
|
||||
staticHTTPResponse{
|
||||
{
|
||||
resp: http.Response{
|
||||
StatusCode: http.StatusTeapot,
|
||||
},
|
||||
@@ -604,19 +604,19 @@ func TestRedirectFollowingHTTPClient(t *testing.T) {
|
||||
},
|
||||
client: &multiStaticHTTPClient{
|
||||
responses: []staticHTTPResponse{
|
||||
staticHTTPResponse{
|
||||
{
|
||||
resp: http.Response{
|
||||
StatusCode: http.StatusTemporaryRedirect,
|
||||
Header: http.Header{"Location": []string{"http://example.com"}},
|
||||
},
|
||||
},
|
||||
staticHTTPResponse{
|
||||
{
|
||||
resp: http.Response{
|
||||
StatusCode: http.StatusTemporaryRedirect,
|
||||
Header: http.Header{"Location": []string{"http://example.com"}},
|
||||
},
|
||||
},
|
||||
staticHTTPResponse{
|
||||
{
|
||||
resp: http.Response{
|
||||
StatusCode: http.StatusTeapot,
|
||||
},
|
||||
@@ -631,7 +631,7 @@ func TestRedirectFollowingHTTPClient(t *testing.T) {
|
||||
checkRedirect: func(int) error { return ErrTooManyRedirects },
|
||||
client: &multiStaticHTTPClient{
|
||||
responses: []staticHTTPResponse{
|
||||
staticHTTPResponse{
|
||||
{
|
||||
resp: http.Response{
|
||||
StatusCode: http.StatusTemporaryRedirect,
|
||||
},
|
||||
@@ -646,7 +646,7 @@ func TestRedirectFollowingHTTPClient(t *testing.T) {
|
||||
checkRedirect: func(int) error { return ErrTooManyRedirects },
|
||||
client: &multiStaticHTTPClient{
|
||||
responses: []staticHTTPResponse{
|
||||
staticHTTPResponse{
|
||||
{
|
||||
resp: http.Response{
|
||||
StatusCode: http.StatusTemporaryRedirect,
|
||||
Header: http.Header{"Location": []string{":"}},
|
||||
@@ -714,7 +714,7 @@ func TestDefaultCheckRedirect(t *testing.T) {
|
||||
|
||||
func TestHTTPClusterClientSync(t *testing.T) {
|
||||
cf := newStaticHTTPClientFactory([]staticHTTPResponse{
|
||||
staticHTTPResponse{
|
||||
{
|
||||
resp: http.Response{StatusCode: http.StatusOK, Header: http.Header{"Content-Type": []string{"application/json"}}},
|
||||
body: []byte(`{"members":[{"id":"2745e2525fce8fe","peerURLs":["http://127.0.0.1:7003"],"name":"node3","clientURLs":["http://127.0.0.1:4003"]},{"id":"42134f434382925","peerURLs":["http://127.0.0.1:2380","http://127.0.0.1:7001"],"name":"node1","clientURLs":["http://127.0.0.1:2379","http://127.0.0.1:4001"]},{"id":"94088180e21eb87b","peerURLs":["http://127.0.0.1:7002"],"name":"node2","clientURLs":["http://127.0.0.1:4002"]}]}`),
|
||||
},
|
||||
@@ -761,7 +761,7 @@ func TestHTTPClusterClientSync(t *testing.T) {
|
||||
|
||||
func TestHTTPClusterClientSyncFail(t *testing.T) {
|
||||
cf := newStaticHTTPClientFactory([]staticHTTPResponse{
|
||||
staticHTTPResponse{err: errors.New("fail!")},
|
||||
{err: errors.New("fail!")},
|
||||
})
|
||||
|
||||
hc := &httpClusterClient{
|
||||
@@ -792,7 +792,7 @@ func TestHTTPClusterClientSyncFail(t *testing.T) {
|
||||
|
||||
func TestHTTPClusterClientAutoSyncCancelContext(t *testing.T) {
|
||||
cf := newStaticHTTPClientFactory([]staticHTTPResponse{
|
||||
staticHTTPResponse{
|
||||
{
|
||||
resp: http.Response{StatusCode: http.StatusOK, Header: http.Header{"Content-Type": []string{"application/json"}}},
|
||||
body: []byte(`{"members":[{"id":"2745e2525fce8fe","peerURLs":["http://127.0.0.1:7003"],"name":"node3","clientURLs":["http://127.0.0.1:4003"]},{"id":"42134f434382925","peerURLs":["http://127.0.0.1:2380","http://127.0.0.1:7001"],"name":"node1","clientURLs":["http://127.0.0.1:2379","http://127.0.0.1:4001"]},{"id":"94088180e21eb87b","peerURLs":["http://127.0.0.1:7002"],"name":"node2","clientURLs":["http://127.0.0.1:4002"]}]}`),
|
||||
},
|
||||
@@ -817,7 +817,7 @@ func TestHTTPClusterClientAutoSyncCancelContext(t *testing.T) {
|
||||
|
||||
func TestHTTPClusterClientAutoSyncFail(t *testing.T) {
|
||||
cf := newStaticHTTPClientFactory([]staticHTTPResponse{
|
||||
staticHTTPResponse{err: errors.New("fail!")},
|
||||
{err: errors.New("fail!")},
|
||||
})
|
||||
|
||||
hc := &httpClusterClient{
|
||||
@@ -839,15 +839,15 @@ func TestHTTPClusterClientAutoSyncFail(t *testing.T) {
|
||||
// it gets the exactly same member list as before.
|
||||
func TestHTTPClusterClientSyncPinEndpoint(t *testing.T) {
|
||||
cf := newStaticHTTPClientFactory([]staticHTTPResponse{
|
||||
staticHTTPResponse{
|
||||
{
|
||||
resp: http.Response{StatusCode: http.StatusOK, Header: http.Header{"Content-Type": []string{"application/json"}}},
|
||||
body: []byte(`{"members":[{"id":"2745e2525fce8fe","peerURLs":["http://127.0.0.1:7003"],"name":"node3","clientURLs":["http://127.0.0.1:4003"]},{"id":"42134f434382925","peerURLs":["http://127.0.0.1:2380","http://127.0.0.1:7001"],"name":"node1","clientURLs":["http://127.0.0.1:2379","http://127.0.0.1:4001"]},{"id":"94088180e21eb87b","peerURLs":["http://127.0.0.1:7002"],"name":"node2","clientURLs":["http://127.0.0.1:4002"]}]}`),
|
||||
},
|
||||
staticHTTPResponse{
|
||||
{
|
||||
resp: http.Response{StatusCode: http.StatusOK, Header: http.Header{"Content-Type": []string{"application/json"}}},
|
||||
body: []byte(`{"members":[{"id":"2745e2525fce8fe","peerURLs":["http://127.0.0.1:7003"],"name":"node3","clientURLs":["http://127.0.0.1:4003"]},{"id":"42134f434382925","peerURLs":["http://127.0.0.1:2380","http://127.0.0.1:7001"],"name":"node1","clientURLs":["http://127.0.0.1:2379","http://127.0.0.1:4001"]},{"id":"94088180e21eb87b","peerURLs":["http://127.0.0.1:7002"],"name":"node2","clientURLs":["http://127.0.0.1:4002"]}]}`),
|
||||
},
|
||||
staticHTTPResponse{
|
||||
{
|
||||
resp: http.Response{StatusCode: http.StatusOK, Header: http.Header{"Content-Type": []string{"application/json"}}},
|
||||
body: []byte(`{"members":[{"id":"2745e2525fce8fe","peerURLs":["http://127.0.0.1:7003"],"name":"node3","clientURLs":["http://127.0.0.1:4003"]},{"id":"42134f434382925","peerURLs":["http://127.0.0.1:2380","http://127.0.0.1:7001"],"name":"node1","clientURLs":["http://127.0.0.1:2379","http://127.0.0.1:4001"]},{"id":"94088180e21eb87b","peerURLs":["http://127.0.0.1:7002"],"name":"node2","clientURLs":["http://127.0.0.1:4002"]}]}`),
|
||||
},
|
||||
@@ -878,10 +878,10 @@ func TestHTTPClusterClientSyncPinEndpoint(t *testing.T) {
|
||||
func TestHTTPClusterClientResetFail(t *testing.T) {
|
||||
tests := [][]string{
|
||||
// need at least one endpoint
|
||||
[]string{},
|
||||
{},
|
||||
|
||||
// urls must be valid
|
||||
[]string{":"},
|
||||
{":"},
|
||||
}
|
||||
|
||||
for i, tt := range tests {
|
||||
|
||||
@@ -221,7 +221,7 @@ func TestWaitAction(t *testing.T) {
|
||||
|
||||
func TestSetAction(t *testing.T) {
|
||||
wantHeader := http.Header(map[string][]string{
|
||||
"Content-Type": []string{"application/x-www-form-urlencoded"},
|
||||
"Content-Type": {"application/x-www-form-urlencoded"},
|
||||
})
|
||||
|
||||
tests := []struct {
|
||||
@@ -412,7 +412,7 @@ func TestSetAction(t *testing.T) {
|
||||
|
||||
func TestCreateInOrderAction(t *testing.T) {
|
||||
wantHeader := http.Header(map[string][]string{
|
||||
"Content-Type": []string{"application/x-www-form-urlencoded"},
|
||||
"Content-Type": {"application/x-www-form-urlencoded"},
|
||||
})
|
||||
|
||||
tests := []struct {
|
||||
@@ -513,7 +513,7 @@ func TestCreateInOrderAction(t *testing.T) {
|
||||
|
||||
func TestDeleteAction(t *testing.T) {
|
||||
wantHeader := http.Header(map[string][]string{
|
||||
"Content-Type": []string{"application/x-www-form-urlencoded"},
|
||||
"Content-Type": {"application/x-www-form-urlencoded"},
|
||||
})
|
||||
|
||||
tests := []struct {
|
||||
@@ -1213,7 +1213,7 @@ func TestHTTPKeysAPIGetResponse(t *testing.T) {
|
||||
Node: &Node{
|
||||
Key: "/pants/foo/bar",
|
||||
Nodes: []*Node{
|
||||
&Node{Key: "/pants/foo/bar/baz", Value: "snarf", CreatedIndex: 21, ModifiedIndex: 25},
|
||||
{Key: "/pants/foo/bar/baz", Value: "snarf", CreatedIndex: 21, ModifiedIndex: 25},
|
||||
},
|
||||
CreatedIndex: uint64(19),
|
||||
ModifiedIndex: uint64(25),
|
||||
|
||||
@@ -48,8 +48,8 @@ func TestMembersAPIActionAdd(t *testing.T) {
|
||||
ep := url.URL{Scheme: "http", Host: "example.com"}
|
||||
act := &membersAPIActionAdd{
|
||||
peerURLs: types.URLs([]url.URL{
|
||||
url.URL{Scheme: "https", Host: "127.0.0.1:8081"},
|
||||
url.URL{Scheme: "http", Host: "127.0.0.1:8080"},
|
||||
{Scheme: "https", Host: "127.0.0.1:8081"},
|
||||
{Scheme: "http", Host: "127.0.0.1:8080"},
|
||||
}),
|
||||
}
|
||||
|
||||
@@ -75,8 +75,8 @@ func TestMembersAPIActionUpdate(t *testing.T) {
|
||||
act := &membersAPIActionUpdate{
|
||||
memberID: "0xabcd",
|
||||
peerURLs: types.URLs([]url.URL{
|
||||
url.URL{Scheme: "https", Host: "127.0.0.1:8081"},
|
||||
url.URL{Scheme: "http", Host: "127.0.0.1:8080"},
|
||||
{Scheme: "https", Host: "127.0.0.1:8081"},
|
||||
{Scheme: "http", Host: "127.0.0.1:8080"},
|
||||
}),
|
||||
}
|
||||
|
||||
@@ -289,8 +289,8 @@ func TestMemberCollectionUnmarshal(t *testing.T) {
|
||||
func TestMemberCreateRequestMarshal(t *testing.T) {
|
||||
req := memberCreateOrUpdateRequest{
|
||||
PeerURLs: types.URLs([]url.URL{
|
||||
url.URL{Scheme: "http", Host: "127.0.0.1:8081"},
|
||||
url.URL{Scheme: "https", Host: "127.0.0.1:8080"},
|
||||
{Scheme: "http", Host: "127.0.0.1:8081"},
|
||||
{Scheme: "https", Host: "127.0.0.1:8080"},
|
||||
}),
|
||||
}
|
||||
want := []byte(`{"peerURLs":["http://127.0.0.1:8081","https://127.0.0.1:8080"]}`)
|
||||
@@ -308,7 +308,7 @@ func TestMemberCreateRequestMarshal(t *testing.T) {
|
||||
func TestHTTPMembersAPIAddSuccess(t *testing.T) {
|
||||
wantAction := &membersAPIActionAdd{
|
||||
peerURLs: types.URLs([]url.URL{
|
||||
url.URL{Scheme: "http", Host: "127.0.0.1:7002"},
|
||||
{Scheme: "http", Host: "127.0.0.1:7002"},
|
||||
}),
|
||||
}
|
||||
|
||||
@@ -473,7 +473,7 @@ func TestHTTPMembersAPIListSuccess(t *testing.T) {
|
||||
}
|
||||
|
||||
wantResponseMembers := []Member{
|
||||
Member{
|
||||
{
|
||||
ID: "94088180e21eb87b",
|
||||
Name: "node2",
|
||||
PeerURLs: []string{"http://127.0.0.1:7002"},
|
||||
|
||||
@@ -36,40 +36,40 @@ func TestSRVDiscover(t *testing.T) {
|
||||
},
|
||||
{
|
||||
[]*net.SRV{
|
||||
&net.SRV{Target: "10.0.0.1", Port: 2480},
|
||||
&net.SRV{Target: "10.0.0.2", Port: 2480},
|
||||
&net.SRV{Target: "10.0.0.3", Port: 2480},
|
||||
{Target: "10.0.0.1", Port: 2480},
|
||||
{Target: "10.0.0.2", Port: 2480},
|
||||
{Target: "10.0.0.3", Port: 2480},
|
||||
},
|
||||
[]*net.SRV{},
|
||||
[]string{"https://10.0.0.1:2480", "https://10.0.0.2:2480", "https://10.0.0.3:2480"},
|
||||
},
|
||||
{
|
||||
[]*net.SRV{
|
||||
&net.SRV{Target: "10.0.0.1", Port: 2480},
|
||||
&net.SRV{Target: "10.0.0.2", Port: 2480},
|
||||
&net.SRV{Target: "10.0.0.3", Port: 2480},
|
||||
{Target: "10.0.0.1", Port: 2480},
|
||||
{Target: "10.0.0.2", Port: 2480},
|
||||
{Target: "10.0.0.3", Port: 2480},
|
||||
},
|
||||
[]*net.SRV{
|
||||
&net.SRV{Target: "10.0.0.1", Port: 7001},
|
||||
{Target: "10.0.0.1", Port: 7001},
|
||||
},
|
||||
[]string{"https://10.0.0.1:2480", "https://10.0.0.2:2480", "https://10.0.0.3:2480", "http://10.0.0.1:7001"},
|
||||
},
|
||||
{
|
||||
[]*net.SRV{
|
||||
&net.SRV{Target: "10.0.0.1", Port: 2480},
|
||||
&net.SRV{Target: "10.0.0.2", Port: 2480},
|
||||
&net.SRV{Target: "10.0.0.3", Port: 2480},
|
||||
{Target: "10.0.0.1", Port: 2480},
|
||||
{Target: "10.0.0.2", Port: 2480},
|
||||
{Target: "10.0.0.3", Port: 2480},
|
||||
},
|
||||
[]*net.SRV{
|
||||
&net.SRV{Target: "10.0.0.1", Port: 7001},
|
||||
{Target: "10.0.0.1", Port: 7001},
|
||||
},
|
||||
[]string{"https://10.0.0.1:2480", "https://10.0.0.2:2480", "https://10.0.0.3:2480", "http://10.0.0.1:7001"},
|
||||
},
|
||||
{
|
||||
[]*net.SRV{
|
||||
&net.SRV{Target: "a.example.com", Port: 2480},
|
||||
&net.SRV{Target: "b.example.com", Port: 2480},
|
||||
&net.SRV{Target: "c.example.com", Port: 2480},
|
||||
{Target: "a.example.com", Port: 2480},
|
||||
{Target: "b.example.com", Port: 2480},
|
||||
{Target: "c.example.com", Port: 2480},
|
||||
},
|
||||
[]*net.SRV{},
|
||||
[]string{"https://a.example.com:2480", "https://b.example.com:2480", "https://c.example.com:2480"},
|
||||
|
||||
Reference in New Issue
Block a user