-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move java scheme generators to SchemeSpec (#944)
* refactor: move java scheme generators to SchemeSpec * refactor: resolve PR comments
- Loading branch information
1 parent
1e8d81b
commit 1ebc70f
Showing
2 changed files
with
10 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,33 @@ | ||
package zhttp.http | ||
|
||
import io.netty.handler.codec.http.HttpScheme | ||
import io.netty.handler.codec.http.websocketx.WebSocketScheme | ||
import zhttp.internal.HttpGen | ||
import zio.test._ | ||
|
||
object SchemeSpec extends DefaultRunnableSpec { | ||
def schemeSpec = suite("SchemeSpec") { | ||
override def spec = suite("SchemeSpec") { | ||
testM("string") { | ||
checkAll(HttpGen.scheme) { scheme => | ||
assertTrue(Scheme.decode(scheme.encode).get == scheme) | ||
} | ||
} + | ||
testM("java http scheme") { | ||
checkAll(HttpGen.jHttpScheme) { jHttpScheme => | ||
checkAll(jHttpScheme) { jHttpScheme => | ||
assertTrue(Scheme.fromJScheme(jHttpScheme).flatMap(_.toJHttpScheme).get == jHttpScheme) | ||
} | ||
} + | ||
testM("java websocket scheme") { | ||
checkAll(HttpGen.jWebSocketScheme) { jWebSocketScheme => | ||
checkAll(jWebSocketScheme) { jWebSocketScheme => | ||
assertTrue( | ||
Scheme.fromJScheme(jWebSocketScheme).flatMap(_.toWebSocketScheme).get == jWebSocketScheme, | ||
) | ||
} | ||
} | ||
} | ||
|
||
override def spec = schemeSpec | ||
private def jHttpScheme: Gen[Any, HttpScheme] = Gen.fromIterable(List(HttpScheme.HTTP, HttpScheme.HTTPS)) | ||
|
||
private def jWebSocketScheme: Gen[Any, WebSocketScheme] = | ||
Gen.fromIterable(List(WebSocketScheme.WS, WebSocketScheme.WSS)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1ebc70f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 Performance Benchmark:
Concurrency: 256
Requests/sec: 917690.42