Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
bgaidioz committed Apr 30, 2024
1 parent ed7a499 commit f9be846
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ class JinjaSqlCompilerService(maybeClassLoader: Option[ClassLoader] = None)(impl
def eval(source: String, tipe: raw.client.api.RawType, environment: raw.client.api.ProgramEnvironment): raw.client.api.EvalResponse = ???


def execute(source: String, environment: raw.client.api.ProgramEnvironment, maybeDecl: Option[String], outputStream: java.io.OutputStream): raw.client.api.ExecutionResponse = ???
def execute(source: String, environment: raw.client.api.ProgramEnvironment, maybeDecl: Option[String], outputStream: java.io.OutputStream): raw.client.api.ExecutionResponse = {
logger.debug("execute")
???
}


def formatCode(source: String, environment: raw.client.api.ProgramEnvironment, maybeIndent: Option[Int], maybeWidth: Option[Int]): raw.client.api.FormatCodeResponse = ???
Expand Down
39 changes: 35 additions & 4 deletions jinja-sql-client/src/test/scala/PreprocessingTest.scala
Original file line number Diff line number Diff line change
@@ -1,9 +1,40 @@
import org.scalatest.funsuite.AnyFunSuite
import raw.client.api.{CompilerService, ExecutionSuccess, ProgramEnvironment, RawValue}
import raw.client.jinja.sql.JinjaSqlCompilerService
import raw.utils.{InteractiveUser, RawTestSuite, SettingsTestContext, TrainingWheelsContext, Uid}

class PreprocessingTest extends AnyFunSuite {
import java.io.ByteArrayOutputStream

test("1+1 works") {
assert(1 + 1 === 2)
class PreprocessingTest extends RawTestSuite
with SettingsTestContext
with TrainingWheelsContext
{

test("SELECT") { q =>
val baos = new ByteArrayOutputStream()
val r = compilerService.execute(q.q, asJson(), None, baos)
assert(r == ExecutionSuccess)
}

private var compilerService: CompilerService = _

private val database = ""
private val user = InteractiveUser(Uid(database), "fdw user", "email", Seq.empty)

private def asJson(params: Map[String, RawValue] = Map.empty): ProgramEnvironment = {
if (params.isEmpty) ProgramEnvironment(user, None, Set.empty, Map("output-format" -> "json"))
else ProgramEnvironment(user, Some(params.toArray), Set.empty, Map("output-format" -> "json"))
}

override def beforeAll(): Unit = {
super.beforeAll()
compilerService = new JinjaSqlCompilerService(None)
}

override def afterAll(): Unit = {
if (compilerService != null) {
compilerService.stop()
compilerService = null
}
}

}

0 comments on commit f9be846

Please sign in to comment.