public function testStorageBackendShouldNotBeRemovedIfThereAreBuckets() { $name = 'My org'; $organization = $this->client->createOrganization($this->testMaintainerId, ['name' => $name]); $project = $this->client->createProject($organization['id'], ['name' => 'My test']); $token = $this->client->createProjectStorageToken($project['id'], ['description' => 'test', 'expiresIn' => 60, 'canManageBuckets' => true]); $sapiClient = new \Keboola\StorageApi\Client(['url' => getenv('KBC_MANAGE_API_URL'), 'token' => $token['token']]); $sapiClient->createBucket('test', 'in'); try { $this->client->removeProjectStorageBackend($project['id'], reset($project['backends'])['id']); $this->fail('Backend should not be removed'); } catch (ClientException $e) { $this->assertEquals(400, $e->getCode()); $this->assertEquals('bucketsExists', $e->getStringCode()); } }
public function testMetaQueryTransformation() { $sapiClient = new \Keboola\StorageApi\Client(array("token" => PROVISIONING_API_TOKEN)); $csv = new \Keboola\Csv\CsvFile(ROOT_PATH . "/tests/data/table.csv"); $sapiClient->createBucket("redshift", \Keboola\StorageApi\Client::STAGE_IN, "provisioning test", "redshift"); $sapiClient->createBucket("redshift", \Keboola\StorageApi\Client::STAGE_OUT, "provisioning test", "redshift"); $sapiClient->createTable("in.c-redshift", "test", $csv); $sapiClient->createTable("out.c-redshift", "test", $csv); $result = $this->client->getCredentials(); $conn = $this->connect($result); $result = $conn->fetchAll("SELECT * FROM SVV_TABLE_INFO;"); $this->assertGreaterThan(0, count($result)); $conn->close(); }