Skip to content

Commit

Permalink
Change way of handling platform specific tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bartlomiej.zylinski committed May 27, 2024
1 parent 3eca264 commit 51b87b5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion core/src/test/scala/sttp/model/UriTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import sttp.model.internal.UriCompatibility

import java.net.URI

class UriTests extends AnyFunSuite with Matchers with TryValues {
class UriTests extends AnyFunSuite with Matchers with TryValues with UriTestsExtension {

val HS = HostSegment
val PS = PathSegment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,14 @@ import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers
import sttp.model.Uri._

class UriTestsHelper extends AnyFunSuite with Matchers with TryValues {
trait UriTestsExtension extends AnyFunSuite with Matchers with TryValues { this: UriTests =>

val QS = QuerySegment

val testUri = Uri.unsafeApply("http", None, "example.com", None, Nil, Nil, None)

val querySegmentsTestData = List(
private val tildeEncodingTest = List(
List(QS.KeyValue("k", "v1~v2", valueEncoding = QuerySegmentEncoding.All)) -> "k=v1~v2"
)

for {
(segments, expected) <- querySegmentsTestData
(segments, expected) <- tildeEncodingTest
} {
test(s"$segments should serialize to$expected") {
testUri.copy(querySegments = segments).toString should endWith(expected)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,14 @@ import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers
import sttp.model.Uri._

class UriTestsHelper extends AnyFunSuite with Matchers with TryValues {
trait UriTestsExtension extends AnyFunSuite with Matchers with TryValues { this: UriTests =>

val QS = QuerySegment

val testUri = Uri.unsafeApply("http", None, "example.com", None, Nil, Nil, None)

val querySegmentsTestData = List(
private val tildeEncodingTest = List(
List(QS.KeyValue("k", "v1~v2", valueEncoding = QuerySegmentEncoding.All)) -> "k=v1%7Ev2"
)

for {
(segments, expected) <- querySegmentsTestData
(segments, expected) <- tildeEncodingTest
} {
test(s"$segments should serialize to$expected") {
testUri.copy(querySegments = segments).toString should endWith(expected)
Expand Down
8 changes: 8 additions & 0 deletions core/src/test/scalanative/sttp/model/UriTestsExtension.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package sttp.model

import org.scalatest.TryValues
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers
import sttp.model.Uri._

trait UriTestsExtension

0 comments on commit 51b87b5

Please sign in to comment.