Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubwro committed Oct 4, 2023
1 parent 19f7c12 commit b0073b3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
20 changes: 19 additions & 1 deletion test/connection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,28 @@ end
@testset "Method error hints." begin
nc = NATS.connect()

@test_throws MethodError subscribe("SOME.THING") do msg::Float64
hint = """To use `Type{Float64}` as parameter of subscription handler apropriate conversion from `Type{NATS.Msg}` must be provided.
```
import Base: convert
function convert(::Type{Type{Float64}}, msg::Union{NATS.Msg, NATS.HMsg})
# Implement conversion logic here.
end
"""
@test_throws hint subscribe("SOME.THING") do msg::Float64
put!(c, msg)
end
@test_throws MethodError request("SOME.REQUESTS"; payload = 4)
hint = """Object of type `Int64` cannot be serialized into payload."""
@test_throws hint request("SOME.REQUESTS", 4) # TODO: in this case there should be rather warning about missing payload.
hint = """To use `Type{Integer}` as parameter of subscription handler apropriate conversion from `Type{NATS.Msg}` must be provided.
```
import Base: convert
function convert(::Type{Type{Integer}}, msg::Union{NATS.Msg, NATS.HMsg})
# Implement conversion logic here.
end
"""
@test_throws MethodError reply("SOME.REQUESTS") do msg::Integer
"Received $msg"
end
Expand Down
1 change: 1 addition & 0 deletions test/reqreply.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ end
"Reply from service 2."
end
results = request(subject, "This is request payload", 2)
sleep(1)
unsubscribe(sub1)
unsubscribe(sub2)
sleep(0.1)
Expand Down

0 comments on commit b0073b3

Please sign in to comment.