2019-04-25 17:13:04 +00:00
|
|
|
module Test.HTTPure.VersionSpec where
|
|
|
|
|
|
|
|
import Prelude
|
2022-05-04 21:02:29 +00:00
|
|
|
|
2021-11-19 06:16:35 +00:00
|
|
|
import HTTPure.Version
|
|
|
|
( Version(HTTP0_9, HTTP1_0, HTTP1_1, HTTP2_0, HTTP3_0, Other)
|
|
|
|
, read
|
|
|
|
)
|
2022-05-04 21:02:29 +00:00
|
|
|
import Test.HTTPure.TestHelpers (Test, mockRequest, (?=))
|
|
|
|
import Test.Spec (describe, it)
|
2019-04-25 17:13:04 +00:00
|
|
|
|
2021-11-19 06:16:35 +00:00
|
|
|
showSpec :: Test
|
2021-03-22 19:02:36 +00:00
|
|
|
showSpec =
|
2021-11-19 06:16:35 +00:00
|
|
|
describe "show" do
|
|
|
|
describe "with an HTTP0_9" do
|
|
|
|
it "is 'HTTP0_9'" do
|
|
|
|
show HTTP0_9 ?= "HTTP/0.9"
|
|
|
|
describe "with an HTTP1_0" do
|
|
|
|
it "is 'HTTP1_0'" do
|
|
|
|
show HTTP1_0 ?= "HTTP/1.0"
|
|
|
|
describe "with an HTTP1_1" do
|
|
|
|
it "is 'HTTP1_1'" do
|
|
|
|
show HTTP1_1 ?= "HTTP/1.1"
|
|
|
|
describe "with an HTTP2_0" do
|
|
|
|
it "is 'HTTP2_0'" do
|
|
|
|
show HTTP2_0 ?= "HTTP/2.0"
|
|
|
|
describe "with an HTTP3_0" do
|
|
|
|
it "is 'HTTP3_0'" do
|
|
|
|
show HTTP3_0 ?= "HTTP/3.0"
|
|
|
|
describe "with an Other" do
|
|
|
|
it "is 'Other'" do
|
|
|
|
show (Other "version") ?= "HTTP/version"
|
2019-04-25 17:13:04 +00:00
|
|
|
|
2021-11-19 06:16:35 +00:00
|
|
|
readSpec :: Test
|
2021-03-22 19:02:36 +00:00
|
|
|
readSpec =
|
2021-11-19 06:16:35 +00:00
|
|
|
describe "read" do
|
|
|
|
describe "with an 'HTTP0_9' Request" do
|
|
|
|
it "is HTTP0_9" do
|
|
|
|
request <- mockRequest "0.9" "" "" "" []
|
|
|
|
read request ?= HTTP0_9
|
|
|
|
describe "with an 'HTTP1_0' Request" do
|
|
|
|
it "is HTTP1_0" do
|
|
|
|
request <- mockRequest "1.0" "" "" "" []
|
|
|
|
read request ?= HTTP1_0
|
|
|
|
describe "with an 'HTTP1_1' Request" do
|
|
|
|
it "is HTTP1_1" do
|
|
|
|
request <- mockRequest "1.1" "" "" "" []
|
|
|
|
read request ?= HTTP1_1
|
|
|
|
describe "with an 'HTTP2_0' Request" do
|
|
|
|
it "is HTTP2_0" do
|
|
|
|
request <- mockRequest "2.0" "" "" "" []
|
|
|
|
read request ?= HTTP2_0
|
|
|
|
describe "with an 'HTTP3_0' Request" do
|
|
|
|
it "is HTTP3_0" do
|
|
|
|
request <- mockRequest "3.0" "" "" "" []
|
|
|
|
read request ?= HTTP3_0
|
|
|
|
describe "with an 'Other' Request" do
|
|
|
|
it "is Other" do
|
|
|
|
request <- mockRequest "version" "" "" "" []
|
|
|
|
read request ?= Other "version"
|
2019-04-25 17:13:04 +00:00
|
|
|
|
2021-11-19 06:16:35 +00:00
|
|
|
versionSpec :: Test
|
2021-03-22 19:02:36 +00:00
|
|
|
versionSpec =
|
2021-11-19 06:16:35 +00:00
|
|
|
describe "Version" do
|
2021-03-22 19:02:36 +00:00
|
|
|
showSpec
|
|
|
|
readSpec
|