-
Notifications
You must be signed in to change notification settings - Fork 412
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor: HttpRunnableSpec clean up (#857)
* refactor: reduce HttpRunnableSpec boilerplate * refactor: remove all helpers from HttpRunnableSpec and inline the method * doc: update documentation for test module * refactor: add type-constraints to Http for specialized methods * refactor: use IsResponse type constraint * style(*): apply scala fmt * doc: update documentation
- Loading branch information
Tushar Mathur
authored
Jan 25, 2022
1 parent
0ee6dde
commit dc0d80f
Showing
8 changed files
with
223 additions
and
160 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
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package zhttp.http | ||
|
||
import io.netty.buffer.ByteBuf | ||
import zhttp.service.Client.ClientResponse | ||
import zio.Task | ||
|
||
sealed trait IsResponse[-A] { | ||
def getBodyAsByteBuf(a: A): Task[ByteBuf] | ||
def getHeaders(a: A): Headers | ||
def getStatus(a: A): Status | ||
} | ||
|
||
object IsResponse { | ||
implicit object serverResponse extends IsResponse[Response] { | ||
def getBodyAsByteBuf(a: Response): Task[ByteBuf] = a.getBodyAsByteBuf | ||
def getHeaders(a: Response): Headers = a.headers | ||
def getStatus(a: Response): Status = a.status | ||
} | ||
|
||
implicit object clientResponse extends IsResponse[ClientResponse] { | ||
def getBodyAsByteBuf(a: ClientResponse): Task[ByteBuf] = a.getBodyAsByteBuf | ||
def getHeaders(a: ClientResponse): Headers = a.headers | ||
def getStatus(a: ClientResponse): Status = a.status | ||
} | ||
} |
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
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
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
Oops, something went wrong.