|
1 | 1 | """Some tests covering the bump_version code."""
|
2 | 2 |
|
| 3 | +import logging |
| 4 | + |
3 | 5 | import yaml
|
4 | 6 |
|
5 | 7 | import nf_core.pipelines.bump_version
|
@@ -66,3 +68,39 @@ def test_bump_nextflow_version(self):
|
66 | 68 | f"[]"
|
67 | 69 | "(https://www.nextflow.io/)" in readme
|
68 | 70 | )
|
| 71 | + |
| 72 | + def test_bump_pipeline_version_in_snapshot(self): |
| 73 | + """Test that bump version also updates versions in the snapshot.""" |
| 74 | + |
| 75 | + # Create dummy snapshot |
| 76 | + snapshot_dir = self.pipeline_dir / "tests" / "pipeline" |
| 77 | + |
| 78 | + snapshot_dir.mkdir(parents=True, exist_ok=True) |
| 79 | + snapshot_fn = snapshot_dir / "main.nf.test.snap" |
| 80 | + snapshot_fn.touch() |
| 81 | + # write version number in snapshot |
| 82 | + with open(snapshot_fn, "w") as fh: |
| 83 | + fh.write("nf-core/testpipeline=1.0.0dev") |
| 84 | + |
| 85 | + # Bump the version number |
| 86 | + nf_core.pipelines.bump_version.bump_pipeline_version(self.pipeline_obj, "1.1.0") |
| 87 | + |
| 88 | + # Check the snapshot |
| 89 | + with open(snapshot_fn) as fh: |
| 90 | + assert fh.read().strip() == "nf-core/testpipeline=1.1.0" |
| 91 | + |
| 92 | + def test_bump_pipeline_version_in_snapshot_no_version(self): |
| 93 | + """Test that bump version does not update versions in the snapshot if no version is given.""" |
| 94 | + |
| 95 | + # Create dummy snapshot |
| 96 | + snapshot_dir = self.pipeline_dir / "tests" / "pipeline" |
| 97 | + |
| 98 | + snapshot_dir.mkdir(parents=True, exist_ok=True) |
| 99 | + snapshot_fn = snapshot_dir / "main2.nf.test.snap" |
| 100 | + snapshot_fn.touch() |
| 101 | + with open(snapshot_fn, "w") as fh: |
| 102 | + fh.write("test") |
| 103 | + # assert log info message |
| 104 | + self.caplog.set_level(logging.INFO) |
| 105 | + nf_core.pipelines.bump_version.bump_pipeline_version(self.pipeline_obj, "1.1.0") |
| 106 | + assert "Could not find version number in " in self.caplog.text |
0 commit comments