-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #202 from opus-codium/improve-tests
Improve tests capabilities by using local/fake remote repositories
- Loading branch information
Showing
9 changed files
with
373 additions
and
388 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
default: --publish-quiet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,75 @@ | ||
Given 'a mocked git configuration' do | ||
steps %( | ||
Given a mocked home directory | ||
And I run `git config --global user.name Test` | ||
And I run `git config --global user.email test@example.com` | ||
) | ||
end | ||
require_relative '../../spec/helpers/faker/puppet_module_remote_repo' | ||
|
||
Given 'a remote module repository' do | ||
Given 'a basic setup with a puppet module {string} from {string}' do |name, namespace| | ||
steps %( | ||
Given a directory named "sources" | ||
And I run `git clone https://github.com/maestrodev/puppet-test sources/puppet-test` | ||
Given a mocked git configuration | ||
And a puppet module "#{name}" from "#{namespace}" | ||
And a file named "managed_modules.yml" with: | ||
""" | ||
--- | ||
- puppet-test | ||
- #{name} | ||
""" | ||
And a file named "modulesync.yml" with: | ||
""" | ||
--- | ||
namespace: #{namespace} | ||
""" | ||
And a git_base option appended to "modulesync.yml" for local tests | ||
) | ||
write_file('modulesync.yml', <<~CONFIG) | ||
--- | ||
namespace: sources | ||
git_base: file://#{expand_path('.')}/ | ||
CONFIG | ||
end | ||
|
||
Given Regexp.new(/a remote module repository with "(.+?)" as the default branch/) do |branch| | ||
Given 'a mocked git configuration' do | ||
steps %( | ||
Given a directory named "sources" | ||
And I run `git clone --mirror https://github.com/maestrodev/puppet-test sources/puppet-test` | ||
And a file named "managed_modules.yml" with: | ||
""" | ||
--- | ||
- puppet-test | ||
""" | ||
Given a mocked home directory | ||
And I run `git config --global user.name Aruba` | ||
And I run `git config --global user.email aruba@example.com` | ||
) | ||
write_file('modulesync.yml', <<~CONFIG) | ||
--- | ||
namespace: sources | ||
git_base: file://#{expand_path('.')}/ | ||
CONFIG | ||
|
||
cd('sources/puppet-test') do | ||
steps %( | ||
And I run `git branch -M master #{branch}` | ||
And I run `git symbolic-ref HEAD refs/heads/#{branch}` | ||
) | ||
end | ||
end | ||
|
||
Given 'a puppet module {string} from {string}' do |name, namespace| | ||
pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace) | ||
pmrr.populate | ||
end | ||
|
||
Given 'a git_base option appended to "modulesync.yml" for local tests' do | ||
File.write "#{Aruba.config.working_directory}/modulesync.yml", "\ngit_base: #{ModuleSync::Faker::PuppetModuleRemoteRepo.git_base}", mode: 'a' | ||
end | ||
|
||
Given 'the puppet module {string} from {string} is read-only' do |name, namespace| | ||
pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace) | ||
pmrr.read_only = true | ||
end | ||
|
||
Then 'the puppet module {string} from {string} should have no commits between {string} and {string}' do |name, namespace, commit1, commit2| | ||
pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace) | ||
expect(pmrr.commit_count_between(commit1, commit2)).to eq 0 | ||
end | ||
|
||
Then 'the puppet module {string} from {string} should have( only) {int} commit(s) made by {string}' do |name, namespace, commit_count, author| | ||
pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace) | ||
expect(pmrr.commit_count_by(author)).to eq commit_count | ||
end | ||
|
||
Then 'the puppet module {string} from {string} should have( only) {int} commit(s) made by {string} in branch {string}' do |name, namespace, commit_count, author, branch| | ||
pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace) | ||
expect(pmrr.commit_count_by(author, branch)).to eq commit_count | ||
end | ||
|
||
Then 'the puppet module {string} from {string} should have no commits made by {string}' do |name, namespace, author| | ||
step "the puppet module \"#{name}\" from \"#{namespace}\" should have 0 commits made by \"#{author}\"" | ||
end | ||
|
||
Given 'the puppet module {string} from {string} has a file named {string} with:' do |name, namespace, filename, content| | ||
pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace) | ||
pmrr.add_file(filename, content) | ||
end | ||
|
||
Then 'the puppet module {string} from {string} should have a branch {string} with a file named {string} which contains:' do |name, namespace, branch, filename, content| | ||
pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace) | ||
expect(pmrr.read_file(filename, branch)).to include(content) | ||
end | ||
|
||
Given 'the puppet module {string} from {string} has the default branch named {string}' do |name, namespace, default_branch| | ||
pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace) | ||
pmrr.default_branch = default_branch | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
require 'aruba/cucumber' | ||
|
||
require_relative '../../spec/helpers/faker' | ||
|
||
ModuleSync::Faker.working_directory = File.expand_path('faker', Aruba.config.working_directory) | ||
|
||
Before do | ||
@aruba_timeout_seconds = 5 | ||
end |
Oops, something went wrong.