})

			assertFailure("Failed to read HTTP response body")
		})

		Context("when a malformed response is received", func() {
			BeforeEach(func() {
				httpClient.LastRequest().Succeed([]byte("ß"))
			})

			assertFailure("Failed to parse HTTP response body JSON")
		})

		Context("when it fails to write to the store", func() {
			BeforeEach(func() {
				store.SaveDesiredStateError = errors.New("oops!")
				a := app.NewApp()
				response = DesiredStateServerResponse{
					Results: map[string]models.DesiredAppState{
						a.AppGuid: a.DesiredState(0),
					},
					BulkToken: BulkToken{
						Id: 5,
					},
				}

				httpClient.LastRequest().Succeed(response.ToJson())
			})

			assertFailure("Failed to store desired state in store")
		})