Bogdanp / Bogdanp/racket-http-easy

Possibility: simulated / replayed requests for testing client code

Offen
#3 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
enhancement
Vorherrschende Sprache
Racket
Sterne
52
Forks
6
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

First of all, thank you for bringing this wonderful package to life.

Now, there's one use case that I don't currently see covered - a way to have something custom "in-between" the API and the network, something that could, for instance:

1. Record a response in some predefined local storage in addition to returning it, and then replay the response for any request that is identical. This could be used to build something like python's [betamax](https://betamax.readthedocs.io/en/latest/#what-does-it-even-do) package.
2. Provide ways to simulate the responses in some other way, maybe by defining one's own "replacement" response-generating callbacks.
3. Provide ways to inspect the request(s), in addition to 1 and/or 2.

Such functionality could be useful if it could happen invisibly to the calling code, so that one could reproducibly test client code that is performing HTTP requests with real response data, but without actually talking to the network.

With the [request](https://docs.racket-lang.org/request/index.html) package this can be achieved by using the parametrized API, where a requester can be swapped in by the `with-requester` form. I'm [relying on this](https://gitlab.com/yurb/lambdagrade/-/blob/c5533d1096cdc59cd30e8856622ef03c2a636732/test/network.rkt#L83) to [test with recorded responses](https://gitlab.com/yurb/lambdagrade/-/blob/081d4142e56f67993b0b7590f920b372968b5b14/test/diskette-requester.rkt) in my little (newbie) racket project.

So this is my humble feature suggestion, although I'm not sure if I'm missing something obvious that would make all of this unnecessary to achieve the described goals.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.