Merge pull request #858 from lavalamp/fix

Fix flaky TestOpGet
This commit is contained in:
brendandburns 2014-08-12 15:19:13 -07:00
commit 74a7179e2e
2 changed files with 15 additions and 4 deletions

View File

@ -586,7 +586,7 @@ func expectApiStatus(t *testing.T, method, url string, data []byte, code int) *a
func TestErrorsToAPIStatus(t *testing.T) {
cases := map[error]api.Status{
NewAlreadyExistsErr("foo", "bar"): api.Status{
NewAlreadyExistsErr("foo", "bar"): {
Status: api.StatusFailure,
Code: http.StatusConflict,
Reason: "already_exists",
@ -596,7 +596,7 @@ func TestErrorsToAPIStatus(t *testing.T) {
ID: "bar",
},
},
NewConflictErr("foo", "bar", errors.New("failure")): api.Status{
NewConflictErr("foo", "bar", errors.New("failure")): {
Status: api.StatusFailure,
Code: http.StatusConflict,
Reason: "conflict",
@ -719,9 +719,12 @@ func TestWriteRAWJSONMarshalError(t *testing.T) {
}
func TestSyncCreateTimeout(t *testing.T) {
testOver := make(chan struct{})
defer close(testOver)
storage := SimpleRESTStorage{
injectedFunction: func(obj interface{}) (interface{}, error) {
time.Sleep(5 * time.Millisecond)
// Eliminate flakes by ensuring the create operation takes longer than this test.
<-testOver
return obj, nil
},
}

View File

@ -140,7 +140,15 @@ func TestOperationsList(t *testing.T) {
}
func TestOpGet(t *testing.T) {
simpleStorage := &SimpleRESTStorage{}
testOver := make(chan struct{})
defer close(testOver)
simpleStorage := &SimpleRESTStorage{
injectedFunction: func(obj interface{}) (interface{}, error) {
// Eliminate flakes by ensuring the create operation takes longer than this test.
<-testOver
return obj, nil
},
}
handler := New(map[string]RESTStorage{
"foo": simpleStorage,
}, codec, "/prefix/version")