{"repo":"dnaeon/go-vcr","free":true,"listed":false,"github":"https://github.com/dnaeon/go-vcr","clone":"git clone https://github.com/dnaeon/go-vcr.git","description":"Record and replay your HTTP interactions for fast, deterministic and accurate tests","language":"Go","stars":1394,"topics":["go","golang","testing"],"license":"BSD-2-Clause","category":"dev-tools","readme_excerpt":"go-vcr go-vcr simplifies testing by recording your HTTP interactions and replaying them in future runs in order to provide fast, deterministic and accurate testing of your code. go-vcr was inspired by the VCR library for Ruby. Installation Install go-vcr by executing the command below: Note, that if you are migrating from a previous version of go-vcr , you may need to re-create your tests cassettes. Usage A quick example of using go-vcr . Running this test code for the first time will result in creating the testdata/TestHelloWorld.yaml cassette, which will contain the recorded HTTP interaction between our HTTP client and the remote server. When we execute this test next time, what would happen is that go-vcr will replay the already recorded HTTP interactions from the cassette, instead of making actual external calls. Please also check the examples directory from this repo for complete and ready to run examples. You can also refer to the test cases for additional examples. Custom YAML Marshaling Function If you need control how YAML is encoded, set WithMarshalFunc with a custom func. This defaults to yaml.Marshal . Custom Request Matching During replay mode, you can customize the way incoming requests are matched against the recorded request/response pairs by defining a recorder.MatcherFunc function. For example, the following matcher will match on method, URL and body: Hooks Hooks in go-vcr are regular functions which take an HTTP interaction and are invoked at different stag","default_branch":null,"files":null,"tree":[],"storefront":"/r/dnaeon","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/dnaeon/go-vcr/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}