An open API service providing package, version and dependency metadata of many open source software ecosystems and registries.

Top 8.2% on proxy.golang.org

proxy.golang.org : github.com/qjpcpu/dvr

Package dvr attempts to make testing far easier by allowing calls to remote HTTP services to be captured and replayed when running the tests a second time. In recording mode (-dvr.record) each request will be captured and recorded to a file (-dvr.file, which defaults to testdata/archive.dvr). In replay mode each request will be matched against of the requests in the archive. This ensures that a unit test can remove all dependencies on remote services while running, which is ideal for most testing environments. Note that this library works be replaying net.http's DefaultTransport with one that will intercept queries. If you are using a custom client, or replacing the http.DefaultTransport you may need to sub a RoundTripper from this package in place. All common error types will be preserved and returned via the archive, however some types can not be restored due to the way that gob works. In these cases an error will be returned that satisfies the error interface but it will be a different type. When in replay mode requests are matched if all of the following are the same: URL, Body, Headers, Trailers. If all of these elements are the same as a recorded request then the response will be returned to the client. If no request matches then the test will panic since re-requesting may cause all sorts of issues. If this matching strategy is not sufficient then you can make value Match() contain a function that can parse two requests and establish if they are the same. This library is intended to be user during unit testing so much of its design is wrapped around this, and while it can be used outside of unit tests it is strongly not recommended. For the most basic of use cases you need only ensure that the dvr library is included in your test file. Including it with an underscore, like in this example, is all that is necessary to get it in place.

Registry - Source - Documentation - JSON
purl: pkg:golang/github.com/qjpcpu/dvr
License: Apache-2.0
Latest release: almost 9 years ago
First release: almost 9 years ago
Namespace: github.com/qjpcpu
Stars: 0 on GitHub
Forks: 0 on GitHub
See more repository details: repos.ecosyste.ms
Last synced: 6 days ago

    Loading...
    Readme
    Loading...