summaryrefslogtreecommitdiff
path: root/src/test/scala/org/xapek/influxdb/InfluxdbTest.scala
blob: 084b25fd5fe287d6369ffa215f844c0c12ce56c7 (plain)
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
package org.xapek.influxdb

import org.junit._
import Assert._
import org.xapek.influxdb.InfluxDB._

@Test
class AppTest {

  @Test
  def testStatements() = {
    val db :InfluxDB = fromUrl("http://localhost")

    assertTrue((SELECT("foo") FROM "bla" WHERE col("a") == "asd")
      .toString().contains("as"))

    assertTrue((SELECT("foo")("bla") FROM "bla" WHERE col("a") == "asd")
      .toString().contains("foo"))

    assertTrue((SELECT("foo")("bla") FROM "bla" WHERE col("b") == 1)
      .toString().contains("\"b\" = 1"))

    assertTrue((
      SELECT("foo")
      FROM "bla"
      WHERE col("a") == "asd" || col("b") == "C" && col("c") == "d").toString().contains("bla"))

    assertTrue((
      SELECT("foo")
      FROM "bla"
      WHERE (col("a") == "asd" || col("b") == "C") && col("c") == "d").toString().contains("foo"))

    assertTrue((
      SELECT("foo")
      FROM "bla"
      WHERE (col("a") == "asd" || col("b") == "C") && col("c") == "d"
      GROUP_BY "asd").toString().contains("GROUP BY"))

    assertTrue(((
      SELECT("foo")
      FROM "bla"
      WHERE (col("a") == "asd" || col("b") == "C") && col("c") == "d"
      GROUP_BY ("asd"))("asdasd")).toString().contains("asdasd"))
  }
}