Merge pull request #1860 from yichengq/249

integration: fix possible early fire in TestWatch
This commit is contained in:
Yicheng Qin 2014-12-04 14:48:39 -08:00
commit ca32a5fe9b

View File

@ -770,15 +770,7 @@ func TestV2Watch(t *testing.T) {
u := cl.URL(0)
tc := NewTestClient()
var watchResp *http.Response
c := make(chan bool)
go func() {
watchResp, _ = tc.Get(fmt.Sprintf("%s%s", u, "/v2/keys/foo/bar?wait=true"))
c <- true
}()
// Make sure response didn't fire early.
time.Sleep(1 * time.Millisecond)
watchResp, _ := tc.Get(fmt.Sprintf("%s%s", u, "/v2/keys/foo/bar?wait=true"))
// Set a value.
v := url.Values{}
@ -786,12 +778,6 @@ func TestV2Watch(t *testing.T) {
resp, _ := tc.PutForm(fmt.Sprintf("%s%s", u, "/v2/keys/foo/bar"), v)
resp.Body.Close()
select {
case <-c:
case <-time.After(time.Millisecond):
t.Fatal("cannot get watch result")
}
body := tc.ReadBodyJSON(watchResp)
w := map[string]interface{}{
"node": map[string]interface{}{