Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ nri-http/nri-http.cabal: nri-http/package.yaml
ghcid-nri-http: nri-http/nri-http.cabal
cd nri-http && ghcid

ghcid-nri-http-test: nri-http/nri-http.cabal
cd nri-http && ghcid --command "cabal repl nri-http:test:spec" --test Main.main

nri-kafka/nri-kafka.cabal: nri-kafka/package.yaml
hpack nri-kafka

Expand Down
6 changes: 3 additions & 3 deletions nri-http/src/Http/Mock.hs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ tryRespond [] req =
handleCustomResponse :: (Internal.Response s -> Result e expect) -> Task e (a, expect)
handleCustomResponse f = case f (Internal.NetworkError_ msg) of
Err err -> Task.fail err
Ok _ -> Debug.todo "Since we manually craft the Response as an Error, this case will not run."
Ok _ -> Debug.todo msg
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Developer: "This thing will not happen"...
Real world: Thing happens
😅

Copy link
Member Author

@omnibs omnibs Aug 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's super weird is this was not happening on your branch in the monorepo

you were getting a message saying "no stub for GoogleWhatevsResponse" instead of hitting the Debug.todo

here in haskell-libraries i was hitting the Debug.todo

in case Internal.expect req of
Internal.ExpectJson ->
Task.fail (Internal.NetworkError msg)
Expand All @@ -178,7 +178,7 @@ tryRespond (Stub respond : rest) req =
|> Maybe.andThen Dynamic.fromDynamic
|> Maybe.withDefault (tryRespond rest req)

printType :: (Dynamic.Typeable expect) => proxy expect -> Text
printType :: (Dynamic.Typeable expect) => expect -> Text
printType expect =
Type.Reflection.someTypeRep expect
Type.Reflection.typeOf expect
|> Debug.toString
26 changes: 26 additions & 0 deletions nri-http/test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,32 @@ tests =
)
urlsAccessed
|> Expect.equal ["example.com/one", "example.com/two"],
test "Http.Mock.stub binary" <| \_ -> do
urlsAccessed <-
Http.Mock.stub
[ Http.Mock.mkStub
( \(req :: Http.Request Text) ->
-- Note the error type here 👇
-- doesn't match the code under test
Task.succeed (Http.url req, "dsa") :: Task Http.Error (Text, Text)
)
]
( \http ->
Expect.succeeds <| do
_ <-
Http.get
http
"example.com/one"
( Http.expectBytesResponse
( \_ ->
-- see? a different error type 👇
(Ok ("asd" :: Text)) :: Result () Text
)
)
Task.succeed ()
)
urlsAccessed
|> Expect.equal ["example.com/one"],
test "Using expectTextResponse, metadata returns the correct status" <| \() ->
withServer
(constant "Some text" Status.ok200)
Expand Down
4 changes: 2 additions & 2 deletions nri-http/test/golden-results-9.8/expected-http-span
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ TracingSpan
{ srcLocPackage = "nri-http-0.6.0.0-inplace-spec"
, srcLocModule = "Main"
, srcLocFile = "test/Main.hs"
, srcLocStartLine = 234
, srcLocStartLine = 247
, srcLocStartCol = 7
, srcLocEndLine = 234
, srcLocEndLine = 247
, srcLocEndCol = 33
}
)
Expand Down