Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
anton-k committed Nov 11, 2023
1 parent f7258d5 commit 8ba12af
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions mig/test/Test/Server/Hello.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ specBy finder = do
it "wrong output media type" $ do
serverFun (helloReq{Request.headers = Map.fromList [("Accept", "text/html")]}) `shouldReturn` Nothing

helloReq = emptyReq{path = ["api", "v1", "hello"]}
helloReq = emptyReq{Request.path = ["api", "v1", "hello"]}
helloResp = Just $ jsonResp @Text "hello"

byeReq = emptyReq{path = ["api", "v1", "bye"]}
byeReq = emptyReq{Request.path = ["api", "v1", "bye"]}
byeResp = Just $ jsonResp @Text "bye"

wrongPathReq = emptyReq{path = ["api", "v2", "hello"]}
wrongPathReq = emptyReq{Request.path = ["api", "v2", "hello"]}
26 changes: 13 additions & 13 deletions mig/test/Test/Server/RouteArgs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,14 @@ specBy finder = do
queryReq :: Request
queryReq =
emptyReq
{ path = ["api", "succ", "query"]
{ Request.path = ["api", "succ", "query"]
, query = toQuery @Int "value" 1
}

twoQueryReq :: Int -> Int -> Request
twoQueryReq a b =
emptyReq
{ path = ["api", "add"]
{ Request.path = ["api", "add"]
, query = toQuery "a" a <> toQuery "b" b
}

Expand All @@ -228,7 +228,7 @@ specBy finder = do
optionalQueryReq :: Request
optionalQueryReq =
emptyReq
{ path = ["api", "succ", "optional"]
{ Request.path = ["api", "succ", "optional"]
, query = toQuery @Int "value" 1
}

Expand All @@ -244,7 +244,7 @@ specBy finder = do
queryFlagReq :: Maybe Bool -> Int -> Int -> Request
queryFlagReq mFlag a b =
emptyReq
{ path = ["api", "add-if"]
{ Request.path = ["api", "add-if"]
, query = mconcat [toQuery "a" a, toQuery "b" b] <> maybe mempty (toQuery "perform") mFlag
}

Expand All @@ -260,7 +260,7 @@ specBy finder = do
headerReq :: Request
headerReq =
emptyReq
{ path = ["api", "succ", "header"]
{ Request.path = ["api", "succ", "header"]
, Request.headers = Map.singleton "value" (BL.toStrict $ Json.encode @Int 1)
}

Expand All @@ -275,7 +275,7 @@ specBy finder = do
optionalHeaderReq :: Request
optionalHeaderReq =
emptyReq
{ path = ["api", "succ", "optional-header"]
{ Request.path = ["api", "succ", "optional-header"]
, Request.headers = Map.singleton "value" (BL.toStrict $ Json.encode @Int 1)
}

Expand All @@ -292,7 +292,7 @@ specBy finder = do
captureReq :: [Int] -> Request
captureReq args =
emptyReq
{ path = ["api", "mul"] <> fmap (Text.pack . show) args
{ Request.path = ["api", "mul"] <> fmap (Text.pack . show) args
}

-- body
Expand All @@ -309,7 +309,7 @@ specBy finder = do
bodyReq :: Method -> Int -> Int -> Request
bodyReq reqMethod a b =
emptyReq
{ path = ["api", "add-json"]
{ Request.path = ["api", "add-json"]
, method = reqMethod
, readBody = pure $ Right $ Json.encode $ AddInput a b
, Request.headers = jsonHeaders
Expand All @@ -318,15 +318,15 @@ specBy finder = do
noBodyReq :: Request
noBodyReq =
emptyReq
{ path = ["api", "add-json"]
{ Request.path = ["api", "add-json"]
, method = methodPost
, Request.headers = jsonHeaders
}

sqrtBodyReq :: Float -> Request
sqrtBodyReq a =
emptyReq
{ path = ["api", "square-root"]
{ Request.path = ["api", "square-root"]
, method = methodPost
, readBody = pure $ Right $ Json.encode a
, Request.headers = jsonHeaders
Expand All @@ -345,7 +345,7 @@ specBy finder = do
statusReq :: Request
statusReq =
emptyReq
{ path = ["api", "response", "status"]
{ Request.path = ["api", "response", "status"]
}

-- response headers
Expand All @@ -365,7 +365,7 @@ specBy finder = do
customHeaderReq :: Text -> Text -> Request
customHeaderReq name value =
emptyReq
{ path = ["api", "response", "header", name, value]
{ Request.path = ["api", "response", "header", name, value]
}

-- response errors
Expand All @@ -390,5 +390,5 @@ specBy finder = do
customErrorReq :: [Text] -> Request
customErrorReq args =
emptyReq
{ path = ["api", "response"] <> args
{ Request.path = ["api", "response"] <> args
}

0 comments on commit 8ba12af

Please sign in to comment.