1
0
Fork 0
mirror of synced 2024-06-01 18:39:57 +12:00

Fixed tests

This commit is contained in:
Eldad Fux 2021-08-22 19:36:26 +03:00
parent 31500cd675
commit f1ec1b2a05
5 changed files with 34 additions and 24 deletions

View file

@ -941,6 +941,7 @@ App::post('/v1/database/collections/:collectionId/indexes')
$database
->setParam('type', DATABASE_TYPE_CREATE_INDEX)
->setParam('collection', $collection)
->setParam('document', $index)
;

View file

@ -264,11 +264,14 @@ $logs = $this->getParam('logs', null);
</td>
<td data-title="Status">
<span class="text-size-small text-success">available</span>
<span data-ls-if="{{index.status}} == 'available'" class="text-size-small text-success">available&nbsp;</span>
<span data-ls-if="{{index.status}} == 'processing'" class="text-size-small text-info">processing&nbsp;</span>
<span data-ls-if="{{index.status}} == 'failed'" class="text-size-small text-danger">failed&nbsp;</span>
<span data-ls-if="{{index.status}} == 'deleting'" class="text-size-small text-danger">deleting&nbsp;</span>
</td>
<td data-title="Index ID: ">
<span class="text-size-small" data-ls-bind="{{index.$id}}"></span><span class="text-size-small" data-ls-if="{{index.size}}" data-ls-bind="({{index.size}})"></span>
<span class="text-size-small" data-ls-bind="{{index.key}}"></span><span class="text-size-small" data-ls-if="{{index.size}}" data-ls-bind="({{index.size}})"></span>
</td>
<td data-title="Type:">

View file

@ -10,11 +10,11 @@ class Index extends Model
public function __construct()
{
$this
->addRule('$id', [
->addRule('key', [
'type' => self::TYPE_STRING,
'description' => 'Index ID.',
'description' => 'Index Key.',
'default' => '',
'example' => '',
'example' => 'index1',
])
->addRule('type', [
'type' => self::TYPE_STRING,
@ -22,6 +22,12 @@ class Index extends Model
'default' => '',
'example' => '',
])
->addRule('status', [
'type' => self::TYPE_STRING,
'description' => 'Index status. Possible values: `available`, `processing`, `deleting`, or `failed`',
'default' => '',
'example' => 'string',
])
->addRule('attributes', [
'type' => self::TYPE_STRING,
'description' => 'Index attributes.',

View file

@ -120,24 +120,24 @@ trait DatabaseBase
'attributes' => ['title'],
]);
// $this->assertEquals($titleIndex['headers']['status-code'], 201);
// $this->assertEquals($titleIndex['body']['$id'], 'titleIndex');
// $this->assertEquals($titleIndex['body']['type'], 'fulltext');
// $this->assertCount(1, $titleIndex['body']['attributes']);
// $this->assertEquals($titleIndex['body']['attributes'][0], 'title');
$this->assertEquals($titleIndex['headers']['status-code'], 201);
$this->assertEquals($titleIndex['body']['key'], 'titleIndex');
$this->assertEquals($titleIndex['body']['type'], 'fulltext');
$this->assertCount(1, $titleIndex['body']['attributes']);
$this->assertEquals($titleIndex['body']['attributes'][0], 'title');
// // wait for database worker to create index
// sleep(5);
// wait for database worker to create index
sleep(5);
// $movies = $this->client->call(Client::METHOD_GET, '/database/collections/' . $data['moviesId'], array_merge([
// 'content-type' => 'application/json',
// 'x-appwrite-project' => $this->getProject()['$id'],
// 'x-appwrite-key' => $this->getProject()['apiKey']
// ]), []);
$movies = $this->client->call(Client::METHOD_GET, '/database/collections/' . $data['moviesId'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), []);
// $this->assertIsArray($movies['body']['indexes']);
// $this->assertCount(1, $movies['body']['indexes']);
// $this->assertEquals($movies['body']['indexes'][0]['$id'], $titleIndex['body']['$id']);
$this->assertIsArray($movies['body']['indexes']);
$this->assertCount(1, $movies['body']['indexes']);
$this->assertEquals($movies['body']['indexes'][0]['key'], $titleIndex['body']['key']);
return $data;
}

View file

@ -179,7 +179,7 @@ class DatabaseCustomServerTest extends Scope
$this->assertEquals($collection['body']['attributes'][1]['key'], $lastName['body']['key']);
$this->assertEquals($collection['body']['attributes'][2]['key'], $unneeded['body']['key']);
$this->assertCount(1, $collection['body']['indexes']);
$this->assertEquals($collection['body']['indexes'][0]['$id'], $index['body']['$id']);
$this->assertEquals($collection['body']['indexes'][0]['key'], $index['body']['key']);
// Delete attribute
$this->client->call(Client::METHOD_DELETE, '/database/collections/' . $actors ['body']['$id'] . '/attributes/' . $unneededId, array_merge([
@ -198,12 +198,12 @@ class DatabaseCustomServerTest extends Scope
$this->assertIsArray($collection['body']['attributes']);
$this->assertCount(2, $collection['body']['attributes']);
$this->assertEquals($collection['body']['attributes'][0]['$id'], $firstName['body']['$id']);
$this->assertEquals($collection['body']['attributes'][1]['$id'], $lastName['body']['$id']);
$this->assertEquals($collection['body']['attributes'][0]['key'], $firstName['body']['key']);
$this->assertEquals($collection['body']['attributes'][1]['key'], $lastName['body']['key']);
return [
'collectionId' => $actors['body']['$id'],
'indexId' => $index['body']['$id'],
'indexId' => $index['body']['key'],
];
}
/**