Add tests to verify sorting algorithm #244

This commit is contained in:
Petr Korolev
2015-06-11 13:21:18 +03:00
parent 22d1657fd4
commit 19eb03c54e
5 changed files with 99 additions and 24 deletions
+16
View File
@@ -2,6 +2,8 @@
## [0.0.4](https://github.com/skywinder/changelog_test/tree/0.0.4) (2015-05-22)
[Full Changelog](https://github.com/skywinder/changelog_test/compare/v0.0.3...0.0.4)
**Closed issues:**
- Test issue, that should appear in 0.0.4 [\#3](https://github.com/skywinder/changelog_test/issues/3)
@@ -10,10 +12,24 @@
- Add automatically generated change log file. [\#5](https://github.com/skywinder/changelog_test/pull/5) ([skywinder](https://github.com/skywinder))
## [v0.0.3](https://github.com/skywinder/changelog_test/tree/v0.0.3) (2015-03-04)
[Full Changelog](https://github.com/skywinder/changelog_test/compare/v0.0.2...v0.0.3)
**Merged pull requests:**
- fix \#3. hotfix. Should appear in v0.0.3 [\#4](https://github.com/skywinder/changelog_test/pull/4) ([skywinder](https://github.com/skywinder))
## [v0.0.2](https://github.com/skywinder/changelog_test/tree/v0.0.2) (2015-03-04)
[Full Changelog](https://github.com/skywinder/changelog_test/compare/v0.0.1...v0.0.2)
**Merged pull requests:**
- Here is a test hotfix should appear in v.0.0.2 [\#2](https://github.com/skywinder/changelog_test/pull/2) ([skywinder](https://github.com/skywinder))
## [v0.0.1](https://github.com/skywinder/changelog_test/tree/v0.0.1) (2015-03-02)
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
@@ -5,6 +5,7 @@ module GitHubChangelogGenerator
# @return [String] Generated change log file
def compound_changelog
fetch_and_filter_tags
sort_tags_by_date(@filtered_tags)
fetch_issues_and_pr
log = "# Change Log\n\n"
@@ -129,7 +130,7 @@ module GitHubChangelogGenerator
log = generate_unreleased_section
(1...filtered_tags.size).each do |index|
log += generate_log_between_tags(all_tags[index], all_tags[index - 1])
log += generate_log_between_tags(filtered_tags[index], filtered_tags[index - 1])
end
if @filtered_tags.count != 0
log += generate_log_between_tags(nil, filtered_tags.last)
@@ -4,7 +4,6 @@ module GitHubChangelogGenerator
def fetch_and_filter_tags
@filtered_tags = get_filtered_tags(@fetcher.get_all_tags)
fetch_tags_dates
sort_tags_by_date(@filtered_tags)
end
# Sort all tags by date
@@ -22,11 +21,13 @@ module GitHubChangelogGenerator
def get_time_of_tag(tag_name)
fail ChangelogGeneratorError, "tag_name is nil".red if tag_name.nil?
if @tag_times_hash[tag_name["name"]]
@tag_times_hash[tag_name["name"]]
name_of_tag = tag_name["name"]
time_for_name = @tag_times_hash[name_of_tag]
if !time_for_name.nil?
time_for_name
else
time_string = @fetcher.fetch_date_of_tag tag_name
@tag_times_hash[tag_name["name"]] = time_string
@tag_times_hash[name_of_tag] = time_string
time_string
end
end