etcdserver: parse context error for better message

This commit is contained in:
Yicheng Qin
2014-10-26 11:35:59 -07:00
parent 91a4aa151a
commit e77f8e311c
2 changed files with 29 additions and 4 deletions

View File

@ -614,8 +614,8 @@ func TestDoProposalCancelled(t *testing.T) {
if len(gaction) != 0 {
t.Errorf("len(action) = %v, want 0", len(gaction))
}
if err != context.Canceled {
t.Fatalf("err = %v, want %v", err, context.Canceled)
if err != ErrCanceled {
t.Fatalf("err = %v, want %v", err, ErrCanceled)
}
w := []action{action{name: "Register1"}, action{name: "Trigger1"}}
if !reflect.DeepEqual(wait.action, w) {
@ -623,6 +623,18 @@ func TestDoProposalCancelled(t *testing.T) {
}
}
func TestDoProposalTimeout(t *testing.T) {
ctx, _ := context.WithTimeout(context.Background(), 0)
srv := &EtcdServer{
node: &nodeRecorder{},
w: &waitRecorder{},
}
_, err := srv.Do(ctx, pb.Request{Method: "PUT", ID: 1})
if err != ErrTimeout {
t.Fatalf("err = %v, want %v", err, ErrTimeout)
}
}
func TestDoProposalStopped(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()