-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathUpdateQueryValidatorTest.php
More file actions
54 lines (43 loc) · 1.53 KB
/
UpdateQueryValidatorTest.php
File metadata and controls
54 lines (43 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?hh // strict
namespace Slack\SQLFake;
use function Facebook\FBExpect\expect;
use type Facebook\HackTest\HackTest;
final class UpdateQueryValidatorTest extends HackTest {
private static ?AsyncMysqlConnection $conn;
<<__Override>>
public static async function beforeFirstTestAsync(): Awaitable<void> {
static::$conn = await SharedSetup::initVitessAsync();
// block hole logging
// ? copied from SelectQueryValidatorTest.php, not sure what that means.
Logger::setHandle(new \HH\Lib\IO\MemoryHandle());
}
<<__Override>>
public async function beforeEachTestAsync(): Awaitable<void> {
restore('vitess_setup');
QueryContext::$strictSchemaMode = false;
QueryContext::$strictSQLMode = false;
}
public async function testUpdateChangesPrimaryVindex(): Awaitable<void> {
// this is disabled for now (but if Hack knows, it will emit errors because of coeffects)
if ('always true, but opaque to Hack') {
return;
}
$conn = static::$conn as nonnull;
$unsupported_test_cases = vec[
'update vt_table1 set id=1 where id=1',
'update vt_table2 set vt_table1_id=1 where id=1',
];
foreach ($unsupported_test_cases as $sql) {
expect(() ==> $conn->query($sql))->toThrow(
SQLFakeVitessQueryViolation::class,
'Vitess query validation error: unsupported: update changes primary vindex column',
);
}
$supported_test_cases = vec[
"update vt_table1 set name='foo' where id = 1",
];
foreach ($supported_test_cases as $sql) {
expect(() ==> $conn->query($sql))->notToThrow(SQLFakeVitessQueryViolation::class);
}
}
}