mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Databases test fixes
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -44,7 +44,7 @@ class DatabasesConsoleClientTest extends Scope
|
||||
'documentSecurity' => true,
|
||||
]);
|
||||
|
||||
$this->assertEquals($movies['headers']['status-code'], 201);
|
||||
$this->assertEquals(201, $movies['headers']['status-code']);
|
||||
$this->assertEquals($movies['body']['name'], 'Movies');
|
||||
|
||||
return ['moviesId' => $movies['body']['$id'], 'databaseId' => $databaseId];
|
||||
@@ -67,7 +67,7 @@ class DatabasesConsoleClientTest extends Scope
|
||||
// 'range' => '32h'
|
||||
// ]);
|
||||
|
||||
// $this->assertEquals($response['headers']['status-code'], 400);
|
||||
// $this->assertEquals(400, $response['headers']['status-code']);
|
||||
|
||||
// /**
|
||||
// * Test for SUCCESS
|
||||
@@ -80,7 +80,7 @@ class DatabasesConsoleClientTest extends Scope
|
||||
// 'range' => '24h'
|
||||
// ]);
|
||||
|
||||
// $this->assertEquals($response['headers']['status-code'], 200);
|
||||
// $this->assertEquals(200, $response['headers']['status-code']);
|
||||
// $this->assertEquals(count($response['body']), 11);
|
||||
// $this->assertEquals($response['body']['range'], '24h');
|
||||
// $this->assertIsArray($response['body']['documentsCount']);
|
||||
@@ -113,7 +113,7 @@ class DatabasesConsoleClientTest extends Scope
|
||||
'range' => '32h'
|
||||
]);
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 400);
|
||||
$this->assertEquals(400, $response['headers']['status-code']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/randomCollectionId/usage', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
@@ -122,7 +122,7 @@ class DatabasesConsoleClientTest extends Scope
|
||||
'range' => '24h'
|
||||
]);
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 404);
|
||||
$this->assertEquals(404, $response['headers']['status-code']);
|
||||
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
@@ -134,7 +134,7 @@ class DatabasesConsoleClientTest extends Scope
|
||||
'range' => '24h'
|
||||
]);
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 200);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals(count($response['body']), 6);
|
||||
$this->assertEquals($response['body']['range'], '24h');
|
||||
$this->assertIsArray($response['body']['documentsCount']);
|
||||
@@ -158,7 +158,7 @@ class DatabasesConsoleClientTest extends Scope
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()));
|
||||
|
||||
$this->assertEquals($logs['headers']['status-code'], 200);
|
||||
$this->assertEquals(200, $logs['headers']['status-code']);
|
||||
$this->assertIsArray($logs['body']['logs']);
|
||||
$this->assertIsNumeric($logs['body']['total']);
|
||||
|
||||
@@ -169,7 +169,7 @@ class DatabasesConsoleClientTest extends Scope
|
||||
'limit' => 1
|
||||
]);
|
||||
|
||||
$this->assertEquals($logs['headers']['status-code'], 200);
|
||||
$this->assertEquals(200, $logs['headers']['status-code']);
|
||||
$this->assertIsArray($logs['body']['logs']);
|
||||
$this->assertLessThanOrEqual(1, count($logs['body']['logs']));
|
||||
$this->assertIsNumeric($logs['body']['total']);
|
||||
@@ -181,7 +181,7 @@ class DatabasesConsoleClientTest extends Scope
|
||||
'offset' => 1
|
||||
]);
|
||||
|
||||
$this->assertEquals($logs['headers']['status-code'], 200);
|
||||
$this->assertEquals(200, $logs['headers']['status-code']);
|
||||
$this->assertIsArray($logs['body']['logs']);
|
||||
$this->assertIsNumeric($logs['body']['total']);
|
||||
|
||||
@@ -193,7 +193,7 @@ class DatabasesConsoleClientTest extends Scope
|
||||
'limit' => 1
|
||||
]);
|
||||
|
||||
$this->assertEquals($logs['headers']['status-code'], 200);
|
||||
$this->assertEquals(200, $logs['headers']['status-code']);
|
||||
$this->assertIsArray($logs['body']['logs']);
|
||||
$this->assertLessThanOrEqual(1, count($logs['body']['logs']));
|
||||
$this->assertIsNumeric($logs['body']['total']);
|
||||
|
||||
@@ -79,9 +79,9 @@ class DatabasesCustomClientTest extends Scope
|
||||
],
|
||||
'permissions' => [
|
||||
'read(user:' . $userId . ', user:user2)',
|
||||
'create(user:' . $userId . ')',
|
||||
'update(user:' . $userId . ')',
|
||||
'delete(user:' . $userId . ')',
|
||||
'create(user:' . $userId . ')',
|
||||
'update(user:' . $userId . ')',
|
||||
'delete(user:' . $userId . ')',
|
||||
],
|
||||
]);
|
||||
$this->assertEquals(201, $response['headers']['status-code']);
|
||||
@@ -96,6 +96,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
'name' => 'AppwriteExpert',
|
||||
]
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
|
||||
// Get name of the document, should be the new one
|
||||
|
||||
@@ -400,7 +400,7 @@ class DatabasesCustomServerTest extends Scope
|
||||
'cursor' => 'unknown',
|
||||
]);
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 400);
|
||||
$this->assertEquals(400, $response['headers']['status-code']);
|
||||
|
||||
// This collection already exists
|
||||
$response = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections', array_merge([
|
||||
@@ -419,7 +419,7 @@ class DatabasesCustomServerTest extends Scope
|
||||
'documentSecurity' => true,
|
||||
]);
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 409);
|
||||
$this->assertEquals(409, $response['headers']['status-code']);
|
||||
}
|
||||
|
||||
public function testDeleteAttribute(): array
|
||||
@@ -457,7 +457,7 @@ class DatabasesCustomServerTest extends Scope
|
||||
'documentSecurity' => true,
|
||||
]);
|
||||
|
||||
$this->assertEquals($actors['headers']['status-code'], 201);
|
||||
$this->assertEquals(201, $actors['headers']['status-code']);
|
||||
$this->assertEquals($actors['body']['name'], 'Actors');
|
||||
|
||||
$firstName = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $actors['body']['$id'] . '/attributes/string', array_merge([
|
||||
@@ -536,7 +536,7 @@ class DatabasesCustomServerTest extends Scope
|
||||
|
||||
$unneededId = $unneeded['body']['key'];
|
||||
|
||||
$this->assertEquals($collection['headers']['status-code'], 200);
|
||||
$this->assertEquals(200, $collection['headers']['status-code']);
|
||||
$this->assertIsArray($collection['body']['attributes']);
|
||||
$this->assertCount(3, $collection['body']['attributes']);
|
||||
$this->assertEquals($collection['body']['attributes'][0]['key'], $firstName['body']['key']);
|
||||
@@ -552,7 +552,7 @@ class DatabasesCustomServerTest extends Scope
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
]));
|
||||
|
||||
$this->assertEquals($attribute['headers']['status-code'], 204);
|
||||
$this->assertEquals(204, $attribute['headers']['status-code']);
|
||||
|
||||
sleep(2);
|
||||
|
||||
@@ -571,7 +571,7 @@ class DatabasesCustomServerTest extends Scope
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
]), []);
|
||||
|
||||
$this->assertEquals($collection['headers']['status-code'], 200);
|
||||
$this->assertEquals(200, $collection['headers']['status-code']);
|
||||
$this->assertIsArray($collection['body']['attributes']);
|
||||
$this->assertCount(2, $collection['body']['attributes']);
|
||||
$this->assertEquals($collection['body']['attributes'][0]['key'], $firstName['body']['key']);
|
||||
@@ -596,7 +596,7 @@ class DatabasesCustomServerTest extends Scope
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
]));
|
||||
|
||||
$this->assertEquals($index['headers']['status-code'], 204);
|
||||
$this->assertEquals(204, $index['headers']['status-code']);
|
||||
|
||||
// Wait for database worker to finish deleting index
|
||||
sleep(2);
|
||||
@@ -680,7 +680,7 @@ class DatabasesCustomServerTest extends Scope
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
]));
|
||||
|
||||
$this->assertEquals($deleted['headers']['status-code'], 204);
|
||||
$this->assertEquals(204, $deleted['headers']['status-code']);
|
||||
|
||||
// wait for database worker to complete
|
||||
sleep(2);
|
||||
@@ -706,7 +706,7 @@ class DatabasesCustomServerTest extends Scope
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
]));
|
||||
|
||||
$this->assertEquals($deleted['headers']['status-code'], 204);
|
||||
$this->assertEquals(204, $deleted['headers']['status-code']);
|
||||
|
||||
return $data;
|
||||
}
|
||||
@@ -808,7 +808,7 @@ class DatabasesCustomServerTest extends Scope
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
]));
|
||||
|
||||
$this->assertEquals($deleted['headers']['status-code'], 204);
|
||||
$this->assertEquals(204, $deleted['headers']['status-code']);
|
||||
|
||||
// wait for database worker to complete
|
||||
sleep(2);
|
||||
@@ -834,7 +834,7 @@ class DatabasesCustomServerTest extends Scope
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
]));
|
||||
|
||||
$this->assertEquals($deleted['headers']['status-code'], 204);
|
||||
$this->assertEquals(204, $deleted['headers']['status-code']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -880,13 +880,13 @@ class DatabasesCustomServerTest extends Scope
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertEquals($document1['headers']['status-code'], 201);
|
||||
$this->assertEquals(201, $document1['headers']['status-code']);
|
||||
$this->assertIsArray($document1['body']['$permissions']);
|
||||
$this->assertCount(2, $document1['body']['$permissions']);
|
||||
$this->assertCount(4, $document1['body']['$permissions']);
|
||||
$this->assertEquals($document1['body']['firstName'], 'Tom');
|
||||
$this->assertEquals($document1['body']['lastName'], 'Holland');
|
||||
|
||||
$this->assertEquals($document2['headers']['status-code'], 201);
|
||||
$this->assertEquals(201, $document2['headers']['status-code']);
|
||||
$this->assertIsArray($document2['body']['$permissions']);
|
||||
$this->assertCount(1, $document2['body']['$permissions']);
|
||||
$this->assertEquals($document2['body']['firstName'], 'Samuel');
|
||||
@@ -899,7 +899,7 @@ class DatabasesCustomServerTest extends Scope
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
], $this->getHeaders()));
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 204);
|
||||
$this->assertEquals(204, $response['headers']['status-code']);
|
||||
$this->assertEquals($response['body'], "");
|
||||
|
||||
// Try to get the collection and check if it has been deleted
|
||||
@@ -908,7 +908,7 @@ class DatabasesCustomServerTest extends Scope
|
||||
'x-appwrite-project' => $this->getProject()['$id']
|
||||
], $this->getHeaders()));
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 404);
|
||||
$this->assertEquals(404, $response['headers']['status-code']);
|
||||
}
|
||||
|
||||
// Adds several minutes to test to replicate coverage in Utopia\Database unit tests
|
||||
@@ -995,7 +995,7 @@ class DatabasesCustomServerTest extends Scope
|
||||
'documentSecurity' => true,
|
||||
]);
|
||||
|
||||
$this->assertEquals($collection['headers']['status-code'], 201);
|
||||
$this->assertEquals(201, $collection['headers']['status-code']);
|
||||
$this->assertEquals($collection['body']['name'], 'attributeRowWidthLimit');
|
||||
|
||||
$collectionId = $collection['body']['$id'];
|
||||
@@ -1012,7 +1012,7 @@ class DatabasesCustomServerTest extends Scope
|
||||
'required' => true,
|
||||
]);
|
||||
|
||||
$this->assertEquals($attribute['headers']['status-code'], 201);
|
||||
$this->assertEquals(201, $attribute['headers']['status-code']);
|
||||
}
|
||||
|
||||
sleep(5);
|
||||
@@ -1061,7 +1061,7 @@ class DatabasesCustomServerTest extends Scope
|
||||
'documentSecurity' => true,
|
||||
]);
|
||||
|
||||
$this->assertEquals($collection['headers']['status-code'], 201);
|
||||
$this->assertEquals(201, $collection['headers']['status-code']);
|
||||
$this->assertEquals($collection['body']['name'], 'testLimitException');
|
||||
|
||||
$collectionId = $collection['body']['$id'];
|
||||
@@ -1079,7 +1079,7 @@ class DatabasesCustomServerTest extends Scope
|
||||
'required' => true,
|
||||
]);
|
||||
|
||||
$this->assertEquals($attribute['headers']['status-code'], 201);
|
||||
$this->assertEquals(201, $attribute['headers']['status-code']);
|
||||
}
|
||||
|
||||
sleep(20);
|
||||
@@ -1090,7 +1090,7 @@ class DatabasesCustomServerTest extends Scope
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
]));
|
||||
|
||||
$this->assertEquals($collection['headers']['status-code'], 200);
|
||||
$this->assertEquals(200, $collection['headers']['status-code']);
|
||||
$this->assertEquals($collection['body']['name'], 'testLimitException');
|
||||
$this->assertIsArray($collection['body']['attributes']);
|
||||
$this->assertIsArray($collection['body']['indexes']);
|
||||
@@ -1128,7 +1128,7 @@ class DatabasesCustomServerTest extends Scope
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
]));
|
||||
|
||||
$this->assertEquals($collection['headers']['status-code'], 200);
|
||||
$this->assertEquals(200, $collection['headers']['status-code']);
|
||||
$this->assertEquals($collection['body']['name'], 'testLimitException');
|
||||
$this->assertIsArray($collection['body']['attributes']);
|
||||
$this->assertIsArray($collection['body']['indexes']);
|
||||
|
||||
Reference in New Issue
Block a user