Skip to content

Commit

Permalink
clientv3/integration: add TestMemberAddUpdateWrongURLs
Browse files Browse the repository at this point in the history
Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
  • Loading branch information
gyuho committed Jan 19, 2018
1 parent 5b88a6f commit d6d7722
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions clientv3/integration/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package integration

import (
"context"
"fmt"
"reflect"
"testing"

Expand Down Expand Up @@ -126,3 +127,35 @@ func TestMemberUpdate(t *testing.T) {
t.Errorf("urls = %v, want %v", urls, resp.Members[0].PeerURLs)
}
}

func TestMemberAddUpdateWrongURLs(t *testing.T) {
defer testutil.AfterTest(t)

clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
defer clus.Terminate(t)

capi := clus.RandClient()
tt := []struct {
urls []string
err error
}{
{
[]string{"127.0.0.1:1234"},
fmt.Errorf("parse 127.0.0.1:1234: first path segment in URL cannot contain colon"),
},
{
[]string{"localhost:1234"},
fmt.Errorf("URL scheme must be http, https, unix, or unixs: localhost:1234"),
},
}
for i := range tt {
_, err := capi.MemberAdd(context.Background(), tt[i].urls)
if err.Error() != tt[i].err.Error() {
t.Fatalf("#%d: expected %v, got %v", i, tt[i].err, err)
}
_, err = capi.MemberUpdate(context.Background(), 0, tt[i].urls)
if err.Error() != tt[i].err.Error() {
t.Fatalf("#%d: expected %v, got %v", i, tt[i].err, err)
}
}
}

0 comments on commit d6d7722

Please sign in to comment.