Skip to content

v2.1.0 NewAsMode fails with ModeReplaying and missing cassette file #72

Closed
@JVecsei

Description

The latest minor version update contained a breaking change in the NewAsMode function.

// Check if the cassette exists
if _, err := os.Stat(cassetteFile); os.IsNotExist(err) {
// Replaying mode should fail if no cassette exists
if mode == ModeReplaying {
return nil, cassette.ErrCassetteNotFound
}

In the previous version we were using (v.2.0.1), this function just created an empty cassette if there was no cassette file found with the given name. With v2.1.0 this behavior changed and calling NewAsMode using ModeReplaying in combination with a non-existing cassette filename returns an error.
Especially in test scenarios where the recorder is just setup in a SetupTest method for all tests, independent of whether all test methods execute an outgoing http call, this is an undesired behavior.

Could we get this function backwards compatible by introducing a flag which defines whether a missing cassette file should return an error?

Thanks in advance!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions