-
Notifications
You must be signed in to change notification settings - Fork 513
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
95de86b
commit 9cdb929
Showing
4 changed files
with
74 additions
and
1 deletion.
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
22 changes: 22 additions & 0 deletions
22
...ght-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/run/FakeDialogViewFactory.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,22 @@ | ||
package app.cash.sqldelight.intellij.run | ||
|
||
import com.intellij.openapi.project.Project | ||
|
||
internal class FakeDialogViewFactory( | ||
val values: List<String> = emptyList(), | ||
val okPressed: Boolean = true, | ||
) : ArgumentsInputDialog.Factory { | ||
|
||
override fun create(project: Project, parameters: List<SqlParameter>): ArgumentsInputDialog { | ||
return object : ArgumentsInputDialog { | ||
override val result: List<SqlParameter> | ||
get() = parameters.zip(values) { a, b -> | ||
a.copy(value = b) | ||
} | ||
|
||
override fun showAndGet(): Boolean { | ||
return okPressed | ||
} | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...ght-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/run/FakeStatementExecutor.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,11 @@ | ||
package app.cash.sqldelight.intellij.run | ||
|
||
internal class FakeStatementExecutor : SqlDelightStatementExecutor { | ||
|
||
var statement = "" | ||
private set | ||
|
||
override fun execute(sqlStmt: String) { | ||
statement = sqlStmt | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...ht-idea-plugin/src/test/kotlin/app/cash/sqldelight/intellij/run/RunSqliteAnnotatorTest.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,40 @@ | ||
package app.cash.sqldelight.intellij.run | ||
|
||
import app.cash.sqldelight.core.lang.SqlDelightFileType | ||
import app.cash.sqldelight.intellij.SqlDelightFixtureTestCase | ||
import com.google.common.truth.Truth.assertThat | ||
import com.intellij.icons.AllIcons | ||
|
||
class RunSqliteAnnotatorTest : SqlDelightFixtureTestCase() { | ||
|
||
fun testGutterIconVisibleInSqlite() { | ||
ConnectionOptions(project).apply { | ||
connectionType = ConnectionType.FILE | ||
filePath = "/path/to/file" | ||
} | ||
myFixture.configureByText( | ||
SqlDelightFileType, """ | ||
|CREATE TABLE test ( <caret> | ||
| id INTEGER | ||
|); | ||
""".trimMargin() | ||
) | ||
|
||
val guttersAtCaret = myFixture.findGuttersAtCaret() | ||
assertThat(guttersAtCaret.first().icon).isEqualTo(AllIcons.RunConfigurations.TestState.Run) | ||
} | ||
|
||
fun testGutterIconInvisibleWhenConnectionTypeNotSpecified() { | ||
ConnectionOptions(project).apply { | ||
connectionType = ConnectionType.NONE | ||
} | ||
myFixture.configureByText( | ||
SqlDelightFileType, """ | ||
|CREATE TABLE test ( <caret> | ||
| id INTEGER | ||
|); | ||
""".trimMargin() | ||
) | ||
assertThat(myFixture.findGuttersAtCaret()).isEmpty() | ||
} | ||
} |