-
Notifications
You must be signed in to change notification settings - Fork 515
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e719378
commit afe9d44
Showing
2 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...pp/cash/sqldelight/intellij/lang/completion/SqlDelightKeywordCompletionContributorTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package app.cash.sqldelight.intellij.lang.completion | ||
|
||
import app.cash.sqldelight.core.lang.SqlDelightFileType | ||
import app.cash.sqldelight.intellij.SqlDelightFixtureTestCase | ||
import com.google.common.truth.Truth.assertThat | ||
import com.intellij.codeInsight.completion.CompletionType | ||
|
||
class SqlDelightKeywordCompletionContributorTest : SqlDelightFixtureTestCase() { | ||
|
||
fun testJoinClauseCompletion() { | ||
myFixture.configureByText( | ||
SqlDelightFileType, | ||
""" | ||
|CREATE TABLE album( | ||
| albumartist TEXT, | ||
| albumname TEXT, | ||
| albumcover TEXT, | ||
| PRIMARY KEY(albumartist) | ||
|); | ||
| | ||
|CREATE TABLE song( | ||
| songid INTEGER, | ||
| songartist TEXT, | ||
| songalbum TEXT, | ||
| songname TEXT, | ||
| FOREIGN KEY(songartist) REFERENCES album(albumartist) | ||
|); | ||
| | ||
|SELECT * FROM song JOIN <caret> | ||
""".trimMargin(), | ||
) | ||
|
||
myFixture.complete(CompletionType.BASIC) | ||
|
||
val lookupElementStrings = myFixture.lookupElementStrings | ||
assertThat(lookupElementStrings).contains("album ON song.songartist = album.albumartist") | ||
} | ||
|
||
fun testJoinClauseCompletionWithCompositeForeignKey() { | ||
myFixture.configureByText( | ||
SqlDelightFileType, | ||
""" | ||
|CREATE TABLE album( | ||
| albumartist TEXT, | ||
| albumname TEXT, | ||
| albumcover TEXT, | ||
| PRIMARY KEY(albumartist, albumname) | ||
|); | ||
| | ||
|CREATE TABLE song( | ||
| songid INTEGER, | ||
| songartist TEXT, | ||
| songalbum TEXT, | ||
| songname TEXT, | ||
| FOREIGN KEY(songartist, songalbum) REFERENCES album(albumartist, albumname) | ||
|); | ||
| | ||
|SELECT * FROM song JOIN <caret> | ||
""".trimMargin(), | ||
) | ||
|
||
myFixture.complete(CompletionType.BASIC) | ||
|
||
val lookupElementStrings = myFixture.lookupElementStrings | ||
assertThat(lookupElementStrings).contains("album ON song.songartist = album.albumartist AND song.songalbum = album.albumname") | ||
} | ||
} |