refactor: Provide API to stop listener programatically#4860
refactor: Provide API to stop listener programatically#4860mkleczek wants to merge 1 commit intoPostgREST:mainfrom
Conversation
8c74fa5 to
0c7dea1
Compare
|
I'm not a fan of exposing internal APIs just for tests - that means we're shipping code that we don't actually need. Is it a requirement to test this from hspec? Can't we observe the same thing in an IO test? |
Me neither but in this particular case, I'd say there is more to it. The direct reason for this change is to be able to test from
This is a longer discussion started here: #4668 (comment) Testing in Answering directly: no, there is no requirement to test from |
0c7dea1 to
a191f8d
Compare
Note: we're already doing this for the postgrest/src/PostgREST/SchemaCache.hs Lines 171 to 173 in 127490e I've been thinking, couldn't we do these points of failure/testing based on That would allow us to not ship the testing code in the binaries, we would only inject the sleeps (and other things) during testing via a callback. |
a191f8d to
0384435
Compare
eeb776d to
193e210
Compare
This change introduces possibility to stop listener thread programatically. It is a prerequisite for HSpec tests starting the listener as they have to be able to stop it when cleaning up.
193e210 to
49941fb
Compare
I looked at this from a perspective of "what would I do from non-hspec tests, for example pytest, to start/stop the listener?". It seems like |
I believe it is not - there is no code that would stop/start listener thread upon config reload. If it is marked as such in the docs it is a documentation issue. |
Interesting, I was going by the docs only. Maybe we can fix the code instead of the documentation then, to make it reloadable? |
DISCLAIMER:
This commit was authored entirely by a human without the assistance of LLMs.
This change introduces possibility to stop listener thread programatically. It is a prerequisite for HSpec tests starting the listener as they have to be able to stop it when cleaning up.