Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

naming a snapshot section mapping omits it from the snapshot? #279

Open
TCLamnidis opened this issue Dec 6, 2024 · 2 comments
Open

naming a snapshot section mapping omits it from the snapshot? #279

TCLamnidis opened this issue Dec 6, 2024 · 2 comments

Comments

@TCLamnidis
Copy link

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 TCLamnidis changed the title naming a snapshop mapping omits it from the snapshot? naming a snapshot section mapping omits it from the snapshot? Dec 6, 2024
@lukfor
Copy link
Collaborator

lukfor commented Dec 6, 2024

Thanks for catching this! It seems that we exclude a property called mapping from the snapshot object, which influences this behaviour (see

JsonGenerator jsonGenerator = new JsonGenerator.Options().excludeFieldsByName("mapping")
). I will check this and try to fix it. 👍

@TCLamnidis
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants