add simple test

Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/d1d17408
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/d1d17408
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/d1d17408

Branch: refs/heads/master
Commit: d1d17408d333b0a0a0598c20977ca101f9350742
Parents: 8af51d9
Author: daewon <[email protected]>
Authored: Mon Jun 4 18:35:25 2018 +0900
Committer: daewon <[email protected]>
Committed: Mon Jun 4 18:35:25 2018 +0900

----------------------------------------------------------------------
 .../apache/s2graph/graphql/DirectiveTest.scala  | 53 ++++++++++++++++++++
 1 file changed, 53 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d1d17408/s2graphql/src/test/scala/org/apache/s2graph/graphql/DirectiveTest.scala
----------------------------------------------------------------------
diff --git 
a/s2graphql/src/test/scala/org/apache/s2graph/graphql/DirectiveTest.scala 
b/s2graphql/src/test/scala/org/apache/s2graph/graphql/DirectiveTest.scala
new file mode 100644
index 0000000..699a968
--- /dev/null
+++ b/s2graphql/src/test/scala/org/apache/s2graph/graphql/DirectiveTest.scala
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.s2graph.graphql
+
+import com.typesafe.config.ConfigFactory
+import org.apache.s2graph.graphql.types.S2Directive
+import org.scalatest._
+
+class DirectiveTest extends FunSuite with Matchers with BeforeAndAfterAll {
+  var testGraph: TestGraph = _
+
+  override def beforeAll = {
+    val config = ConfigFactory.load()
+    testGraph = new EmptyGraph(config)
+    testGraph.open()
+  }
+
+  override def afterAll(): Unit = {
+    testGraph.cleanup()
+  }
+
+  test("transform") {
+    val input = "20170601_A0"
+    val code =
+      """ (s: String) => {
+          val date = s.split("_").head
+          s"http://abc.xy.com/IMG_${date}.png";
+      }
+
+      """.stripMargin
+    val actual = S2Directive.resolveTransform(code, input)
+    val expected = "http://abc.xy.com/IMG_20170601.png";
+
+    actual shouldBe expected
+  }
+}

Reply via email to