Skip to content

Commit

Permalink
Added spec for Importer::run, fixes #9
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelkiessling committed Dec 30, 2015
1 parent 8b848a1 commit 42228dd
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions importer/src/test/scala/ImporterSpec.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.journeymonitor.analyze.importer

import com.datastax.driver.core.querybuilder.QueryBuilder._
import org.scalatest.{Matchers, FunSpec}

class ImporterSpec extends FunSpec with Matchers {

describe("Importing testresults") {
it("should work if the file is valid") {
val uriString = sys.env.getOrElse(
"JOURNEYMONITOR_ANALYZE_IMPORTER_CASSANDRAURI_TEST",
"cassandra://localhost:9042/test"
)
val uri = CassandraConnectionUri(uriString)
val firstSession = CassandraClient.createSessionAndInitKeyspace(uri)

firstSession.execute("TRUNCATE testresults;")

Importer.run("./testresults.json", firstSession)

val secondSession = CassandraClient.createSessionAndInitKeyspace(uri)

val selectStmt = select().column("testresult_id")
.from("testresults")
.limit(1)

val resultSet = secondSession.execute(selectStmt)
val row = resultSet.one()
row.getString("testresult_id") should be("61C19634-9B83-4E63-8EBD-7D7469AB678C")
}
}

}

0 comments on commit 42228dd

Please sign in to comment.