-
Notifications
You must be signed in to change notification settings - Fork 496
/
SyntaxErrors.kt
68 lines (58 loc) · 1.59 KB
/
SyntaxErrors.kt
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package app.cash.sqldelight.core.errors
import app.cash.sqldelight.test.util.FixtureCompiler
import com.google.common.truth.Truth.assertThat
import org.junit.Rule
import org.junit.Test
import org.junit.rules.TemporaryFolder
class SyntaxErrors {
@get:Rule val tempFolder = TemporaryFolder()
@Test fun `incorrect capitalization on type errors gracefully`() {
val result = FixtureCompiler.compileSql(
"""
|CREATE TABLE my_table (
| col INTEGER AS long
|);
|
""".trimMargin(),
tempFolder,
)
assertThat(result.errors).containsExactly("Test.sq: (2, 19): Unknown type long")
}
@Test fun `unknown function`() {
val result = FixtureCompiler.compileSql(
"""
|selectScoob:
|SELECT scoobyDoo();
|
""".trimMargin(),
tempFolder,
)
assertThat(result.errors).containsExactly("Test.sq: (2, 7): Unknown function scoobyDoo")
}
@Test fun `illegal type fails gracefully`() {
val result = FixtureCompiler.compileSql(
"""
|CREATE TABLE my_table (
| col INTEGER AS team
|);
|
""".trimMargin(),
tempFolder,
)
assertThat(result.errors).containsExactly("Test.sq: (2, 19): Unknown type team")
}
@Test fun `lowercase 'as' in column type`() {
val result = FixtureCompiler.compileSql(
"""
|CREATE TABLE my_table (
| col INTEGER as Boolean
|);
|
""".trimMargin(),
tempFolder,
)
assertThat(result.errors).containsExactly(
"Test.sq: (2, 16): ')', ',', <column constraint real> or AS expected, got 'as'",
)
}
}