public function testWaitForStateTimeOut() { $Facker = Factory::create(); $MockedModel = new Model(json_decode(ServiceTest::getMockData(), true)); $this->mockResponses([new Response(200, ['Content-Type' => 'application/json'], Encoder::encode($MockedModel->setState(Model::STATE_NOT_RUNNING)->getArrayCopy())), new Response(200, ['Content-Type' => 'application/json'], Encoder::encode($MockedModel->setState(Model::STATE_STARTING)->getArrayCopy()))]); $API = new API(); $Model = $API->get($Facker->uuid); $this->expectException(Exception::class); $this->expectExceptionMessageRegExp('/.*timed out.*/'); $API->waitForState($Model, Model::STATE_RUNNING, 0.1, 0); }
/** * @param Model $Model * * @depends testCreate */ public function testUpdateLinkedToService(Model $Model) { $this->mockResponse(200, $this->getMockData()); $API = new API(); $Model->setTags(['unit-test-update']); $Model = $API->updateLinkedToService($Model); $this->assertInstanceOf(Model::class, $Model); }
/** * Only update linked_to_service field so the DockerCloud API won't prompt need to redeploy * * @param Model $Model * * @return Model * @throws \DockerCloud\Exception */ public function updateLinkedToService(Model $Model) { return new Model($this->getClient()->request('PATCH', $this->getAPINameSpace() . $Model->getUuid() . '/', ['body' => Json::encode(['linked_to_service' => $Model->getLinkedToService()])])); }