Merge pull request #3356 from xiang90/travis

*: test gofmt with -s and fix reported issues
This commit is contained in:
Xiang Li 2015-08-21 18:59:51 -07:00
commit 044b23c3ca
35 changed files with 266 additions and 266 deletions

View File

@ -333,8 +333,8 @@ func TestHTTPClusterClientDo(t *testing.T) {
endpoints: []url.URL{fakeURL, fakeURL}, endpoints: []url.URL{fakeURL, fakeURL},
clientFactory: newStaticHTTPClientFactory( clientFactory: newStaticHTTPClientFactory(
[]staticHTTPResponse{ []staticHTTPResponse{
staticHTTPResponse{resp: http.Response{StatusCode: http.StatusTeapot}}, {resp: http.Response{StatusCode: http.StatusTeapot}},
staticHTTPResponse{err: fakeErr}, {err: fakeErr},
}, },
), ),
rand: rand.New(rand.NewSource(0)), rand: rand.New(rand.NewSource(0)),
@ -348,8 +348,8 @@ func TestHTTPClusterClientDo(t *testing.T) {
endpoints: []url.URL{fakeURL, fakeURL}, endpoints: []url.URL{fakeURL, fakeURL},
clientFactory: newStaticHTTPClientFactory( clientFactory: newStaticHTTPClientFactory(
[]staticHTTPResponse{ []staticHTTPResponse{
staticHTTPResponse{err: fakeErr}, {err: fakeErr},
staticHTTPResponse{resp: http.Response{StatusCode: http.StatusTeapot}}, {resp: http.Response{StatusCode: http.StatusTeapot}},
}, },
), ),
rand: rand.New(rand.NewSource(0)), rand: rand.New(rand.NewSource(0)),
@ -364,8 +364,8 @@ func TestHTTPClusterClientDo(t *testing.T) {
endpoints: []url.URL{fakeURL, fakeURL}, endpoints: []url.URL{fakeURL, fakeURL},
clientFactory: newStaticHTTPClientFactory( clientFactory: newStaticHTTPClientFactory(
[]staticHTTPResponse{ []staticHTTPResponse{
staticHTTPResponse{err: context.Canceled}, {err: context.Canceled},
staticHTTPResponse{resp: http.Response{StatusCode: http.StatusTeapot}}, {resp: http.Response{StatusCode: http.StatusTeapot}},
}, },
), ),
rand: rand.New(rand.NewSource(0)), rand: rand.New(rand.NewSource(0)),
@ -389,8 +389,8 @@ func TestHTTPClusterClientDo(t *testing.T) {
endpoints: []url.URL{fakeURL, fakeURL}, endpoints: []url.URL{fakeURL, fakeURL},
clientFactory: newStaticHTTPClientFactory( clientFactory: newStaticHTTPClientFactory(
[]staticHTTPResponse{ []staticHTTPResponse{
staticHTTPResponse{err: fakeErr}, {err: fakeErr},
staticHTTPResponse{err: fakeErr}, {err: fakeErr},
}, },
), ),
rand: rand.New(rand.NewSource(0)), rand: rand.New(rand.NewSource(0)),
@ -404,8 +404,8 @@ func TestHTTPClusterClientDo(t *testing.T) {
endpoints: []url.URL{fakeURL, fakeURL}, endpoints: []url.URL{fakeURL, fakeURL},
clientFactory: newStaticHTTPClientFactory( clientFactory: newStaticHTTPClientFactory(
[]staticHTTPResponse{ []staticHTTPResponse{
staticHTTPResponse{resp: http.Response{StatusCode: http.StatusBadGateway}}, {resp: http.Response{StatusCode: http.StatusBadGateway}},
staticHTTPResponse{resp: http.Response{StatusCode: http.StatusTeapot}}, {resp: http.Response{StatusCode: http.StatusTeapot}},
}, },
), ),
rand: rand.New(rand.NewSource(0)), rand: rand.New(rand.NewSource(0)),
@ -513,7 +513,7 @@ func TestRedirectFollowingHTTPClient(t *testing.T) {
checkRedirect: func(int) error { return ErrTooManyRedirects }, checkRedirect: func(int) error { return ErrTooManyRedirects },
client: &multiStaticHTTPClient{ client: &multiStaticHTTPClient{
responses: []staticHTTPResponse{ responses: []staticHTTPResponse{
staticHTTPResponse{ {
err: errors.New("fail!"), err: errors.New("fail!"),
}, },
}, },
@ -526,7 +526,7 @@ func TestRedirectFollowingHTTPClient(t *testing.T) {
checkRedirect: func(int) error { return ErrTooManyRedirects }, checkRedirect: func(int) error { return ErrTooManyRedirects },
client: &multiStaticHTTPClient{ client: &multiStaticHTTPClient{
responses: []staticHTTPResponse{ responses: []staticHTTPResponse{
staticHTTPResponse{ {
resp: http.Response{ resp: http.Response{
StatusCode: http.StatusTeapot, StatusCode: http.StatusTeapot,
}, },
@ -546,13 +546,13 @@ func TestRedirectFollowingHTTPClient(t *testing.T) {
}, },
client: &multiStaticHTTPClient{ client: &multiStaticHTTPClient{
responses: []staticHTTPResponse{ responses: []staticHTTPResponse{
staticHTTPResponse{ {
resp: http.Response{ resp: http.Response{
StatusCode: http.StatusTemporaryRedirect, StatusCode: http.StatusTemporaryRedirect,
Header: http.Header{"Location": []string{"http://example.com"}}, Header: http.Header{"Location": []string{"http://example.com"}},
}, },
}, },
staticHTTPResponse{ {
resp: http.Response{ resp: http.Response{
StatusCode: http.StatusTeapot, StatusCode: http.StatusTeapot,
}, },
@ -572,19 +572,19 @@ func TestRedirectFollowingHTTPClient(t *testing.T) {
}, },
client: &multiStaticHTTPClient{ client: &multiStaticHTTPClient{
responses: []staticHTTPResponse{ responses: []staticHTTPResponse{
staticHTTPResponse{ {
resp: http.Response{ resp: http.Response{
StatusCode: http.StatusTemporaryRedirect, StatusCode: http.StatusTemporaryRedirect,
Header: http.Header{"Location": []string{"http://example.com"}}, Header: http.Header{"Location": []string{"http://example.com"}},
}, },
}, },
staticHTTPResponse{ {
resp: http.Response{ resp: http.Response{
StatusCode: http.StatusTemporaryRedirect, StatusCode: http.StatusTemporaryRedirect,
Header: http.Header{"Location": []string{"http://example.com"}}, Header: http.Header{"Location": []string{"http://example.com"}},
}, },
}, },
staticHTTPResponse{ {
resp: http.Response{ resp: http.Response{
StatusCode: http.StatusTeapot, StatusCode: http.StatusTeapot,
}, },
@ -604,19 +604,19 @@ func TestRedirectFollowingHTTPClient(t *testing.T) {
}, },
client: &multiStaticHTTPClient{ client: &multiStaticHTTPClient{
responses: []staticHTTPResponse{ responses: []staticHTTPResponse{
staticHTTPResponse{ {
resp: http.Response{ resp: http.Response{
StatusCode: http.StatusTemporaryRedirect, StatusCode: http.StatusTemporaryRedirect,
Header: http.Header{"Location": []string{"http://example.com"}}, Header: http.Header{"Location": []string{"http://example.com"}},
}, },
}, },
staticHTTPResponse{ {
resp: http.Response{ resp: http.Response{
StatusCode: http.StatusTemporaryRedirect, StatusCode: http.StatusTemporaryRedirect,
Header: http.Header{"Location": []string{"http://example.com"}}, Header: http.Header{"Location": []string{"http://example.com"}},
}, },
}, },
staticHTTPResponse{ {
resp: http.Response{ resp: http.Response{
StatusCode: http.StatusTeapot, StatusCode: http.StatusTeapot,
}, },
@ -631,7 +631,7 @@ func TestRedirectFollowingHTTPClient(t *testing.T) {
checkRedirect: func(int) error { return ErrTooManyRedirects }, checkRedirect: func(int) error { return ErrTooManyRedirects },
client: &multiStaticHTTPClient{ client: &multiStaticHTTPClient{
responses: []staticHTTPResponse{ responses: []staticHTTPResponse{
staticHTTPResponse{ {
resp: http.Response{ resp: http.Response{
StatusCode: http.StatusTemporaryRedirect, StatusCode: http.StatusTemporaryRedirect,
}, },
@ -646,7 +646,7 @@ func TestRedirectFollowingHTTPClient(t *testing.T) {
checkRedirect: func(int) error { return ErrTooManyRedirects }, checkRedirect: func(int) error { return ErrTooManyRedirects },
client: &multiStaticHTTPClient{ client: &multiStaticHTTPClient{
responses: []staticHTTPResponse{ responses: []staticHTTPResponse{
staticHTTPResponse{ {
resp: http.Response{ resp: http.Response{
StatusCode: http.StatusTemporaryRedirect, StatusCode: http.StatusTemporaryRedirect,
Header: http.Header{"Location": []string{":"}}, Header: http.Header{"Location": []string{":"}},
@ -714,7 +714,7 @@ func TestDefaultCheckRedirect(t *testing.T) {
func TestHTTPClusterClientSync(t *testing.T) { func TestHTTPClusterClientSync(t *testing.T) {
cf := newStaticHTTPClientFactory([]staticHTTPResponse{ cf := newStaticHTTPClientFactory([]staticHTTPResponse{
staticHTTPResponse{ {
resp: http.Response{StatusCode: http.StatusOK, Header: http.Header{"Content-Type": []string{"application/json"}}}, 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"]}]}`), 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) { func TestHTTPClusterClientSyncFail(t *testing.T) {
cf := newStaticHTTPClientFactory([]staticHTTPResponse{ cf := newStaticHTTPClientFactory([]staticHTTPResponse{
staticHTTPResponse{err: errors.New("fail!")}, {err: errors.New("fail!")},
}) })
hc := &httpClusterClient{ hc := &httpClusterClient{
@ -792,7 +792,7 @@ func TestHTTPClusterClientSyncFail(t *testing.T) {
func TestHTTPClusterClientAutoSyncCancelContext(t *testing.T) { func TestHTTPClusterClientAutoSyncCancelContext(t *testing.T) {
cf := newStaticHTTPClientFactory([]staticHTTPResponse{ cf := newStaticHTTPClientFactory([]staticHTTPResponse{
staticHTTPResponse{ {
resp: http.Response{StatusCode: http.StatusOK, Header: http.Header{"Content-Type": []string{"application/json"}}}, 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"]}]}`), 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) { func TestHTTPClusterClientAutoSyncFail(t *testing.T) {
cf := newStaticHTTPClientFactory([]staticHTTPResponse{ cf := newStaticHTTPClientFactory([]staticHTTPResponse{
staticHTTPResponse{err: errors.New("fail!")}, {err: errors.New("fail!")},
}) })
hc := &httpClusterClient{ hc := &httpClusterClient{
@ -839,15 +839,15 @@ func TestHTTPClusterClientAutoSyncFail(t *testing.T) {
// it gets the exactly same member list as before. // it gets the exactly same member list as before.
func TestHTTPClusterClientSyncPinEndpoint(t *testing.T) { func TestHTTPClusterClientSyncPinEndpoint(t *testing.T) {
cf := newStaticHTTPClientFactory([]staticHTTPResponse{ cf := newStaticHTTPClientFactory([]staticHTTPResponse{
staticHTTPResponse{ {
resp: http.Response{StatusCode: http.StatusOK, Header: http.Header{"Content-Type": []string{"application/json"}}}, 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"]}]}`), 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"}}}, 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"]}]}`), 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"}}}, 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"]}]}`), 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) { func TestHTTPClusterClientResetFail(t *testing.T) {
tests := [][]string{ tests := [][]string{
// need at least one endpoint // need at least one endpoint
[]string{}, {},
// urls must be valid // urls must be valid
[]string{":"}, {":"},
} }
for i, tt := range tests { for i, tt := range tests {

View File

@ -221,7 +221,7 @@ func TestWaitAction(t *testing.T) {
func TestSetAction(t *testing.T) { func TestSetAction(t *testing.T) {
wantHeader := http.Header(map[string][]string{ wantHeader := http.Header(map[string][]string{
"Content-Type": []string{"application/x-www-form-urlencoded"}, "Content-Type": {"application/x-www-form-urlencoded"},
}) })
tests := []struct { tests := []struct {
@ -412,7 +412,7 @@ func TestSetAction(t *testing.T) {
func TestCreateInOrderAction(t *testing.T) { func TestCreateInOrderAction(t *testing.T) {
wantHeader := http.Header(map[string][]string{ wantHeader := http.Header(map[string][]string{
"Content-Type": []string{"application/x-www-form-urlencoded"}, "Content-Type": {"application/x-www-form-urlencoded"},
}) })
tests := []struct { tests := []struct {
@ -513,7 +513,7 @@ func TestCreateInOrderAction(t *testing.T) {
func TestDeleteAction(t *testing.T) { func TestDeleteAction(t *testing.T) {
wantHeader := http.Header(map[string][]string{ wantHeader := http.Header(map[string][]string{
"Content-Type": []string{"application/x-www-form-urlencoded"}, "Content-Type": {"application/x-www-form-urlencoded"},
}) })
tests := []struct { tests := []struct {
@ -1213,7 +1213,7 @@ func TestHTTPKeysAPIGetResponse(t *testing.T) {
Node: &Node{ Node: &Node{
Key: "/pants/foo/bar", Key: "/pants/foo/bar",
Nodes: []*Node{ 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), CreatedIndex: uint64(19),
ModifiedIndex: uint64(25), ModifiedIndex: uint64(25),

View File

@ -48,8 +48,8 @@ func TestMembersAPIActionAdd(t *testing.T) {
ep := url.URL{Scheme: "http", Host: "example.com"} ep := url.URL{Scheme: "http", Host: "example.com"}
act := &membersAPIActionAdd{ act := &membersAPIActionAdd{
peerURLs: types.URLs([]url.URL{ peerURLs: types.URLs([]url.URL{
url.URL{Scheme: "https", Host: "127.0.0.1:8081"}, {Scheme: "https", Host: "127.0.0.1:8081"},
url.URL{Scheme: "http", Host: "127.0.0.1:8080"}, {Scheme: "http", Host: "127.0.0.1:8080"},
}), }),
} }
@ -75,8 +75,8 @@ func TestMembersAPIActionUpdate(t *testing.T) {
act := &membersAPIActionUpdate{ act := &membersAPIActionUpdate{
memberID: "0xabcd", memberID: "0xabcd",
peerURLs: types.URLs([]url.URL{ peerURLs: types.URLs([]url.URL{
url.URL{Scheme: "https", Host: "127.0.0.1:8081"}, {Scheme: "https", Host: "127.0.0.1:8081"},
url.URL{Scheme: "http", Host: "127.0.0.1:8080"}, {Scheme: "http", Host: "127.0.0.1:8080"},
}), }),
} }
@ -289,8 +289,8 @@ func TestMemberCollectionUnmarshal(t *testing.T) {
func TestMemberCreateRequestMarshal(t *testing.T) { func TestMemberCreateRequestMarshal(t *testing.T) {
req := memberCreateOrUpdateRequest{ req := memberCreateOrUpdateRequest{
PeerURLs: types.URLs([]url.URL{ PeerURLs: types.URLs([]url.URL{
url.URL{Scheme: "http", Host: "127.0.0.1:8081"}, {Scheme: "http", Host: "127.0.0.1:8081"},
url.URL{Scheme: "https", Host: "127.0.0.1:8080"}, {Scheme: "https", Host: "127.0.0.1:8080"},
}), }),
} }
want := []byte(`{"peerURLs":["http://127.0.0.1:8081","https://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) { func TestHTTPMembersAPIAddSuccess(t *testing.T) {
wantAction := &membersAPIActionAdd{ wantAction := &membersAPIActionAdd{
peerURLs: types.URLs([]url.URL{ 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{ wantResponseMembers := []Member{
Member{ {
ID: "94088180e21eb87b", ID: "94088180e21eb87b",
Name: "node2", Name: "node2",
PeerURLs: []string{"http://127.0.0.1:7002"}, PeerURLs: []string{"http://127.0.0.1:7002"},

View File

@ -36,40 +36,40 @@ func TestSRVDiscover(t *testing.T) {
}, },
{ {
[]*net.SRV{ []*net.SRV{
&net.SRV{Target: "10.0.0.1", Port: 2480}, {Target: "10.0.0.1", Port: 2480},
&net.SRV{Target: "10.0.0.2", Port: 2480}, {Target: "10.0.0.2", Port: 2480},
&net.SRV{Target: "10.0.0.3", Port: 2480}, {Target: "10.0.0.3", Port: 2480},
}, },
[]*net.SRV{}, []*net.SRV{},
[]string{"https://10.0.0.1:2480", "https://10.0.0.2:2480", "https://10.0.0.3:2480"}, []string{"https://10.0.0.1:2480", "https://10.0.0.2:2480", "https://10.0.0.3:2480"},
}, },
{ {
[]*net.SRV{ []*net.SRV{
&net.SRV{Target: "10.0.0.1", Port: 2480}, {Target: "10.0.0.1", Port: 2480},
&net.SRV{Target: "10.0.0.2", Port: 2480}, {Target: "10.0.0.2", Port: 2480},
&net.SRV{Target: "10.0.0.3", Port: 2480}, {Target: "10.0.0.3", Port: 2480},
}, },
[]*net.SRV{ []*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"}, []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{
&net.SRV{Target: "10.0.0.1", Port: 2480}, {Target: "10.0.0.1", Port: 2480},
&net.SRV{Target: "10.0.0.2", Port: 2480}, {Target: "10.0.0.2", Port: 2480},
&net.SRV{Target: "10.0.0.3", Port: 2480}, {Target: "10.0.0.3", Port: 2480},
}, },
[]*net.SRV{ []*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"}, []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{
&net.SRV{Target: "a.example.com", Port: 2480}, {Target: "a.example.com", Port: 2480},
&net.SRV{Target: "b.example.com", Port: 2480}, {Target: "b.example.com", Port: 2480},
&net.SRV{Target: "c.example.com", Port: 2480}, {Target: "c.example.com", Port: 2480},
}, },
[]*net.SRV{}, []*net.SRV{},
[]string{"https://a.example.com:2480", "https://b.example.com:2480", "https://c.example.com:2480"}, []string{"https://a.example.com:2480", "https://b.example.com:2480", "https://c.example.com:2480"},

View File

@ -47,9 +47,9 @@ func TestSRVGetCluster(t *testing.T) {
}, },
{ {
[]*net.SRV{ []*net.SRV{
&net.SRV{Target: "10.0.0.1", Port: 2480}, {Target: "10.0.0.1", Port: 2480},
&net.SRV{Target: "10.0.0.2", Port: 2480}, {Target: "10.0.0.2", Port: 2480},
&net.SRV{Target: "10.0.0.3", Port: 2480}, {Target: "10.0.0.3", Port: 2480},
}, },
[]*net.SRV{}, []*net.SRV{},
nil, nil,
@ -59,12 +59,12 @@ func TestSRVGetCluster(t *testing.T) {
}, },
{ {
[]*net.SRV{ []*net.SRV{
&net.SRV{Target: "10.0.0.1", Port: 2480}, {Target: "10.0.0.1", Port: 2480},
&net.SRV{Target: "10.0.0.2", Port: 2480}, {Target: "10.0.0.2", Port: 2480},
&net.SRV{Target: "10.0.0.3", Port: 2480}, {Target: "10.0.0.3", Port: 2480},
}, },
[]*net.SRV{ []*net.SRV{
&net.SRV{Target: "10.0.0.1", Port: 2380}, {Target: "10.0.0.1", Port: 2380},
}, },
nil, nil,
nil, nil,
@ -72,12 +72,12 @@ func TestSRVGetCluster(t *testing.T) {
}, },
{ {
[]*net.SRV{ []*net.SRV{
&net.SRV{Target: "10.0.0.1", Port: 2480}, {Target: "10.0.0.1", Port: 2480},
&net.SRV{Target: "10.0.0.2", Port: 2480}, {Target: "10.0.0.2", Port: 2480},
&net.SRV{Target: "10.0.0.3", Port: 2480}, {Target: "10.0.0.3", Port: 2480},
}, },
[]*net.SRV{ []*net.SRV{
&net.SRV{Target: "10.0.0.1", Port: 2380}, {Target: "10.0.0.1", Port: 2380},
}, },
[]string{"https://10.0.0.1:2480"}, []string{"https://10.0.0.1:2480"},
nil, nil,
@ -86,9 +86,9 @@ func TestSRVGetCluster(t *testing.T) {
// matching local member with resolved addr and return unresolved hostnames // matching local member with resolved addr and return unresolved hostnames
{ {
[]*net.SRV{ []*net.SRV{
&net.SRV{Target: "1.example.com.", Port: 2480}, {Target: "1.example.com.", Port: 2480},
&net.SRV{Target: "2.example.com.", Port: 2480}, {Target: "2.example.com.", Port: 2480},
&net.SRV{Target: "3.example.com.", Port: 2480}, {Target: "3.example.com.", Port: 2480},
}, },
nil, nil,
[]string{"https://10.0.0.1:2480"}, []string{"https://10.0.0.1:2480"},

View File

@ -23,7 +23,7 @@ import (
) )
func TestErrorWriteTo(t *testing.T) { func TestErrorWriteTo(t *testing.T) {
for k, _ := range errors { for k := range errors {
err := NewError(k, "", 1) err := NewError(k, "", 1)
rr := httptest.NewRecorder() rr := httptest.NewRecorder()
err.WriteTo(rr) err.WriteTo(rr)
@ -38,8 +38,8 @@ func TestErrorWriteTo(t *testing.T) {
} }
wheader := http.Header(map[string][]string{ wheader := http.Header(map[string][]string{
"Content-Type": []string{"application/json"}, "Content-Type": {"application/json"},
"X-Etcd-Index": []string{"1"}, "X-Etcd-Index": {"1"},
}) })
if !reflect.DeepEqual(wheader, rr.HeaderMap) { if !reflect.DeepEqual(wheader, rr.HeaderMap) {

View File

@ -29,12 +29,12 @@ func NewAuthCommands() cli.Command {
Name: "auth", Name: "auth",
Usage: "overall auth controls", Usage: "overall auth controls",
Subcommands: []cli.Command{ Subcommands: []cli.Command{
cli.Command{ {
Name: "enable", Name: "enable",
Usage: "enable auth access controls", Usage: "enable auth access controls",
Action: actionAuthEnable, Action: actionAuthEnable,
}, },
cli.Command{ {
Name: "disable", Name: "disable",
Usage: "disable auth access controls", Usage: "disable auth access controls",
Action: actionAuthDisable, Action: actionAuthDisable,

View File

@ -29,22 +29,22 @@ func NewMemberCommand() cli.Command {
Name: "member", Name: "member",
Usage: "member add, remove and list subcommands", Usage: "member add, remove and list subcommands",
Subcommands: []cli.Command{ Subcommands: []cli.Command{
cli.Command{ {
Name: "list", Name: "list",
Usage: "enumerate existing cluster members", Usage: "enumerate existing cluster members",
Action: actionMemberList, Action: actionMemberList,
}, },
cli.Command{ {
Name: "add", Name: "add",
Usage: "add a new member to the etcd cluster", Usage: "add a new member to the etcd cluster",
Action: actionMemberAdd, Action: actionMemberAdd,
}, },
cli.Command{ {
Name: "remove", Name: "remove",
Usage: "remove an existing member from the etcd cluster", Usage: "remove an existing member from the etcd cluster",
Action: actionMemberRemove, Action: actionMemberRemove,
}, },
cli.Command{ {
Name: "update", Name: "update",
Usage: "update an existing member in the etcd cluster", Usage: "update an existing member in the etcd cluster",
Action: actionMemberUpdate, Action: actionMemberUpdate,

View File

@ -31,27 +31,27 @@ func NewRoleCommands() cli.Command {
Name: "role", Name: "role",
Usage: "role add, grant and revoke subcommands", Usage: "role add, grant and revoke subcommands",
Subcommands: []cli.Command{ Subcommands: []cli.Command{
cli.Command{ {
Name: "add", Name: "add",
Usage: "add a new role for the etcd cluster", Usage: "add a new role for the etcd cluster",
Action: actionRoleAdd, Action: actionRoleAdd,
}, },
cli.Command{ {
Name: "get", Name: "get",
Usage: "get details for a role", Usage: "get details for a role",
Action: actionRoleGet, Action: actionRoleGet,
}, },
cli.Command{ {
Name: "list", Name: "list",
Usage: "list all roles", Usage: "list all roles",
Action: actionRoleList, Action: actionRoleList,
}, },
cli.Command{ {
Name: "remove", Name: "remove",
Usage: "remove a role from the etcd cluster", Usage: "remove a role from the etcd cluster",
Action: actionRoleRemove, Action: actionRoleRemove,
}, },
cli.Command{ {
Name: "grant", Name: "grant",
Usage: "grant path matches to an etcd role", Usage: "grant path matches to an etcd role",
Flags: []cli.Flag{ Flags: []cli.Flag{
@ -62,7 +62,7 @@ func NewRoleCommands() cli.Command {
}, },
Action: actionRoleGrant, Action: actionRoleGrant,
}, },
cli.Command{ {
Name: "revoke", Name: "revoke",
Usage: "revoke path matches for an etcd role", Usage: "revoke path matches for an etcd role",
Flags: []cli.Flag{ Flags: []cli.Flag{

View File

@ -32,39 +32,39 @@ func NewUserCommands() cli.Command {
Name: "user", Name: "user",
Usage: "user add, grant and revoke subcommands", Usage: "user add, grant and revoke subcommands",
Subcommands: []cli.Command{ Subcommands: []cli.Command{
cli.Command{ {
Name: "add", Name: "add",
Usage: "add a new user for the etcd cluster", Usage: "add a new user for the etcd cluster",
Action: actionUserAdd, Action: actionUserAdd,
}, },
cli.Command{ {
Name: "get", Name: "get",
Usage: "get details for a user", Usage: "get details for a user",
Action: actionUserGet, Action: actionUserGet,
}, },
cli.Command{ {
Name: "list", Name: "list",
Usage: "list all current users", Usage: "list all current users",
Action: actionUserList, Action: actionUserList,
}, },
cli.Command{ {
Name: "remove", Name: "remove",
Usage: "remove a user for the etcd cluster", Usage: "remove a user for the etcd cluster",
Action: actionUserRemove, Action: actionUserRemove,
}, },
cli.Command{ {
Name: "grant", Name: "grant",
Usage: "grant roles to an etcd user", Usage: "grant roles to an etcd user",
Flags: []cli.Flag{cli.StringSliceFlag{Name: "roles", Value: new(cli.StringSlice), Usage: "List of roles to grant or revoke"}}, Flags: []cli.Flag{cli.StringSliceFlag{Name: "roles", Value: new(cli.StringSlice), Usage: "List of roles to grant or revoke"}},
Action: actionUserGrant, Action: actionUserGrant,
}, },
cli.Command{ {
Name: "revoke", Name: "revoke",
Usage: "revoke roles for an etcd user", Usage: "revoke roles for an etcd user",
Flags: []cli.Flag{cli.StringSliceFlag{Name: "roles", Value: new(cli.StringSlice), Usage: "List of roles to grant or revoke"}}, Flags: []cli.Flag{cli.StringSliceFlag{Name: "roles", Value: new(cli.StringSlice), Usage: "List of roles to grant or revoke"}},
Action: actionUserRevoke, Action: actionUserRevoke,
}, },
cli.Command{ {
Name: "passwd", Name: "passwd",
Usage: "change password for a user", Usage: "change password for a user",
Action: actionUserPasswd, Action: actionUserPasswd,

View File

@ -184,19 +184,19 @@ func TestConfigParsingV1Flags(t *testing.T) {
func TestConfigParsingConflictClusteringFlags(t *testing.T) { func TestConfigParsingConflictClusteringFlags(t *testing.T) {
conflictArgs := [][]string{ conflictArgs := [][]string{
[]string{ {
"-initial-cluster=0=localhost:8000", "-initial-cluster=0=localhost:8000",
"-discovery=http://example.com/abc", "-discovery=http://example.com/abc",
}, },
[]string{ {
"-discovery-srv=example.com", "-discovery-srv=example.com",
"-discovery=http://example.com/abc", "-discovery=http://example.com/abc",
}, },
[]string{ {
"-initial-cluster=0=localhost:8000", "-initial-cluster=0=localhost:8000",
"-discovery-srv=example.com", "-discovery-srv=example.com",
}, },
[]string{ {
"-initial-cluster=0=localhost:8000", "-initial-cluster=0=localhost:8000",
"-discovery=http://example.com/abc", "-discovery=http://example.com/abc",
"-discovery-srv=example.com", "-discovery-srv=example.com",

View File

@ -196,10 +196,10 @@ func TestAllUsers(t *testing.T) {
Action: etcdstore.Get, Action: etcdstore.Get,
Node: &etcdstore.NodeExtern{ Node: &etcdstore.NodeExtern{
Nodes: etcdstore.NodeExterns([]*etcdstore.NodeExtern{ Nodes: etcdstore.NodeExterns([]*etcdstore.NodeExtern{
&etcdstore.NodeExtern{ {
Key: StorePermsPrefix + "/users/cat", Key: StorePermsPrefix + "/users/cat",
}, },
&etcdstore.NodeExtern{ {
Key: StorePermsPrefix + "/users/dog", Key: StorePermsPrefix + "/users/dog",
}, },
}), }),
@ -260,10 +260,10 @@ func TestAllRoles(t *testing.T) {
Action: etcdstore.Get, Action: etcdstore.Get,
Node: &etcdstore.NodeExtern{ Node: &etcdstore.NodeExtern{
Nodes: etcdstore.NodeExterns([]*etcdstore.NodeExtern{ Nodes: etcdstore.NodeExterns([]*etcdstore.NodeExtern{
&etcdstore.NodeExtern{ {
Key: StorePermsPrefix + "/roles/animal", Key: StorePermsPrefix + "/roles/animal",
}, },
&etcdstore.NodeExtern{ {
Key: StorePermsPrefix + "/roles/human", Key: StorePermsPrefix + "/roles/human",
}, },
}), }),

View File

@ -198,7 +198,7 @@ func (c *cluster) String() string {
} }
fmt.Fprintf(b, "Members:[%s] ", strings.Join(ms, " ")) fmt.Fprintf(b, "Members:[%s] ", strings.Join(ms, " "))
var ids []string var ids []string
for id, _ := range c.removed { for id := range c.removed {
ids = append(ids, fmt.Sprintf("%s", id)) ids = append(ids, fmt.Sprintf("%s", id))
} }
fmt.Fprintf(b, "RemovedMemberIDs:[%s]}", strings.Join(ids, " ")) fmt.Fprintf(b, "RemovedMemberIDs:[%s]}", strings.Join(ids, " "))

View File

@ -472,19 +472,19 @@ func TestClusterAddMember(t *testing.T) {
func TestClusterMembers(t *testing.T) { func TestClusterMembers(t *testing.T) {
cls := &cluster{ cls := &cluster{
members: map[types.ID]*Member{ members: map[types.ID]*Member{
1: &Member{ID: 1}, 1: {ID: 1},
20: &Member{ID: 20}, 20: {ID: 20},
100: &Member{ID: 100}, 100: {ID: 100},
5: &Member{ID: 5}, 5: {ID: 5},
50: &Member{ID: 50}, 50: {ID: 50},
}, },
} }
w := []*Member{ w := []*Member{
&Member{ID: 1}, {ID: 1},
&Member{ID: 5}, {ID: 5},
&Member{ID: 20}, {ID: 20},
&Member{ID: 50}, {ID: 50},
&Member{ID: 100}, {ID: 100},
} }
if g := cls.Members(); !reflect.DeepEqual(g, w) { if g := cls.Members(); !reflect.DeepEqual(g, w) {
t.Fatalf("Members()=%#v, want %#v", g, w) t.Fatalf("Members()=%#v, want %#v", g, w)

View File

@ -29,7 +29,7 @@ func TestDecideClusterVersion(t *testing.T) {
wdver *semver.Version wdver *semver.Version
}{ }{
{ {
map[string]*version.Versions{"a": &version.Versions{Server: "2.0.0"}}, map[string]*version.Versions{"a": {Server: "2.0.0"}},
semver.Must(semver.NewVersion("2.0.0")), semver.Must(semver.NewVersion("2.0.0")),
}, },
// unknow // unknow
@ -38,15 +38,15 @@ func TestDecideClusterVersion(t *testing.T) {
nil, nil,
}, },
{ {
map[string]*version.Versions{"a": &version.Versions{Server: "2.0.0"}, "b": &version.Versions{Server: "2.1.0"}, "c": &version.Versions{Server: "2.1.0"}}, map[string]*version.Versions{"a": {Server: "2.0.0"}, "b": {Server: "2.1.0"}, "c": {Server: "2.1.0"}},
semver.Must(semver.NewVersion("2.0.0")), semver.Must(semver.NewVersion("2.0.0")),
}, },
{ {
map[string]*version.Versions{"a": &version.Versions{Server: "2.1.0"}, "b": &version.Versions{Server: "2.1.0"}, "c": &version.Versions{Server: "2.1.0"}}, map[string]*version.Versions{"a": {Server: "2.1.0"}, "b": {Server: "2.1.0"}, "c": {Server: "2.1.0"}},
semver.Must(semver.NewVersion("2.1.0")), semver.Must(semver.NewVersion("2.1.0")),
}, },
{ {
map[string]*version.Versions{"a": nil, "b": &version.Versions{Server: "2.1.0"}, "c": &version.Versions{Server: "2.1.0"}}, map[string]*version.Versions{"a": nil, "b": {Server: "2.1.0"}, "c": {Server: "2.1.0"}},
nil, nil,
}, },
} }
@ -69,9 +69,9 @@ func TestIsCompatibleWithVers(t *testing.T) {
// too low // too low
{ {
map[string]*version.Versions{ map[string]*version.Versions{
"a": &version.Versions{Server: "2.0.0", Cluster: "not_decided"}, "a": {Server: "2.0.0", Cluster: "not_decided"},
"b": &version.Versions{Server: "2.1.0", Cluster: "2.1.0"}, "b": {Server: "2.1.0", Cluster: "2.1.0"},
"c": &version.Versions{Server: "2.1.0", Cluster: "2.1.0"}, "c": {Server: "2.1.0", Cluster: "2.1.0"},
}, },
0xa, 0xa,
semver.Must(semver.NewVersion("2.0.0")), semver.Must(semver.NewVersion("2.0.0")), semver.Must(semver.NewVersion("2.0.0")), semver.Must(semver.NewVersion("2.0.0")),
@ -79,9 +79,9 @@ func TestIsCompatibleWithVers(t *testing.T) {
}, },
{ {
map[string]*version.Versions{ map[string]*version.Versions{
"a": &version.Versions{Server: "2.1.0", Cluster: "not_decided"}, "a": {Server: "2.1.0", Cluster: "not_decided"},
"b": &version.Versions{Server: "2.1.0", Cluster: "2.1.0"}, "b": {Server: "2.1.0", Cluster: "2.1.0"},
"c": &version.Versions{Server: "2.1.0", Cluster: "2.1.0"}, "c": {Server: "2.1.0", Cluster: "2.1.0"},
}, },
0xa, 0xa,
semver.Must(semver.NewVersion("2.0.0")), semver.Must(semver.NewVersion("2.1.0")), semver.Must(semver.NewVersion("2.0.0")), semver.Must(semver.NewVersion("2.1.0")),
@ -90,9 +90,9 @@ func TestIsCompatibleWithVers(t *testing.T) {
// too high // too high
{ {
map[string]*version.Versions{ map[string]*version.Versions{
"a": &version.Versions{Server: "2.2.0", Cluster: "not_decided"}, "a": {Server: "2.2.0", Cluster: "not_decided"},
"b": &version.Versions{Server: "2.0.0", Cluster: "2.0.0"}, "b": {Server: "2.0.0", Cluster: "2.0.0"},
"c": &version.Versions{Server: "2.0.0", Cluster: "2.0.0"}, "c": {Server: "2.0.0", Cluster: "2.0.0"},
}, },
0xa, 0xa,
semver.Must(semver.NewVersion("2.1.0")), semver.Must(semver.NewVersion("2.2.0")), semver.Must(semver.NewVersion("2.1.0")), semver.Must(semver.NewVersion("2.2.0")),
@ -101,9 +101,9 @@ func TestIsCompatibleWithVers(t *testing.T) {
// cannot get b's version, expect ok // cannot get b's version, expect ok
{ {
map[string]*version.Versions{ map[string]*version.Versions{
"a": &version.Versions{Server: "2.1.0", Cluster: "not_decided"}, "a": {Server: "2.1.0", Cluster: "not_decided"},
"b": nil, "b": nil,
"c": &version.Versions{Server: "2.1.0", Cluster: "2.1.0"}, "c": {Server: "2.1.0", Cluster: "2.1.0"},
}, },
0xa, 0xa,
semver.Must(semver.NewVersion("2.0.0")), semver.Must(semver.NewVersion("2.1.0")), semver.Must(semver.NewVersion("2.0.0")), semver.Must(semver.NewVersion("2.1.0")),
@ -112,7 +112,7 @@ func TestIsCompatibleWithVers(t *testing.T) {
// cannot get b and c's version, expect not ok // cannot get b and c's version, expect not ok
{ {
map[string]*version.Versions{ map[string]*version.Versions{
"a": &version.Versions{Server: "2.1.0", Cluster: "not_decided"}, "a": {Server: "2.1.0", Cluster: "not_decided"},
"b": nil, "b": nil,
"c": nil, "c": nil,
}, },

View File

@ -817,7 +817,7 @@ func TestServeMembersFail(t *testing.T) {
URL: testutil.MustNewURL(t, membersPrefix), URL: testutil.MustNewURL(t, membersPrefix),
Method: "POST", Method: "POST",
Body: ioutil.NopCloser(strings.NewReader("bad json")), Body: ioutil.NopCloser(strings.NewReader("bad json")),
Header: map[string][]string{"Content-Type": []string{"application/json"}}, Header: map[string][]string{"Content-Type": {"application/json"}},
}, },
&resServer{}, &resServer{},
@ -829,7 +829,7 @@ func TestServeMembersFail(t *testing.T) {
URL: testutil.MustNewURL(t, membersPrefix), URL: testutil.MustNewURL(t, membersPrefix),
Method: "POST", Method: "POST",
Body: ioutil.NopCloser(strings.NewReader(`{"PeerURLs": ["http://127.0.0.1:1"]}`)), Body: ioutil.NopCloser(strings.NewReader(`{"PeerURLs": ["http://127.0.0.1:1"]}`)),
Header: map[string][]string{"Content-Type": []string{"application/bad"}}, Header: map[string][]string{"Content-Type": {"application/bad"}},
}, },
&errServer{}, &errServer{},
@ -841,7 +841,7 @@ func TestServeMembersFail(t *testing.T) {
URL: testutil.MustNewURL(t, membersPrefix), URL: testutil.MustNewURL(t, membersPrefix),
Method: "POST", Method: "POST",
Body: ioutil.NopCloser(strings.NewReader(`{"PeerURLs": ["http://a"]}`)), Body: ioutil.NopCloser(strings.NewReader(`{"PeerURLs": ["http://a"]}`)),
Header: map[string][]string{"Content-Type": []string{"application/json"}}, Header: map[string][]string{"Content-Type": {"application/json"}},
}, },
&errServer{}, &errServer{},
@ -853,7 +853,7 @@ func TestServeMembersFail(t *testing.T) {
URL: testutil.MustNewURL(t, membersPrefix), URL: testutil.MustNewURL(t, membersPrefix),
Method: "POST", Method: "POST",
Body: ioutil.NopCloser(strings.NewReader(`{"PeerURLs": ["http://127.0.0.1:1"]}`)), Body: ioutil.NopCloser(strings.NewReader(`{"PeerURLs": ["http://127.0.0.1:1"]}`)),
Header: map[string][]string{"Content-Type": []string{"application/json"}}, Header: map[string][]string{"Content-Type": {"application/json"}},
}, },
&errServer{ &errServer{
errors.New("Error while adding a member"), errors.New("Error while adding a member"),
@ -867,7 +867,7 @@ func TestServeMembersFail(t *testing.T) {
URL: testutil.MustNewURL(t, membersPrefix), URL: testutil.MustNewURL(t, membersPrefix),
Method: "POST", Method: "POST",
Body: ioutil.NopCloser(strings.NewReader(`{"PeerURLs": ["http://127.0.0.1:1"]}`)), Body: ioutil.NopCloser(strings.NewReader(`{"PeerURLs": ["http://127.0.0.1:1"]}`)),
Header: map[string][]string{"Content-Type": []string{"application/json"}}, Header: map[string][]string{"Content-Type": {"application/json"}},
}, },
&errServer{ &errServer{
etcdserver.ErrIDExists, etcdserver.ErrIDExists,
@ -881,7 +881,7 @@ func TestServeMembersFail(t *testing.T) {
URL: testutil.MustNewURL(t, membersPrefix), URL: testutil.MustNewURL(t, membersPrefix),
Method: "POST", Method: "POST",
Body: ioutil.NopCloser(strings.NewReader(`{"PeerURLs": ["http://127.0.0.1:1"]}`)), Body: ioutil.NopCloser(strings.NewReader(`{"PeerURLs": ["http://127.0.0.1:1"]}`)),
Header: map[string][]string{"Content-Type": []string{"application/json"}}, Header: map[string][]string{"Content-Type": {"application/json"}},
}, },
&errServer{ &errServer{
etcdserver.ErrPeerURLexists, etcdserver.ErrPeerURLexists,
@ -951,7 +951,7 @@ func TestServeMembersFail(t *testing.T) {
URL: testutil.MustNewURL(t, path.Join(membersPrefix, "0")), URL: testutil.MustNewURL(t, path.Join(membersPrefix, "0")),
Method: "PUT", Method: "PUT",
Body: ioutil.NopCloser(strings.NewReader("bad json")), Body: ioutil.NopCloser(strings.NewReader("bad json")),
Header: map[string][]string{"Content-Type": []string{"application/json"}}, Header: map[string][]string{"Content-Type": {"application/json"}},
}, },
&resServer{}, &resServer{},
@ -963,7 +963,7 @@ func TestServeMembersFail(t *testing.T) {
URL: testutil.MustNewURL(t, path.Join(membersPrefix, "0")), URL: testutil.MustNewURL(t, path.Join(membersPrefix, "0")),
Method: "PUT", Method: "PUT",
Body: ioutil.NopCloser(strings.NewReader(`{"PeerURLs": ["http://127.0.0.1:1"]}`)), Body: ioutil.NopCloser(strings.NewReader(`{"PeerURLs": ["http://127.0.0.1:1"]}`)),
Header: map[string][]string{"Content-Type": []string{"application/bad"}}, Header: map[string][]string{"Content-Type": {"application/bad"}},
}, },
&errServer{}, &errServer{},
@ -975,7 +975,7 @@ func TestServeMembersFail(t *testing.T) {
URL: testutil.MustNewURL(t, path.Join(membersPrefix, "0")), URL: testutil.MustNewURL(t, path.Join(membersPrefix, "0")),
Method: "PUT", Method: "PUT",
Body: ioutil.NopCloser(strings.NewReader(`{"PeerURLs": ["http://a"]}`)), Body: ioutil.NopCloser(strings.NewReader(`{"PeerURLs": ["http://a"]}`)),
Header: map[string][]string{"Content-Type": []string{"application/json"}}, Header: map[string][]string{"Content-Type": {"application/json"}},
}, },
&errServer{}, &errServer{},
@ -987,7 +987,7 @@ func TestServeMembersFail(t *testing.T) {
URL: testutil.MustNewURL(t, path.Join(membersPrefix, "0")), URL: testutil.MustNewURL(t, path.Join(membersPrefix, "0")),
Method: "PUT", Method: "PUT",
Body: ioutil.NopCloser(strings.NewReader(`{"PeerURLs": ["http://127.0.0.1:1"]}`)), Body: ioutil.NopCloser(strings.NewReader(`{"PeerURLs": ["http://127.0.0.1:1"]}`)),
Header: map[string][]string{"Content-Type": []string{"application/json"}}, Header: map[string][]string{"Content-Type": {"application/json"}},
}, },
&errServer{ &errServer{
errors.New("blah"), errors.New("blah"),
@ -1001,7 +1001,7 @@ func TestServeMembersFail(t *testing.T) {
URL: testutil.MustNewURL(t, path.Join(membersPrefix, "0")), URL: testutil.MustNewURL(t, path.Join(membersPrefix, "0")),
Method: "PUT", Method: "PUT",
Body: ioutil.NopCloser(strings.NewReader(`{"PeerURLs": ["http://127.0.0.1:1"]}`)), Body: ioutil.NopCloser(strings.NewReader(`{"PeerURLs": ["http://127.0.0.1:1"]}`)),
Header: map[string][]string{"Content-Type": []string{"application/json"}}, Header: map[string][]string{"Content-Type": {"application/json"}},
}, },
&errServer{ &errServer{
etcdserver.ErrPeerURLexists, etcdserver.ErrPeerURLexists,
@ -1015,7 +1015,7 @@ func TestServeMembersFail(t *testing.T) {
URL: testutil.MustNewURL(t, path.Join(membersPrefix, "0")), URL: testutil.MustNewURL(t, path.Join(membersPrefix, "0")),
Method: "PUT", Method: "PUT",
Body: ioutil.NopCloser(strings.NewReader(`{"PeerURLs": ["http://127.0.0.1:1"]}`)), Body: ioutil.NopCloser(strings.NewReader(`{"PeerURLs": ["http://127.0.0.1:1"]}`)),
Header: map[string][]string{"Content-Type": []string{"application/json"}}, Header: map[string][]string{"Content-Type": {"application/json"}},
}, },
&errServer{ &errServer{
etcdserver.ErrIDNotFound, etcdserver.ErrIDNotFound,
@ -1918,12 +1918,12 @@ func TestTrimPrefix(t *testing.T) {
func TestNewMemberCollection(t *testing.T) { func TestNewMemberCollection(t *testing.T) {
fixture := []*etcdserver.Member{ fixture := []*etcdserver.Member{
&etcdserver.Member{ {
ID: 12, ID: 12,
Attributes: etcdserver.Attributes{ClientURLs: []string{"http://localhost:8080", "http://localhost:8081"}}, Attributes: etcdserver.Attributes{ClientURLs: []string{"http://localhost:8080", "http://localhost:8081"}},
RaftAttributes: etcdserver.RaftAttributes{PeerURLs: []string{"http://localhost:8082", "http://localhost:8083"}}, RaftAttributes: etcdserver.RaftAttributes{PeerURLs: []string{"http://localhost:8082", "http://localhost:8083"}},
}, },
&etcdserver.Member{ {
ID: 13, ID: 13,
Attributes: etcdserver.Attributes{ClientURLs: []string{"http://localhost:9090", "http://localhost:9091"}}, Attributes: etcdserver.Attributes{ClientURLs: []string{"http://localhost:9090", "http://localhost:9091"}},
RaftAttributes: etcdserver.RaftAttributes{PeerURLs: []string{"http://localhost:9092", "http://localhost:9093"}}, RaftAttributes: etcdserver.RaftAttributes{PeerURLs: []string{"http://localhost:9092", "http://localhost:9093"}},
@ -1932,12 +1932,12 @@ func TestNewMemberCollection(t *testing.T) {
got := newMemberCollection(fixture) got := newMemberCollection(fixture)
want := httptypes.MemberCollection([]httptypes.Member{ want := httptypes.MemberCollection([]httptypes.Member{
httptypes.Member{ {
ID: "c", ID: "c",
ClientURLs: []string{"http://localhost:8080", "http://localhost:8081"}, ClientURLs: []string{"http://localhost:8080", "http://localhost:8081"},
PeerURLs: []string{"http://localhost:8082", "http://localhost:8083"}, PeerURLs: []string{"http://localhost:8082", "http://localhost:8083"},
}, },
httptypes.Member{ {
ID: "d", ID: "d",
ClientURLs: []string{"http://localhost:9090", "http://localhost:9091"}, ClientURLs: []string{"http://localhost:9090", "http://localhost:9091"},
PeerURLs: []string{"http://localhost:9092", "http://localhost:9093"}, PeerURLs: []string{"http://localhost:9092", "http://localhost:9093"},

View File

@ -28,7 +28,7 @@ func TestHTTPErrorWriteTo(t *testing.T) {
wcode := http.StatusBadRequest wcode := http.StatusBadRequest
wheader := http.Header(map[string][]string{ wheader := http.Header(map[string][]string{
"Content-Type": []string{"application/json"}, "Content-Type": {"application/json"},
}) })
wbody := `{"message":"what a bad request you made!"}` wbody := `{"message":"what a bad request you made!"}`

View File

@ -97,8 +97,8 @@ func TestMemberCreateRequestUnmarshal(t *testing.T) {
body := []byte(`{"peerURLs": ["http://127.0.0.1:8081", "https://127.0.0.1:8080"]}`) body := []byte(`{"peerURLs": ["http://127.0.0.1:8081", "https://127.0.0.1:8080"]}`)
want := MemberCreateRequest{ want := MemberCreateRequest{
PeerURLs: types.URLs([]url.URL{ PeerURLs: types.URLs([]url.URL{
url.URL{Scheme: "http", Host: "127.0.0.1:8081"}, {Scheme: "http", Host: "127.0.0.1:8081"},
url.URL{Scheme: "https", Host: "127.0.0.1:8080"}, {Scheme: "https", Host: "127.0.0.1:8080"},
}), }),
} }

View File

@ -722,7 +722,7 @@ func (s *EtcdServer) publish(timeout time.Duration) {
} }
func (s *EtcdServer) send(ms []raftpb.Message) { func (s *EtcdServer) send(ms []raftpb.Message) {
for i, _ := range ms { for i := range ms {
if s.cluster.IsIDRemoved(types.ID(ms[i].To)) { if s.cluster.IsIDRemoved(types.ID(ms[i].To)) {
ms[i].To = 0 ms[i].To = 0
} }

View File

@ -509,10 +509,10 @@ func TestApplyConfChangeShouldStop(t *testing.T) {
func TestDoProposal(t *testing.T) { func TestDoProposal(t *testing.T) {
tests := []pb.Request{ tests := []pb.Request{
pb.Request{Method: "POST", ID: 1}, {Method: "POST", ID: 1},
pb.Request{Method: "PUT", ID: 1}, {Method: "PUT", ID: 1},
pb.Request{Method: "DELETE", ID: 1}, {Method: "DELETE", ID: 1},
pb.Request{Method: "GET", ID: 1, Quorum: true}, {Method: "GET", ID: 1, Quorum: true},
} }
for i, tt := range tests { for i, tt := range tests {
st := &storeRecorder{} st := &storeRecorder{}

View File

@ -417,7 +417,7 @@ func (c *cluster) Launch(t *testing.T) {
errc <- m.Launch() errc <- m.Launch()
}(m) }(m)
} }
for _ = range c.Members { for range c.Members {
if err := <-errc; err != nil { if err := <-errc; err != nil {
t.Fatalf("error setting up member: %v", err) t.Fatalf("error setting up member: %v", err)
} }

View File

@ -45,7 +45,7 @@ func (ci *CORSInfo) Set(s string) error {
func (ci *CORSInfo) String() string { func (ci *CORSInfo) String() string {
o := make([]string, 0) o := make([]string, 0)
for k, _ := range *ci { for k := range *ci {
o = append(o, k) o = append(o, k)
} }
return strings.Join(o, ",") return strings.Join(o, ",")

View File

@ -141,7 +141,7 @@ func TestURLsFromFlags(t *testing.T) {
args: []string{}, args: []string{},
tlsInfo: transport.TLSInfo{}, tlsInfo: transport.TLSInfo{},
wantURLs: []url.URL{ wantURLs: []url.URL{
url.URL{Scheme: "http", Host: "127.0.0.1:2379"}, {Scheme: "http", Host: "127.0.0.1:2379"},
}, },
wantFail: false, wantFail: false,
}, },
@ -151,8 +151,8 @@ func TestURLsFromFlags(t *testing.T) {
args: []string{"-urls=https://192.0.3.17:2930,http://127.0.0.1:1024"}, args: []string{"-urls=https://192.0.3.17:2930,http://127.0.0.1:1024"},
tlsInfo: transport.TLSInfo{}, tlsInfo: transport.TLSInfo{},
wantURLs: []url.URL{ wantURLs: []url.URL{
url.URL{Scheme: "http", Host: "127.0.0.1:1024"}, {Scheme: "http", Host: "127.0.0.1:1024"},
url.URL{Scheme: "https", Host: "192.0.3.17:2930"}, {Scheme: "https", Host: "192.0.3.17:2930"},
}, },
wantFail: false, wantFail: false,
}, },
@ -162,7 +162,7 @@ func TestURLsFromFlags(t *testing.T) {
args: []string{"-addr=192.0.2.3:1024"}, args: []string{"-addr=192.0.2.3:1024"},
tlsInfo: transport.TLSInfo{}, tlsInfo: transport.TLSInfo{},
wantURLs: []url.URL{ wantURLs: []url.URL{
url.URL{Scheme: "http", Host: "192.0.2.3:1024"}, {Scheme: "http", Host: "192.0.2.3:1024"},
}, },
wantFail: false, wantFail: false,
}, },
@ -175,7 +175,7 @@ func TestURLsFromFlags(t *testing.T) {
KeyFile: "/tmp/bar", KeyFile: "/tmp/bar",
}, },
wantURLs: []url.URL{ wantURLs: []url.URL{
url.URL{Scheme: "https", Host: "192.0.2.3:1024"}, {Scheme: "https", Host: "192.0.2.3:1024"},
}, },
wantFail: false, wantFail: false,
}, },

View File

@ -33,45 +33,45 @@ func TestResolveTCPAddrs(t *testing.T) {
}{ }{
{ {
urls: [][]url.URL{ urls: [][]url.URL{
[]url.URL{ {
url.URL{Scheme: "http", Host: "127.0.0.1:4001"}, {Scheme: "http", Host: "127.0.0.1:4001"},
url.URL{Scheme: "http", Host: "127.0.0.1:2379"}, {Scheme: "http", Host: "127.0.0.1:2379"},
}, },
[]url.URL{ {
url.URL{Scheme: "http", Host: "127.0.0.1:7001"}, {Scheme: "http", Host: "127.0.0.1:7001"},
url.URL{Scheme: "http", Host: "127.0.0.1:2380"}, {Scheme: "http", Host: "127.0.0.1:2380"},
}, },
}, },
expected: [][]url.URL{ expected: [][]url.URL{
[]url.URL{ {
url.URL{Scheme: "http", Host: "127.0.0.1:4001"}, {Scheme: "http", Host: "127.0.0.1:4001"},
url.URL{Scheme: "http", Host: "127.0.0.1:2379"}, {Scheme: "http", Host: "127.0.0.1:2379"},
}, },
[]url.URL{ {
url.URL{Scheme: "http", Host: "127.0.0.1:7001"}, {Scheme: "http", Host: "127.0.0.1:7001"},
url.URL{Scheme: "http", Host: "127.0.0.1:2380"}, {Scheme: "http", Host: "127.0.0.1:2380"},
}, },
}, },
}, },
{ {
urls: [][]url.URL{ urls: [][]url.URL{
[]url.URL{ {
url.URL{Scheme: "http", Host: "infra0.example.com:4001"}, {Scheme: "http", Host: "infra0.example.com:4001"},
url.URL{Scheme: "http", Host: "infra0.example.com:2379"}, {Scheme: "http", Host: "infra0.example.com:2379"},
}, },
[]url.URL{ {
url.URL{Scheme: "http", Host: "infra0.example.com:7001"}, {Scheme: "http", Host: "infra0.example.com:7001"},
url.URL{Scheme: "http", Host: "infra0.example.com:2380"}, {Scheme: "http", Host: "infra0.example.com:2380"},
}, },
}, },
expected: [][]url.URL{ expected: [][]url.URL{
[]url.URL{ {
url.URL{Scheme: "http", Host: "10.0.1.10:4001"}, {Scheme: "http", Host: "10.0.1.10:4001"},
url.URL{Scheme: "http", Host: "10.0.1.10:2379"}, {Scheme: "http", Host: "10.0.1.10:2379"},
}, },
[]url.URL{ {
url.URL{Scheme: "http", Host: "10.0.1.10:7001"}, {Scheme: "http", Host: "10.0.1.10:7001"},
url.URL{Scheme: "http", Host: "10.0.1.10:2380"}, {Scheme: "http", Host: "10.0.1.10:2380"},
}, },
}, },
hostMap: map[string]string{ hostMap: map[string]string{
@ -81,13 +81,13 @@ func TestResolveTCPAddrs(t *testing.T) {
}, },
{ {
urls: [][]url.URL{ urls: [][]url.URL{
[]url.URL{ {
url.URL{Scheme: "http", Host: "infra0.example.com:4001"}, {Scheme: "http", Host: "infra0.example.com:4001"},
url.URL{Scheme: "http", Host: "infra0.example.com:2379"}, {Scheme: "http", Host: "infra0.example.com:2379"},
}, },
[]url.URL{ {
url.URL{Scheme: "http", Host: "infra0.example.com:7001"}, {Scheme: "http", Host: "infra0.example.com:7001"},
url.URL{Scheme: "http", Host: "infra0.example.com:2380"}, {Scheme: "http", Host: "infra0.example.com:2380"},
}, },
}, },
hostMap: map[string]string{ hostMap: map[string]string{
@ -97,13 +97,13 @@ func TestResolveTCPAddrs(t *testing.T) {
}, },
{ {
urls: [][]url.URL{ urls: [][]url.URL{
[]url.URL{ {
url.URL{Scheme: "http", Host: "ssh://infra0.example.com:4001"}, {Scheme: "http", Host: "ssh://infra0.example.com:4001"},
url.URL{Scheme: "http", Host: "ssh://infra0.example.com:2379"}, {Scheme: "http", Host: "ssh://infra0.example.com:2379"},
}, },
[]url.URL{ {
url.URL{Scheme: "http", Host: "ssh://infra0.example.com:7001"}, {Scheme: "http", Host: "ssh://infra0.example.com:7001"},
url.URL{Scheme: "http", Host: "ssh://infra0.example.com:2380"}, {Scheme: "http", Host: "ssh://infra0.example.com:2380"},
}, },
}, },
hasError: true, hasError: true,

View File

@ -98,17 +98,17 @@ func TestNewTransportTLSInfo(t *testing.T) {
defer os.Remove(tmp) defer os.Remove(tmp)
tests := []TLSInfo{ tests := []TLSInfo{
TLSInfo{}, {},
TLSInfo{ {
CertFile: tmp, CertFile: tmp,
KeyFile: tmp, KeyFile: tmp,
}, },
TLSInfo{ {
CertFile: tmp, CertFile: tmp,
KeyFile: tmp, KeyFile: tmp,
CAFile: tmp, CAFile: tmp,
}, },
TLSInfo{ {
CAFile: tmp, CAFile: tmp,
}, },
} }
@ -157,10 +157,10 @@ func TestTLSInfoMissingFields(t *testing.T) {
defer os.Remove(tmp) defer os.Remove(tmp)
tests := []TLSInfo{ tests := []TLSInfo{
TLSInfo{CertFile: tmp}, {CertFile: tmp},
TLSInfo{KeyFile: tmp}, {KeyFile: tmp},
TLSInfo{CertFile: tmp, CAFile: tmp}, {CertFile: tmp, CAFile: tmp},
TLSInfo{KeyFile: tmp, CAFile: tmp}, {KeyFile: tmp, CAFile: tmp},
} }
for i, info := range tests { for i, info := range tests {

View File

@ -91,7 +91,7 @@ func (us *unsafeSet) Length() int {
// Values returns the values of the Set in an unspecified order. // Values returns the values of the Set in an unspecified order.
func (us *unsafeSet) Values() (values []string) { func (us *unsafeSet) Values() (values []string) {
values = make([]string, 0) values = make([]string, 0)
for val, _ := range us.d { for val := range us.d {
values = append(values, val) values = append(values, val)
} }
return return
@ -100,7 +100,7 @@ func (us *unsafeSet) Values() (values []string) {
// Copy creates a new Set containing the values of the first // Copy creates a new Set containing the values of the first
func (us *unsafeSet) Copy() Set { func (us *unsafeSet) Copy() Set {
cp := NewUnsafeSet() cp := NewUnsafeSet()
for val, _ := range us.d { for val := range us.d {
cp.Add(val) cp.Add(val)
} }

View File

@ -70,11 +70,11 @@ func TestNewDirectorScheme(t *testing.T) {
func TestDirectorEndpointsFiltering(t *testing.T) { func TestDirectorEndpointsFiltering(t *testing.T) {
d := director{ d := director{
ep: []*endpoint{ ep: []*endpoint{
&endpoint{ {
URL: url.URL{Scheme: "http", Host: "192.0.2.5:5050"}, URL: url.URL{Scheme: "http", Host: "192.0.2.5:5050"},
Available: false, Available: false,
}, },
&endpoint{ {
URL: url.URL{Scheme: "http", Host: "192.0.2.4:4000"}, URL: url.URL{Scheme: "http", Host: "192.0.2.4:4000"},
Available: true, Available: true,
}, },
@ -83,7 +83,7 @@ func TestDirectorEndpointsFiltering(t *testing.T) {
got := d.endpoints() got := d.endpoints()
want := []*endpoint{ want := []*endpoint{
&endpoint{ {
URL: url.URL{Scheme: "http", Host: "192.0.2.4:4000"}, URL: url.URL{Scheme: "http", Host: "192.0.2.4:4000"},
Available: true, Available: true,
}, },

View File

@ -56,19 +56,19 @@ func TestReverseProxyServe(t *testing.T) {
// error is returned from one endpoint that should be available // error is returned from one endpoint that should be available
{ {
eps: []*endpoint{&endpoint{URL: u, Available: true}}, eps: []*endpoint{{URL: u, Available: true}},
rt: &staticRoundTripper{err: errors.New("what a bad trip")}, rt: &staticRoundTripper{err: errors.New("what a bad trip")},
want: http.StatusBadGateway, want: http.StatusBadGateway,
}, },
// endpoint is available and returns success // endpoint is available and returns success
{ {
eps: []*endpoint{&endpoint{URL: u, Available: true}}, eps: []*endpoint{{URL: u, Available: true}},
rt: &staticRoundTripper{ rt: &staticRoundTripper{
res: &http.Response{ res: &http.Response{
StatusCode: http.StatusCreated, StatusCode: http.StatusCreated,
Body: ioutil.NopCloser(&bytes.Reader{}), Body: ioutil.NopCloser(&bytes.Reader{}),
Header: map[string][]string{"Content-Type": []string{"application/json"}}, Header: map[string][]string{"Content-Type": {"application/json"}},
}, },
}, },
want: http.StatusCreated, want: http.StatusCreated,
@ -171,25 +171,25 @@ func TestMaybeSetForwardedFor(t *testing.T) {
func TestRemoveSingleHopHeaders(t *testing.T) { func TestRemoveSingleHopHeaders(t *testing.T) {
hdr := http.Header(map[string][]string{ hdr := http.Header(map[string][]string{
// single-hop headers that should be removed // single-hop headers that should be removed
"Connection": []string{"close"}, "Connection": {"close"},
"Keep-Alive": []string{"foo"}, "Keep-Alive": {"foo"},
"Proxy-Authenticate": []string{"Basic realm=example.com"}, "Proxy-Authenticate": {"Basic realm=example.com"},
"Proxy-Authorization": []string{"foo"}, "Proxy-Authorization": {"foo"},
"Te": []string{"deflate,gzip"}, "Te": {"deflate,gzip"},
"Trailers": []string{"ETag"}, "Trailers": {"ETag"},
"Transfer-Encoding": []string{"chunked"}, "Transfer-Encoding": {"chunked"},
"Upgrade": []string{"WebSocket"}, "Upgrade": {"WebSocket"},
// headers that should persist // headers that should persist
"Accept": []string{"application/json"}, "Accept": {"application/json"},
"X-Foo": []string{"Bar"}, "X-Foo": {"Bar"},
}) })
removeSingleHopHeaders(&hdr) removeSingleHopHeaders(&hdr)
want := http.Header(map[string][]string{ want := http.Header(map[string][]string{
"Accept": []string{"application/json"}, "Accept": {"application/json"},
"X-Foo": []string{"Bar"}, "X-Foo": {"Bar"},
}) })
if !reflect.DeepEqual(want, hdr) { if !reflect.DeepEqual(want, hdr) {
@ -205,33 +205,33 @@ func TestCopyHeader(t *testing.T) {
}{ }{
{ {
src: http.Header(map[string][]string{ src: http.Header(map[string][]string{
"Foo": []string{"bar", "baz"}, "Foo": {"bar", "baz"},
}), }),
dst: http.Header(map[string][]string{}), dst: http.Header(map[string][]string{}),
want: http.Header(map[string][]string{ want: http.Header(map[string][]string{
"Foo": []string{"bar", "baz"}, "Foo": {"bar", "baz"},
}), }),
}, },
{ {
src: http.Header(map[string][]string{ src: http.Header(map[string][]string{
"Foo": []string{"bar"}, "Foo": {"bar"},
"Ping": []string{"pong"}, "Ping": {"pong"},
}), }),
dst: http.Header(map[string][]string{}), dst: http.Header(map[string][]string{}),
want: http.Header(map[string][]string{ want: http.Header(map[string][]string{
"Foo": []string{"bar"}, "Foo": {"bar"},
"Ping": []string{"pong"}, "Ping": {"pong"},
}), }),
}, },
{ {
src: http.Header(map[string][]string{ src: http.Header(map[string][]string{
"Foo": []string{"bar", "baz"}, "Foo": {"bar", "baz"},
}), }),
dst: http.Header(map[string][]string{ dst: http.Header(map[string][]string{
"Foo": []string{"qux"}, "Foo": {"qux"},
}), }),
want: http.Header(map[string][]string{ want: http.Header(map[string][]string{
"Foo": []string{"qux", "bar", "baz"}, "Foo": {"qux", "bar", "baz"},
}), }),
}, },
} }

View File

@ -480,7 +480,7 @@ func TestDuelingCandidates(t *testing.T) {
nt.send(pb.Message{From: 3, To: 3, Type: pb.MsgHup}) nt.send(pb.Message{From: 3, To: 3, Type: pb.MsgHup})
wlog := &raftLog{ wlog := &raftLog{
storage: &MemoryStorage{ents: []pb.Entry{{}, pb.Entry{Data: nil, Term: 1, Index: 1}}}, storage: &MemoryStorage{ents: []pb.Entry{{}, {Data: nil, Term: 1, Index: 1}}},
committed: 1, committed: 1,
unstable: unstable{offset: 2}, unstable: unstable{offset: 2},
} }

View File

@ -46,9 +46,9 @@ var (
// the key is in string format "major.minor.patch" // the key is in string format "major.minor.patch"
supportedStream = map[string][]streamType{ supportedStream = map[string][]streamType{
"2.0.0": []streamType{streamTypeMsgApp}, "2.0.0": {streamTypeMsgApp},
"2.1.0": []streamType{streamTypeMsgApp, streamTypeMsgAppV2, streamTypeMessage}, "2.1.0": {streamTypeMsgApp, streamTypeMsgAppV2, streamTypeMessage},
"2.2.0": []streamType{streamTypeMsgApp, streamTypeMsgAppV2, streamTypeMessage}, "2.2.0": {streamTypeMsgApp, streamTypeMsgAppV2, streamTypeMessage},
} }
) )

View File

@ -214,7 +214,7 @@ func (t *transport) RemovePeer(id types.ID) {
func (t *transport) RemoveAllPeers() { func (t *transport) RemoveAllPeers() {
t.mu.Lock() t.mu.Lock()
defer t.mu.Unlock() defer t.mu.Unlock()
for id, _ := range t.peers { for id := range t.peers {
t.removePeer(id) t.removePeer(id)
} }
} }

View File

@ -124,7 +124,7 @@ func TestContinuousCompact(t *testing.T) {
{[]byte("foo2"), 6, nil, 4}, {[]byte("foo2"), 6, nil, 4},
} }
wa := map[revision]struct{}{ wa := map[revision]struct{}{
revision{main: 1}: struct{}{}, revision{main: 1}: {},
} }
ga := index.Compact(1) ga := index.Compact(1)
if !reflect.DeepEqual(ga, wa) { if !reflect.DeepEqual(ga, wa) {
@ -133,8 +133,8 @@ func TestContinuousCompact(t *testing.T) {
verify(t, index, tests) verify(t, index, tests)
wa = map[revision]struct{}{ wa = map[revision]struct{}{
revision{main: 1}: struct{}{}, revision{main: 1}: {},
revision{main: 2}: struct{}{}, revision{main: 2}: {},
} }
ga = index.Compact(2) ga = index.Compact(2)
if !reflect.DeepEqual(ga, wa) { if !reflect.DeepEqual(ga, wa) {
@ -143,9 +143,9 @@ func TestContinuousCompact(t *testing.T) {
verify(t, index, tests) verify(t, index, tests)
wa = map[revision]struct{}{ wa = map[revision]struct{}{
revision{main: 1}: struct{}{}, revision{main: 1}: {},
revision{main: 2}: struct{}{}, revision{main: 2}: {},
revision{main: 3}: struct{}{}, revision{main: 3}: {},
} }
ga = index.Compact(3) ga = index.Compact(3)
if !reflect.DeepEqual(ga, wa) { if !reflect.DeepEqual(ga, wa) {
@ -154,9 +154,9 @@ func TestContinuousCompact(t *testing.T) {
verify(t, index, tests) verify(t, index, tests)
wa = map[revision]struct{}{ wa = map[revision]struct{}{
revision{main: 1}: struct{}{}, revision{main: 1}: {},
revision{main: 2}: struct{}{}, revision{main: 2}: {},
revision{main: 4}: struct{}{}, revision{main: 4}: {},
} }
ga = index.Compact(4) ga = index.Compact(4)
delete(wa, revision{main: 3}) delete(wa, revision{main: 3})
@ -167,9 +167,9 @@ func TestContinuousCompact(t *testing.T) {
verify(t, index, tests) verify(t, index, tests)
wa = map[revision]struct{}{ wa = map[revision]struct{}{
revision{main: 2}: struct{}{}, revision{main: 2}: {},
revision{main: 4}: struct{}{}, revision{main: 4}: {},
revision{main: 5}: struct{}{}, revision{main: 5}: {},
} }
ga = index.Compact(5) ga = index.Compact(5)
delete(wa, revision{main: 1}) delete(wa, revision{main: 1})
@ -181,9 +181,9 @@ func TestContinuousCompact(t *testing.T) {
verify(t, index, tests) verify(t, index, tests)
wa = map[revision]struct{}{ wa = map[revision]struct{}{
revision{main: 4}: struct{}{}, revision{main: 4}: {},
revision{main: 5}: struct{}{}, revision{main: 5}: {},
revision{main: 6}: struct{}{}, revision{main: 6}: {},
} }
ga = index.Compact(6) ga = index.Compact(6)
delete(wa, revision{main: 2}) delete(wa, revision{main: 2})

View File

@ -139,7 +139,7 @@ func TestKeyIndexCompact(t *testing.T) {
}, },
}, },
map[revision]struct{}{ map[revision]struct{}{
revision{main: 2}: struct{}{}, revision{main: 2}: {},
}, },
}, },
{ {
@ -154,7 +154,7 @@ func TestKeyIndexCompact(t *testing.T) {
}, },
}, },
map[revision]struct{}{ map[revision]struct{}{
revision{main: 2}: struct{}{}, revision{main: 2}: {},
}, },
}, },
{ {
@ -169,7 +169,7 @@ func TestKeyIndexCompact(t *testing.T) {
}, },
}, },
map[revision]struct{}{ map[revision]struct{}{
revision{main: 4}: struct{}{}, revision{main: 4}: {},
}, },
}, },
{ {
@ -184,7 +184,7 @@ func TestKeyIndexCompact(t *testing.T) {
}, },
}, },
map[revision]struct{}{ map[revision]struct{}{
revision{main: 4}: struct{}{}, revision{main: 4}: {},
}, },
}, },
{ {
@ -222,7 +222,7 @@ func TestKeyIndexCompact(t *testing.T) {
}, },
}, },
map[revision]struct{}{ map[revision]struct{}{
revision{main: 8}: struct{}{}, revision{main: 8}: {},
}, },
}, },
{ {
@ -236,7 +236,7 @@ func TestKeyIndexCompact(t *testing.T) {
}, },
}, },
map[revision]struct{}{ map[revision]struct{}{
revision{main: 8}: struct{}{}, revision{main: 8}: {},
}, },
}, },
{ {
@ -250,7 +250,7 @@ func TestKeyIndexCompact(t *testing.T) {
}, },
}, },
map[revision]struct{}{ map[revision]struct{}{
revision{main: 10}: struct{}{}, revision{main: 10}: {},
}, },
}, },
{ {
@ -264,7 +264,7 @@ func TestKeyIndexCompact(t *testing.T) {
}, },
}, },
map[revision]struct{}{ map[revision]struct{}{
revision{main: 10}: struct{}{}, revision{main: 10}: {},
}, },
}, },
{ {

View File

@ -13,11 +13,11 @@ import (
func TestRevision(t *testing.T) { func TestRevision(t *testing.T) {
tests := []revision{ tests := []revision{
// order in (main, sub) // order in (main, sub)
revision{}, {},
revision{main: 1, sub: 0}, {main: 1, sub: 0},
revision{main: 1, sub: 1}, {main: 1, sub: 1},
revision{main: 2, sub: 0}, {main: 2, sub: 0},
revision{main: math.MaxInt64, sub: math.MaxInt64}, {main: math.MaxInt64, sub: math.MaxInt64},
} }
bs := make([][]byte, len(tests)) bs := make([][]byte, len(tests))

2
test
View File

@ -61,7 +61,7 @@ if [ -n "$INTEGRATION" ]; then
fi fi
echo "Checking gofmt..." echo "Checking gofmt..."
fmtRes=$(gofmt -l $FMT) fmtRes=$(gofmt -l -s $FMT)
if [ -n "${fmtRes}" ]; then if [ -n "${fmtRes}" ]; then
echo -e "gofmt checking failed:\n${fmtRes}" echo -e "gofmt checking failed:\n${fmtRes}"
exit 255 exit 255