We developed a middleware to make calls to the HubSpot API along with functional tests. For testing, when creating a new object, we had to implement PHP’s `sleep()` method to allow time for HubSpot’s collection response to include the new object. We had to keep increasing the `sleep()` time for the tests to finish without errors.
Example of failed tests.
- Create Contact Object Test (success)
- Don’t use `sleep()` method
- Get collection by Contact ID test (fail)
- Get collection by email address test (fail)
- Get single contact ID test (fail)
Example of successful tests.
- Create Contact Object Test (success)
- `sleep(15)`; 15 seconds. we had to keep increasing in order to get success on a regular basis.
- Get collection by Contact ID test (success)
- Get collection by email address test (success)
- Get single contact ID test (success)
Is this a HubSpot caching issue? Is there a way to force HubSpot to bust the cache so the new object is available?