testing with a fake client #80
Replies: 1 comment 1 reply
-
Cool idea! We're a bit limited in what exactly the text of the error message can be, because these type of errors come directly from Serde and aren't hand-written. But this isn't a scenario I've really tested, so there might be some improvements that can be made. To avoid guesswork in what JSON text the SDK is expecting, you can make an instance of the type in question and call
which prints I am interested in how you got the error |
Beta Was this translation helpful? Give feedback.
-
rustc 1.54.0
crate version 0.13.3
I am wanting to test some retry logic. I created a fake client that proxies the request data to a function to respond per test.
All of my functions have a
client: &impl UserAuthClient
or it could be stored on a struct if you like. I also store common JSON blobs on my fake client.this allows me to write a test like
I would personally like to see more explicit example error JSON or better JSON parsing errors. I guessed my way to a winning answer.
NetworkError("Json(Error(\"missing field `.tag`\", line: 8, column: 14))")
add .tags at every level. if you are wrong you will could getNetworkError("Json(Error(\"unknown variant `write`, expected `path`\", line: 5, column: 19))")
.NetworkError("Json(Error(\"unknown field `conflict`, expected one of `malformed_path`, `conflict`, `no_write_permission`, `insufficient_space`, `disallowed_name`, `team_folder`, `operation_suppressed`, `too_many_write_operations`, `other`\", line: 8, column: 14))
I believe this means there should be a sibling node to the .tag with the same name.Thanks for crate!
Beta Was this translation helpful? Give feedback.
All reactions