nf-test icon indicating copy to clipboard operation
nf-test copied to clipboard

naming a snapshot section `mapping` omits it from the snapshot?

Open TCLamnidis opened this issue 1 year ago • 2 comments

I am using nft-utils to collect a set of files from the output of my pipeline, and then test them for consistency in content or name using nf-test.

Here's part of the test code.

then {
  //Mapping
  def stable_content_mapping          = getAllFilesFromDir("$outputDir/mapping", true , null, null, ['**/*.flagstat'] )
  def stable_name_mapping             = getAllFilesFromDir("$outputDir/mapping", true , null, null, ['**/*.{bam,bai}'] )
  assertAll(
    { assert workflow.success },
    { assert snapshot( stable_content_mapping, stable_name_mapping*.name).match("mapping") },
  )
}

I run my test and get the following output:

$ nf-test test --tag test --profile docker,test --update-snapshot

🚀 nf-test 0.8.4
https://code.askimed.com/nf-test
(c) 2021 - 2024 Lukas Forer and Sebastian Schoenherr

Load .nf-test/plugins/nft-bam/0.3.0/nft-bam-0.3.0.jar
Load .nf-test/plugins/nft-utils/0.0.3/nft-utils-0.0.3.jar
Found 1 files in test directory.
Warning: every snapshot that fails during this test run is re-record.

Test pipeline: NFCORE_EAGER

  Test [cc0bd237] 'test_profile' PASSED (138.503s)
  Snapshots:
    1 created [mapping]


Snapshot Summary:
  1 created

SUCCESS: Executed 1 tests in 138.509s

But the produced snapshot contains no mapping section.

I found that changing the assertion name to .match("mapping_output") fixes the issue and the mapping_output section of the snapshot appears, as expected.

I am unsure why this happens, and have found a workaround, but I am curious why this happens to begin with. Is mapping implicitly ignored in snapshots for some reason?

TCLamnidis avatar Dec 06 '24 10:12 TCLamnidis

Thanks for catching this! It seems that we exclude a property called mapping from the snapshot object, which influences this behaviour (see https://github.com/askimed/nf-test/blob/1ed4d99e18df6bd311252cf74c645cc9f78f9248/src/main/java/com/askimed/nf/test/lang/extensions/SnapshotFile.java#L146). I will check this and try to fix it. 👍

lukfor avatar Dec 06 '24 10:12 lukfor

Oh thanks for the explanation! 😄 I'd personally be happy with even just a warning when mapping exists in the snapshot. Renaming the section is easy to do, if one knows that name is reserved.

TCLamnidis avatar Dec 06 '24 10:12 TCLamnidis