pdjohntony / vcrpy-cassette-mgr

Easily open or delete vcrpy cassettes within your tests.
MIT License
0 stars 0 forks source link

Multiple cassettes found when tests have same base name #2

Closed pdjohntony closed 7 months ago

pdjohntony commented 7 months ago

This issue is a result of fixing #1 in v1.1.2.

Now that cassette searching can match multiple files for a single test, if two tests share the same base name, the wrong cassette can be matched for a test.

Here is the new cassette matching code:

const matchingFiles = files.filter(file => file.startsWith(`${vcrDecorator.vcrTestName}`) && file.endsWith('.yaml'));

Here are some example test names:

test_msteams_service_emergency_address_create
test_msteams_service_emergency_address_create_without_latlon

These overlapping names will cause test_msteams_service_emergency_address_create to also match the cassettes for test_msteams_service_emergency_address_create_without_latlon.

This is also causing an issue during the deleteCassettesCurrentFile command. Where the same cassettes can become duplicated in the currentFileCassettesArray and will cause subsequent deletion failures.

pdjohntony commented 7 months ago

Fixed in 1.1.3