diff --git a/providertests/recorder_test.go b/providertests/recorder_test.go index f1710e7cd6b9867ad1deab70f86240a103f3c5b3..cf74fce496639f155175b45dee1fadf11f2c7822 100644 --- a/providertests/recorder_test.go +++ b/providertests/recorder_test.go @@ -8,6 +8,7 @@ import ( "strings" "testing" + "go.yaml.in/yaml/v4" "gopkg.in/dnaeon/go-vcr.v4/pkg/cassette" "gopkg.in/dnaeon/go-vcr.v4/pkg/recorder" ) @@ -19,6 +20,7 @@ func newRecorder(t *testing.T) *recorder.Recorder { cassetteName, recorder.WithMode(recorder.ModeRecordOnce), recorder.WithMatcher(customMatcher(t)), + recorder.WithMarshalFunc(marshalFunc), recorder.WithSkipRequestLatency(true), // disable sleep to simulate response time, makes tests faster recorder.WithHook(hookRemoveHeaders, recorder.AfterCaptureHook), ) @@ -54,6 +56,16 @@ func customMatcher(t *testing.T) recorder.MatcherFunc { } } +func marshalFunc(in any) ([]byte, error) { + var buff bytes.Buffer + enc := yaml.NewEncoder(&buff) + enc.CompactSeqIndent() + if err := enc.Encode(in); err != nil { + return nil, err + } + return buff.Bytes(), nil +} + var headersToKeep = map[string]struct{}{ "accept": {}, "content-type": {},