aboutsummaryrefslogtreecommitdiff
path: root/tests/src/test/scala/com/softwaremill/sttp/UriInterpolatorTests.scala
blob: 57bb6afb05c5bd309cfbe2e9104bb0564bee0be6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package com.softwaremill.sttp

import java.net.URI

import org.scalatest.{FlatSpec, Matchers}

class UriInterpolatorTests extends FlatSpec with Matchers {
  val v1 = "y"
  val v2 = "a c"
  val v2encoded = "a%20c"

  val testData: List[(URI, String)] = List(
    (uri"http://example.com", "http://example.com"),
    (uri"http://example.com?x=y", "http://example.com?x=y"),
    (uri"http://example.com?x=$v1", s"http://example.com?x=$v1"),
    (uri"http://example.com?x=$v2", s"http://example.com?x=$v2encoded")
  )

  for (((interpolated, expected), i) <- testData.zipWithIndex) {
    it should s"interpolate to $expected ($i)" in {
      interpolated should be (new URI(expected))
    }
  }
}