Make updates atomic from the client side.

This commit is contained in:
Brendan Burns
2014-08-01 14:14:33 -07:00
parent 5b589cf115
commit 1101c00014
3 changed files with 42 additions and 18 deletions

View File

@@ -154,7 +154,7 @@ func TestCreatePod(t *testing.T) {
func TestUpdatePod(t *testing.T) {
requestPod := api.Pod{
JSONBase: api.JSONBase{ID: "foo"},
JSONBase: api.JSONBase{ID: "foo", ResourceVersion: 1},
CurrentState: api.PodState{
Status: "Foobar",
},
@@ -219,7 +219,7 @@ func TestGetController(t *testing.T) {
func TestUpdateController(t *testing.T) {
requestController := api.ReplicationController{
JSONBase: api.JSONBase{ID: "foo"},
JSONBase: api.JSONBase{ID: "foo", ResourceVersion: 1},
}
c := &testClient{
Request: testRequest{Method: "PUT", Path: "/replicationControllers/foo"},
@@ -388,11 +388,12 @@ func TestCreateService(t *testing.T) {
}
func TestUpdateService(t *testing.T) {
svc := api.Service{JSONBase: api.JSONBase{ID: "service-1", ResourceVersion: 1}}
c := &testClient{
Request: testRequest{Method: "PUT", Path: "/services/service-1", Body: &api.Service{JSONBase: api.JSONBase{ID: "service-1"}}},
Response: Response{StatusCode: 200, Body: &api.Service{JSONBase: api.JSONBase{ID: "service-1"}}},
Request: testRequest{Method: "PUT", Path: "/services/service-1", Body: &svc},
Response: Response{StatusCode: 200, Body: &svc},
}
response, err := c.Setup().UpdateService(api.Service{JSONBase: api.JSONBase{ID: "service-1"}})
response, err := c.Setup().UpdateService(svc)
c.Validate(t, &response, err)
}