Skip to content

Commit

Permalink
Ensure empty version is properly handled
Browse files Browse the repository at this point in the history
  • Loading branch information
Colin-b committed May 21, 2021
1 parent cb0ee86 commit d1aa49d
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<a href="https://travis-ci.com/Colin-b/keepachangelog"><img alt="Build status" src="https://api.travis-ci.com/Colin-b/keepachangelog.svg?branch=master"></a>
<a href="https://travis-ci.com/Colin-b/keepachangelog"><img alt="Coverage" src="https://img.shields.io/badge/coverage-100%25-brightgreen"></a>
<a href="https://github.com/psf/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
<a href="https://travis-ci.com/Colin-b/keepachangelog"><img alt="Number of tests" src="https://img.shields.io/badge/tests-30 passed-blue"></a>
<a href="https://travis-ci.com/Colin-b/keepachangelog"><img alt="Number of tests" src="https://img.shields.io/badge/tests-31 passed-blue"></a>
<a href="https://pypi.org/project/keepachangelog/"><img alt="Number of downloads" src="https://img.shields.io/pypi/dm/keepachangelog"></a>
</p>

Expand Down
67 changes: 67 additions & 0 deletions tests/test_changelog_empty_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import os
import os.path

import pytest

import keepachangelog


@pytest.fixture
def changelog(tmpdir):
changelog_file_path = os.path.join(tmpdir, "CHANGELOG.md")
with open(changelog_file_path, "wt") as file:
file.write(
"""# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
## [] - 2018-06-01
### Changed
- Release note 1.
- Release note 2.
### Fixed
- Bug fix 1
- sub bug 1
- sub bug 2
- Bug fix 2
### Security
- Known issue 1
- Known issue 2
### Deprecated
- Deprecated feature 1
- Future removal 2
### Removed
- Deprecated feature 2
- Future removal 1
"""
)
return changelog_file_path


def test_changelog_with_empty_version(changelog):
assert keepachangelog.to_dict(changelog) == {
"": {
"changed": ["Release note 1.", "Release note 2."],
"deprecated": ["Deprecated feature 1", "Future removal 2"],
"fixed": ["Bug fix 1", "sub bug 1", "sub bug 2", "Bug fix 2"],
"release_date": "2018-06-01",
"removed": ["Deprecated feature 2", "Future removal 1"],
"security": ["Known issue 1", "Known issue 2"],
"version": "",
"semantic_version": {
"buildmetadata": None,
"major": 0,
"minor": 0,
"patch": 0,
"prerelease": None,
},
},
}

0 comments on commit d1aa49d

Please sign in to comment.