Skip to content

Commit

Permalink
Merge pull request #213 from opus-codium/add-test-for-bump
Browse files Browse the repository at this point in the history
Tests: Add tests for bump feature
  • Loading branch information
ekohl authored Apr 21, 2021
2 parents fa002a0 + 6fc8126 commit b6a03bb
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 0 deletions.
10 changes: 10 additions & 0 deletions features/step_definitions/git_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,13 @@
pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace)
pmrr.default_branch = default_branch
end

Then('the puppet module {string} from {string} should have a tag named {string}') do |name, namespace, tag|
pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace)
expect(pmrr.tags).to include(tag)
end

Then('the puppet module {string} from {string} should not have a tag named {string}') do |name, namespace, tag|
pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace)
expect(pmrr.tags).not_to include(tag)
end
87 changes: 87 additions & 0 deletions features/update/bump_version.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
Feature: Bump a new version after an update
Scenario: Bump the module version, update changelog and tag it after an update that produces changes
Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
And the puppet module "puppet-test" from "fakenamespace" has a file named "CHANGELOG.md" with:
"""
## 1965-04-14 - Release 0.4.2
"""
And a file named "config_defaults.yml" with:
"""
---
new-file:
content: aruba
"""
And a directory named "moduleroot"
And a file named "moduleroot/new-file.erb" with:
"""
<%= @configs['content'] %>
"""
When I run `msync update --message "Add new-file" --bump --changelog --tag`
Then the exit status should be 0
And the file named "modules/fakenamespace/puppet-test/new-file" should contain "aruba"
And the stdout should contain:
"""
Bumped to version 0.4.3
"""
And the stdout should contain:
"""
Tagging with 0.4.3
"""
And the file named "modules/fakenamespace/puppet-test/CHANGELOG.md" should contain "0.4.3"
And the puppet module "puppet-test" from "fakenamespace" should have 2 commits made by "Aruba"
And the puppet module "puppet-test" from "fakenamespace" should have a tag named "0.4.3"

Scenario: Bump the module version after an update that produces changes
Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
And a file named "config_defaults.yml" with:
"""
---
new-file:
content: aruba
"""
And a directory named "moduleroot"
And a file named "moduleroot/new-file.erb" with:
"""
<%= @configs['content'] %>
"""
When I run `msync update --message "Add new-file" --bump`
Then the exit status should be 0
And the file named "modules/fakenamespace/puppet-test/new-file" should contain "aruba"
And the stdout should contain:
"""
Bumped to version 0.4.3
"""
And the puppet module "puppet-test" from "fakenamespace" should have 2 commits made by "Aruba"
And the puppet module "puppet-test" from "fakenamespace" should not have a tag named "0.4.3"

Scenario: Bump the module version with changelog update when no CHANGELOG.md is available
Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
And a file named "config_defaults.yml" with:
"""
---
new-file:
content: aruba
"""
And a directory named "moduleroot"
And a file named "moduleroot/new-file.erb" with:
"""
<%= @configs['content'] %>
"""
When I run `msync update --message "Add new-file" --bump --changelog`
Then the exit status should be 0
And the file named "modules/fakenamespace/puppet-test/new-file" should contain "aruba"
And the stdout should contain:
"""
Bumped to version 0.4.3
No CHANGELOG.md file found, not updating.
"""
And the file named "modules/fakenamespace/puppet-test/CHANGELOG.md" should not exist
And the puppet module "puppet-test" from "fakenamespace" should have 2 commits made by "Aruba"

Scenario: Dont bump the module version after an update that produces no changes
Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
And a directory named "moduleroot"
When I run `msync update --message "Add new-file" --bump --tag`
Then the exit status should be 0
And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
And the puppet module "puppet-test" from "fakenamespace" should not have a tag named "0.4.3"
6 changes: 6 additions & 0 deletions spec/helpers/faker/puppet_module_remote_repo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ def commit_count_by(author, commit = nil)
end
end

def tags
FileUtils.chdir(bare_repo_dir) do
return run %w{git tag --list}
end
end

def remote_url
"file://#{bare_repo_dir}"
end
Expand Down

0 comments on commit b6a03bb

Please sign in to comment.